1.5. 変数の作成
変数は、IP アドレス、FQDN、オペレーティングシステム、SSH ユーザーなどのマネージドノードの値を設定するため、Ansible コマンドの実行時に渡す必要はありません。
変数は特定のホストに適用できます。
webservers:
hosts:
webserver01:
ansible_host: 192.0.2.140
http_port: 80
webserver02:
ansible_host: 192.0.2.150
http_port: 443
変数は、グループ内のすべてのホストにも適用できます。
webservers:
hosts:
webserver01:
ansible_host: 192.0.2.140
http_port: 80
webserver02:
ansible_host: 192.0.2.150
http_port: 443
vars:
ansible_user: my_server_user
インベントリーと Ansible インベントリー変数の詳細は、インストーラインベントリーファイル と インベントリーファイル変数 を参照してください。