[英]Ansible 'synchronize' overwrites folder even though delete=no
In my Ansible role "xen", I have this task: 在我的Ansible角色“ xen”中,我有以下任务:
---
- name: Install Xen
synchronize: src=install/
dest=/
archive=yes
delete=no
I want to copy the following structure to the destination without overwriting files in the existing folders like /boot
and /lib64
: 我想将以下结构复制到目标位置,而不覆盖
/boot
和/lib64
等现有文件夹中的文件:
root@node51 [~]# tree -L 1 /etc/ansible/xenhost/xen/files/install
/etc/ansible/xenhost/xen/files/install
├── boot
├── etc
├── lib64
├── usr
└── var
5 directories, 0 files
The task worked, but it replaced all the files in /lib64
. 该任务有效,但替换了
/lib64
所有文件 。 That killed my server: 那杀死了我的服务器:
[root@localhost ~]# ls /lib64/
-bash: /usr/bin/ls: /lib64/ld-linux-x86-64.so.2: bad ELF interpreter: No such file or directory
Here's the verbose task output, truncated for brevity: 这是冗长的任务输出,为简洁起见被截断了:
TASK: [xen | Install Xen] *****************************************************
<127.0.0.1> EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1448470134.66-193795609318676 && echo $HOME/.ansible/tmp/ansible-tmp-1448470134.66-193795609318676']
<127.0.0.1> PUT /tmp/tmpb7EusD TO /root/.ansible/tmp/ansible-tmp-1448470134.66-193795609318676/synchronize
<127.0.0.1> EXEC ['/bin/sh', '-c', u'LANG=C LC_CTYPE=C /usr/bin/python /root/.ansible/tmp/ansible-tmp-1448470134.66-193795609318676/synchronize; rm -rf /root/.ansible/tmp/ansible-tmp-1448470134.66-193795609318676/ >/dev/null 2>&1']
changed: [192.168.0.123] => {"changed": true, "cmd": "rsync --delay-updates -FF --compress --archive --rsh 'ssh -o StrictHostKeyChecking=no' --out-format='<<CHANGED>>%i %n%L' \"/etc/ansible/xenhost/xen/files/install/\" \"root@192.168.0.123:/\"", "msg": "…truncated…"}
Curiously, the task didn't erase the existing files in /boot
. 奇怪的是,该任务并未清除
/boot
的现有文件。
I made sure to specify delete=no
explicitly, just in case, so it should not " Delete files that don't exist (after transfer, not before) in the src
path. " 我确信指定
delete=no
明确,为了以防万一,所以它不应该“ 删除不存在的(转移之后,而不是之前)文件src
路径。 ”
Why did the Ansible 'synchronize' module replace /lib64
but copy to /boot
as expected? 为什么Ansible的“同步”模块替换了
/lib64
却按预期复制到了/boot
?
The issue is that /lib64
is not a directory . 问题是
/lib64
不是目录 。 It is a symbolic link: 这是一个符号链接:
[root@localhost ~]# file /lib64
/lib64: symbolic link to `usr/lib64'
By having Ansible 'synchronize' rsync
your lib64
directory, it removes the symbolic link and puts an actual folder in its place . 通过具有Ansible“同步”
rsync
你lib64
目录,它消除了符号链接,并把实际的文件夹中自己的位置 。
As a result, the libraries in /usr/lib64
are no longer reachable from /lib64
, which is why everything that depended on finding libraries in /lib64
failed: 结果,
/usr/lib64
不再可以访问/usr/lib64
中的/lib64
,这就是所有依赖于/lib64
查找库的原因都失败了的原因:
[root@localhost ~]# ldd /usr/bin/ls
linux-vdso.so.1 => (0x00007fffa9118000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fe4b9630000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007fe4b9428000)
libacl.so.1 => /lib64/libacl.so.1 (0x00007fe4b9218000)
libc.so.6 => /lib64/libc.so.6 (0x00007fe4b8e50000)
libpcre.so.1 => /lib64/libpcre.so.1 (0x00007fe4b8be8000)
liblzma.so.5 => /lib64/liblzma.so.5 (0x00007fe4b89c0000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fe4b87b8000)
/lib64/ld-linux-x86-64.so.2 (0x00007fe4b9860000)
libattr.so.1 => /lib64/libattr.so.1 (0x00007fe4b85b0000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fe4b8390000)
Copy to /usr/lib64
instead. 复制到
/usr/lib64
。 Put the libraries to copy in /etc/ansible/xenhost/xen/files/install/usr/lib64
instead of in /etc/ansible/xenhost/xen/files/install/lib64
, and make sure the latter path does not exist. 将要复制的库放在
/etc/ansible/xenhost/xen/files/install/usr/lib64
而不是在/etc/ansible/xenhost/xen/files/install/lib64
,并确保后一个路径不存在。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.