インフラ系SEの技術メモ

雑なエンジニアが低信頼性のメモを書いています。参考程度にとどめてください。

(RHEL)/etc/hostsが再起動すると初期化される事象が困る

なぜ...

/etc/hostsを編集するも

# systemctl reboot

で上がってくるサーバの/etc/hostsが初期状態に。

で、調べてみると

/etc/cloud/cloud.cfg

にあるファイルが悪さをしていました。

cloud.cfg

中を見ると

# cat /etc/cloud/cloud.cfg
# Configure the Datasource for both instances
datasource_list: [ ConfigDrive, NoCloud ]

user: root
ssh_pwauth: True
disable_root: False
manage_etc_hosts: True

system_info:
   # This will affect which distro class gets used
   distro: rhel
   # Other config here will be given to the distro class and/or path classes
   paths:
      cloud_dir: /var/lib/cloud/
      templates_dir: /etc/cloud/templates/
...

とありますがこの

manage_etc_hosts: True

がダメな模様。ここをコメントアウトすると解消。

cloud-initと言う機構とのことですが、どう考えもhostsを初期化したい要件なんてないので困った機能に思えました。