[deyu1@kvm19 ansible]$ ansible-doc copy
- name: Copy using inline content
copy:
content: '# This file was moved to /etc/other.conf'
dest: /etc/mine.conf
[deyu1@kvm19 ansible]$ vim webtest.yml
[deyu1@kvm19 ansible]$ cat webtest.yml
---
- name: Web test
hosts: dev
tasks:
- file:
path: /webtest
state: directory
group: webtest
mode: '2775'
- file:
src: /webtest
dest: /var/www/html/webtest
state: link
- copy:
content: "WebTest on {{ ansible_hostname }}"
dest: /webtest/index.html
[deyu1@kvm19 ansible]$ ansible-playbook webtest.yml PLAY [Web test] **************************************************************** TASK [Gathering Facts] ********************************************************* ok: [kvm11] TASK [file] ******************************************************************** ok: [kvm11] TASK [file] ******************************************************************** ok: [kvm11] TASK [copy] ******************************************************************** changed: [kvm11] PLAY RECAP ********************************************************************* kvm11 : ok=4 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
[deyu1@kvm19 ansible]$ ansible dev -m shell -a "cat /webtest/index.html" kvm11 | CHANGED | rc=0 >> WebTest on kvm11
[deyu1@kvm19 ansible]$ curl http://kvm11/webtest/index.html [deyu1@kvm19 ansible]$ curl http://kvm11/webtest/ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>403 Forbidden</title> </head><body> <h1>Forbidden</h1> <p>You don't have permission to access /webtest/ on this server.<br /> </p> </body></html>