0
0

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

CentOS7にて

インストール

sudo yum install ansible

コンフィグ

/etc/ansible/ansible.cfg
[defaults]
fact_caching = jsonfile
fact_caching_connection = /var/tmp/ansible/cache
fact_caching_timeout = 315360000
forks = 50
gathering = smart
inventory=<< YOUR GIT REPOSITORY >>
log_path = /var/log/ansible/ansible.log
retry_files_enabled = False
private_key_file = << YOUR PRIVATE KEY >>
[inventory]
[privilege_escalation]
[paramiko_connection]
[ssh_connection]
[persistent_connection]
[accelerate]
[selinux]
[colors]
[diff]
always = yes
context = 3

ディレクトリ掘る

mkdir -p /var/log/ansible
mkdir -p /var/tmp/ansible/cache

インベントリのhostsファイルに記述する

対象のサーバのauthorized_keysに.pubの中身を追記する。

試しにやる

ansible all -m shell -a "uname -n"

成功したら、セットアップ

ansible all -m setup

Tips

  • ansible.cfgの中でdiffをalwaysにしておくと、いちいちdry runの時に-Dのオプションをつける必要がなくてよい
  • ansible.cfgの中でinventoriesをあらかじめ設定しておけば、ansibleを使ったオペレーションも本番とステージングで分ける必要がなくてよい。
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?