Copy multiple files with Ansible

前端 未结 11 1070
执念已碎
执念已碎 2021-01-29 22:29

How can I copy more than a single file into remote nodes by Ansible in a task?

I\'ve tried to duplicate the copy module line in my task to define files but it only copie

11条回答
  •  暖寄归人
    2021-01-29 23:06

    copy module is a wrong tool for copying many files and/or directory structure, use synchronize module instead which uses rsync as backend. Mind you, it requires rsync installed on both controller and target host. It's really powerful, check ansible documentation.

    Example - copy files from build directory (with subdirectories) of controller to /var/www/html directory on target host:

    synchronize:
      src: ./my-static-web-page/build/
      dest: /var/www/html
      rsync_opts:
        - "--chmod=D2755,F644" # copy from windows - force permissions
    

提交回复
热议问题