I wanna copy directory content from /etc/yum.repos.d to /etc/yum.repos.d.org I tried like this
- name: copy yum.repos.d content
synchronize:
src: /etc/yum.repos.d
dest: /etc/yum.repos.d.org
but when I run this yml
[root@master yum.repos.d.org]# ls -al
drwxr-xr-x 3 root root 25 11월 29 18:00 .
drwxr-xr-x. 77 root root 8192 11월 29 18:00 ..
drwxr-xr-x 2 root root 324 11월 29 16:16 yum.repos.d
There's another directory. I just want the contents of /etc/yum.repos.d in /etc/yum.repos.d.org
CodePudding user response:
Use the Ansible copy module, with the remote_src option.
- name: copy yum.repos.d content
copy:
src: /etc/yum.repos.d/
dest: /etc/yum.repos.d.org
remote_src: yes
CodePudding user response:
Actually the synchronize module takes a parameter called dirs
, which is used to:
Transfer directories without recursing.
This will allow you to copy the contents of yum.repos.d
directly to yum.repos.d.org
instead of the directory itself.
- name: copy yum.repos.d content
synchronize:
src: /etc/yum.repos.d/
dest: /etc/yum.repos.d.org
dirs: true