ansible execute playbook

ansible을 이용한 playbook 실행 

1. 환경준비
    Centos 7.x

2. edit playbook

[root@localhost ~]# vi /etc/ansible/hosts
[testgroup]
192.168.0.156 ansible_connection=ssh ansible_ssh_user=min ansible_ssh_pass=xxxxxx ansible_ssh_common_args='-o StrictHostKeyChecking=no'
192.168.0.116 ansible_connection=ssh ansible_ssh_user=min ansible_ssh_pass=xxxxxx ansible_ssh_common_args='-o StrictHostKeyChecking=no'
192.168.0.177 ansible_connection=ssh ansible_ssh_user=min ansible_ssh_pass=xxxxxx ansible_ssh_common_args='-o StrictHostKeyChecking=no'

[root@localhost ~]# vi test.yml
- hosts: testgroup
  tasks:
    - script: /usr/bin/date >> /tmp/date.log
~
~
[root@localhost ~]# ansible-playbook test.yml

PLAY [testgroup] ******************************************************************************************************************************

TASK [Gathering Facts] ************************************************************************************************************************
ok: [192.168.0.116]
ok: [192.168.0.156]
ok: [192.168.0.177]

TASK [script] *********************************************************************************************************************************
changed: [192.168.0.116]
changed: [192.168.0.156]
changed: [192.168.0.177]

PLAY RECAP ************************************************************************************************************************************
192.168.0.116              : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
192.168.0.156              : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
192.168.0.177              : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

[root@localhost ~]#

댓글

이 블로그의 인기 게시물

error You have $NVM_DIR set to "/root/.nvm", but that directory does not exist. Check your profile files and environment.

linux mint install xrdp

centos 6.x yum update problem making ssl connection