Ansible Vault Password in variable

泄露秘密 提交于 2019-12-12 03:38:59

问题


Is there a way to access the vault password as a variable in an Ansible playbook? I am looking for something like this:

---

debug: var=ansible_vault_password

回答1:


I ended up solving this by copying the local vault password file to the server. The task to do that looks like that:

- name: setup ansible vault password file
  copy:
    src: /path/to/local/vault_pass
    dest: /root/.vault_pass
    mode: 0600
    owner: root
    group: root

And then the root user will execute the ansible-pull command.




回答2:


Try to save the password into a different file and use "vars_files" to include the password. Example:

In Password.yml:

ansible_vault_password: redhat

In Playbook.yml:

Host: xyz

vars_files: password.yml

tasks:

   debug:

       var: "{{ ansible_vault_password }}"

Try this and please let me know.



来源:https://stackoverflow.com/questions/43043701/ansible-vault-password-in-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!