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 ~]#

댓글

이 블로그의 인기 게시물

[!] CDN: trunk URL couldn't be downloaded: https://cdn.cocoapods.org/CocoaPods-version.yml Response: URL using bad/illegal format or missing URL

starcraft map

Data Analysis with Superset - boardless chart