[root@ ansible]# more sendmail.yml
—
– hosts: hadoop_sit
user: root
tasks:
– name: 1. Install sendmail
yum: name=sendmail state=latest
– name: 2. Start sendmail
service: name=sendmail state=running enabled=yes
simple copy file playbock
Command to run ansible playbook
1
ansible-playbook demo.yml
where ‘demo.yml’ is playbook name
Dry Run mode
1
ansible-playbook demo.yml –check
[ovi@~]$ more tsm.yml
—
– hosts: endur_dev
tasks:
– name: Copy the file
copy: src=/tmp/file.txt dest=/tmp/file.txt
[ovi@ ~]$ ansible-playbook tsm.yml –ask-pass
SSH password:
PLAY [endur_dev] **************************************************************
GATHERING FACTS ***************************************************************
ok: [ndora01.uat.my.com]
ok: [ndora01.dev.my.com]
TASK: [Copy the file] *********************************************************
changed: [ndora01.dev.my.com]
changed: [ndora01.uat.my.com]
PLAY RECAP ********************************************************************
ndora01.dev.bmocm.com : ok=2 changed=1 unreachable=0 failed=0
ndora01.uat.bmocm.com : ok=2 changed=1 unreachable=0 failed=0
another simple playbook
[ovi@ ~]$ more tsm2.yml
—
– hosts: endur_dev
tasks:
– name: Copy the file
copy: src=/tmp/file1.txt dest=/tmp/file1.txt
– name: Copy second file
copy: src=/tmp/file2.txt dest=/tmp/file2.txt