Closed7
Ansible入門

Ansibleの環境構築

ホストグループの設定はインベントリと呼ばれる
inventry.yaml
webservers:
hosts:
foo.example.com:
bar.example.com:
dbservers:
hosts:
one.example.com:
two.example.com:
three.example.com:
以下のようにコマンドを実行するとインベントリで指定したホストグループに対してexample.yamlを実行できる。
ansible-playbook example.yaml -i inventory.yaml
ポート指定もできる
atlanta:
hosts:
host1:
http_port: 80
maxRequestsPerChild: 808
host2:
http_port: 303
maxRequestsPerChild: 909

インベントリやタスクに対してユーザーを指定できる。
インベントリにおいてansible_ssh_private_key_fileを指定することもできる。

アドホックコマンドを使ってリブート
ansible atlanta -a "/sbin/reboot"

ansibleのコマンド一覧

チートシート

頑張って公式読もうとしたけど、これ読んどいたらええ
このスクラップは2024/10/13にクローズされました
ログインするとコメントできます