ansible 使用local_action解密Vault加密的模板
示例
您可以使用该local_action模块运行依赖于保管库加密模板的播放。
---
- name: Decrypt template
local_action: "shell {{ view_encrypted_file_cmd }} {{ role_path }}/templates/template.enc > {{ role_path }}/templates/template"
changed_when: False
- name: Deploy template
template:
xx_src=templates/template
dest=/home/user/file
- name: Remove decrypted template
local_action: "file path={{ role_path }}/templates/template state=absent"
changed_when: False请注意changed_when:False。如果您使用角色扮演幂等测试,这一点很重要-否则,每次您运行剧本时,都会发出更改信号。在中,group_vars/all.yml您可以设置一个全局解密命令以供重用,例如,如view_encrypted_file_cmd。
group_vars/all.yml
---
view_encrypted_file_cmd: "ansible-vault --vault-password-file {{ lookup('env', 'ANSIBLE_VAULT_PASSWORD_FILE') }} view"现在,在运行播放时,您需要将ANSIBLE_VAULT_PASSWORD_FILE环境变量设置为指向您的Vault密码文件(理想情况下具有绝对路径)。
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短