Question:
I am trying to copy the content of dist directory to nginx directory.
1 2 3 |
- name: copy html file copy: src=/home/vagrant/dist/ dest=/usr/share/nginx/html/ |
But when I execute the playbook it throws an error:
1 2 3 |
TASK [NGINX : copy html file] ************************************************** fatal: [172.16.8.200]: FAILED! => {"changed": false, "failed": true, "msg": "attempted to take checksum of directory:/home/vagrant/dist/"} |
How can I copy a directory that has another directory and a file inside?
Answer:
To copy a directory’s content to another directory I use the next:
1 2 3 4 5 6 |
- name: copy consul_ui files command: cp -r /home/{{ user }}/dist/{{ item }} /usr/share/nginx/html with_items: - "index.html" - "static/" |
It copies both items to the other directory. In the example, one of the items is a directory and the other is not. It works perfectly.