同步之前解密Ansible Vault文件

时间:2018-09-04 15:29:06

标签: encryption ansible ansible-vault

我使用以下脚本对一堆文件(证书)进行了加密

unhandled exception at 0x01002d62 ...

在同步过程中,我运行的是这样的

for i in $(find . -type f); do ansible-vault encrypt $i  --vault-password-file ~/.vault && echo $i encrypted ; done

我遇到的问题是,移动的文件仍然保持加密状态。我认为ansible足够聪明,可以像我在这里一样检测它是否已加密和解密

- name: Copy letsencrypt files 
  synchronize:
   src: "{{ path }}/letsencrypt/"
   dest: /etc/letsencrypt/
   rsync_path: "sudo rsync"
   rsync_opts:
    - "--delete"
    - "--checksum"
    - "-a"
  notify:
   - Reload Nginx

回到前面的问题,如何确保在同步之前解密了一个或多个文件夹中的文件

编辑:

我尝试使用copy module,因为它可以加密,但是模块似乎挂起了。注意到ansible github上目录的复制模块存在一些问题,我将重新进行同步。

我也尝试了with_fileglob方法,但是这种方法使目录结构变得平坦。

编辑2:

我可以对复制模块进行加密和解密,但是速度非常慢。

1 个答案:

答案 0 :(得分: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.