Chapter 2
$ sudo pip install --upgrade pip
$ sudo pip install virtualenv
$ virtualenv $HOME/venv1
$ source $HOME/venv1/bin/activate # 仮想環境の有効化
$ deactivate # 仮想環境の無効化
- $HOME/effective_ansible/sec2/inventory.ini の設定 (p.62)
- ansible_user で Hostname に ssh するユーザ名を指定する必要がある。
- ポート番号は 22 以外なら指定必須
[test_servers]
Hostname:Port ansible_user=User
$ ansible -i inventory.ini test_servers -m userr -Kb -a 'user=user01 append=yes comment="hoge"' # 要求される BECOME password は ssh 先の管理者パスワード
- hosts: test_servers
tasks:
- name: copy file
copy:
src: /etc/hosts # これはコントロールノードのファイル
dest: /home/ansible/tmp/hosts # これは test_servers の位置
owner: ansible # ansible_ssh_user と一致しないと chown failed となるようである
mode: 0644