7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ansibleでホスト名を各ホスト固有の設定にする

Posted at

世の皆様方は、調べずとも使えていたと思いますが
僕自身が結構ハマってしまったのでメモがてらに。

環境は省略しますが、Ansibleで設定したいノードが2台あるとして
それぞれに固有のホスト名を指定したい場合は下記のようにすればやってくれるようです。

/etc/hosts

[sample]
my_host ansible_ssh_host=192.168.1.1 # これはノード1
my_host2 ansible_ssh_host=192.168.1.2 # これはノード2

change_hostname.yml

- hosts: sample
  user: hogehoge
  sudo: yes

  tasks:
    - name: change hostname per server
      hostname: name=" {{ inventory_hostname }} "

これに2日くらいかかるとは・・・

7
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?