【问题标题】:Decrypting ansible vault files before rsyncing在 rsync 之前解密 ansible Vault 文件
【发布时间】:2019-02-09 16:30:47
【问题描述】:

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

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:

我使用复制模块进行加密、解密,但速度非常慢。

【问题讨论】:

    标签: encryption ansible ansible-vault


    【解决方案1】:

    在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.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-13
      • 1970-01-01
      • 1970-01-01
      • 2020-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多