簡體   English   中英

同步之前解密Ansible Vault文件

[英]Decrypting ansible vault files before rsyncing

我使用以下腳本對一堆文件(證書)進行了加密

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

在rsync期間,我運行類似這樣的內容

- 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之前解密一個或多個文件夾中的文件?

編輯:

我嘗試使用復制模塊,因為它具有加密功能,但是該模塊似乎已掛起。 注意到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.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM