[root@puppet ansible]# ansible vpn -m shell -a “ls -l /tmp/” -u test –private-key=/root/denglei -k
SSH password:
172.17.0.10 | success | rc=0 >>
total 96
-rw-r–r– 1 root root 41692 May 21 13:02 config
-rw-r–r– 1 root root 1228 Jun 12 18:24 install_pptpd_vpn.sh
-rwxr-xr-x 1 root root 7 Jun 13 19:33 server
-rw-rw-r– 1 test test 7 Jun 14 17:07 server-test
-rw-rw-r– 1 test test 7 Jun 18 00:50 test-server-1
-rw-rw-r– 1 test test 7 Jun 18 00:50 test-server-2
-rw-rw-r– 1 test test 7 Jun 18 00:50 test-server-3
-rw-r–r– 1 root root 82 Jun 12 18:21 test.log
-rw-r–r– 1 root root 290 Jun 12 18:21 test.sh
-rw-r–r– 1 root root 2444 Apr 28 2012 vpn_centos6.sh
-rw——- 1 root root 727 Jun 10 18:21 yum_save_tx-2014-06-10-18-21UrqDAp.yumtx
-rw-rw-r– 1 zabbix zabbix 4664 Jun 14 00:30 zabbix_agentd.log
-rw-rw-r– 1 zabbix zabbix 5 Jun 14 00:30 zabbix_agentd.pid
[root@puppet ansible]# cat delete.yml
—
– hosts: vpn
remote_user: test
gather_facts: True
tasks:
– name: if system is centos,then rm /tmp/test-server-1
shell: rm -rf /tmp/test-server-1
when: ansible_os_family == “RedHat”
[root@puppet ansible]# ansible-playbook delete.yml –private-key=/root/denglei -k
[WARNING]: The version of gmp you have installed has a known issue regarding
timing vulnerabilities when used with pycrypto. If possible, you should update
it (ie. yum update gmp).
SSH password:
PLAY [vpn] ********************************************************************
GATHERING FACTS ***************************************************************
ok: [172.17.0.10]
TASK: [if system is centos,then rm /tmp/test-server-1] ************************
changed: [172.17.0.10]
PLAY RECAP ********************************************************************
172.17.0.10 : ok=2 changed=1 unreachable=0 failed=0
[root@puppet ansible]# ansible vpn -m shell -a “ls -l /tmp/” -u test –private-key=/root/denglei -k
SSH password:
172.17.0.10 | success | rc=0 >>
total 92
-rw-r–r– 1 root root 41692 May 21 13:02 config
-rw-r–r– 1 root root 1228 Jun 12 18:24 install_pptpd_vpn.sh
-rwxr-xr-x 1 root root 7 Jun 13 19:33 server
-rw-rw-r– 1 test test 7 Jun 14 17:07 server-test
-rw-rw-r– 1 test test 7 Jun 18 00:50 test-server-2
-rw-rw-r– 1 test test 7 Jun 18 00:50 test-server-3
-rw-r–r– 1 root root 82 Jun 12 18:21 test.log
-rw-r–r– 1 root root 290 Jun 12 18:21 test.sh
-rw-r–r– 1 root root 2444 Apr 28 2012 vpn_centos6.sh
-rw——- 1 root root 727 Jun 10 18:21 yum_save_tx-2014-06-10-18-21UrqDAp.yumtx
-rw-rw-r– 1 zabbix zabbix 4664 Jun 14 00:30 zabbix_agentd.log
-rw-rw-r– 1 zabbix zabbix 5 Jun 14 00:30 zabbix_agentd.pid