Ansible: copy a directory content to another directory

前端 未结 12 1147
青春惊慌失措
青春惊慌失措 2020-12-24 00:25

I am trying to copy the content of dist directory to nginx directory.

- name: copy html file
  copy: src=/home/vagrant/dist/ dest=/usr/share/nginx/html/
         


        
12条回答
  •  猫巷女王i
    2020-12-24 01:21

    Resolved answer: To copy a directory's content to another directory I use the next:

    - 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.

提交回复
热议问题