[deyu1@kvm19 ansible]$ ansible-playbook hosts.yml PLAY [Create /etc/myhosts] ***************************************************** TASK [Gathering Facts] ********************************************************* ok: [kvm15] ok: [kvm12] ok: [kvm11] ok: [kvm13] ok: [kvm14] TASK [Template a file to /etc/myhosts] ***************************************** skipping: [kvm12] skipping: [kvm15] skipping: [kvm13] skipping: [kvm14] changed: [kvm11] PLAY RECAP ********************************************************************* kvm11 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 kvm12 : ok=1 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0 kvm13 : ok=1 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0 kvm14 : ok=1 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0 kvm15 : ok=1 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
[deyu1@kvm19 ansible]$ ansible dev -m shell -a "cat /etc/myhosts" 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain 192.168.122.11 kvm11.deyu.wang kvm11 192.168.122.12 kvm12.deyu.wang kvm12 192.168.122.15 kvm15.deyu.wang kvm15 192.168.122.13 kvm13.deyu.wang kvm13 192.168.122.14 kvm14.deyu.wang kvm14