我使用以下脚本加密了一堆文件(证书)
for i in $(find . -type f); do ansible-vault encrypt $i --vault-password-file ~/.vault && echo $i encrypted ; done
在rsyncing期间我运行这样的东西
- name: Copy letsencrypt files
synchronize:
src: "{{ path }}/letsencrypt/"
dest: /etc/letsencrypt/
rsync_path: "sudo rsync"
rsync_opts:
- "--delete"
- "--checksum"
- "-a"
notify:
- Reload Nginx
我遇到的问题是移动的文件仍然是加密的。我认为ansible足够智能,可以检测它是否像我在这里一样加密和解密
- name: Copy deploy private key
copy:
content: "{{ private_key_content }}"
dest: "/home/deploy/.ssh/id_rsa"
owner: deploy
group: deploy
mode: 0600
no_log: true
回到前面的问题,如何在rsyncing之前确保文件夹/文件中的文件被解密?
编辑:
我尝试使用copy module,因为它是加密感知但模块似乎挂起。注意到ansible github目录的复制模块的一些问题,我回来同步。
我也尝试过with_fileglob方法,但这会使目录结构变得平坦。
编辑2:
我得到了加密,解密以使用复制模块,但速度非常慢。
在ansible网站上已经有一个问题https://github.com/ansible/ansible/issues/45161开放,结论是:
Synchronize is a wrapper around rsync, I doubt that you can hook into the
process like that. You might want to implement a custom module doing this
or use something, which supports it.