'Is it possible to import child yaml file in main yaml where child yaml will decrypt login info with ansible-vault
>>> main.yaml
---
- hosts: localhost
connection: local
gather_facts: false
vars_files:
- child.yml
tasks:
- debug:
var: username
- name: Run Custom Module
run_task:
ip: "{{ ip }}"
username: "{{ username }}"
password: "{{ password }}"
no_log: false
register: result
>>> child.yaml
---
- name: Child Playbook
hosts: all
vars_files:
- secrets.txt
vars:
test_user: "{{ username }}"
Note:
run_task is custom module which accepts three parameters as input.
secrets.txt is ansible-vault encrypted file which contains one key-value pair: username, password
Command to run the playbook:
ansible-playbook -vvvv main.yml --vault-password-file ~/.vault_pass -e 'ip=10.0.0.0'
I want to include this child yaml file where ever am using these credentials instead of repeating the code in main playbooks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
