I ran my secrets through a playbook and locked it in ansible-vault. Following this I set up a python script that could unlock the vault.
vault.yml
#######################################################
- hosts: localhost tasks:
- name: Pull secret for password
shell: python3 CSRSecret.py
register: secret_pass
- debug:
var: secret_pass.stdout
unlockVault.py
from ansible_vault import Vault
vault = Vault('password')
data = vault.load(open('vault.yml').read())
My next step was to create a playbook that uses the python script to unlock the vaulted file then run and read it.
Step 1 testPlay.yml
---
#######################################################
# Python Script for Pulling CSR's
- hosts: localhost
tasks:
- name: Unlock file locked by Vault
shell: unlockVault.py
- name: Read Unlocked file
shell:
once it unlocks the vault.yml file I can't figure out how to run the playbook and read it, when it unlocks the playbook shows the code as seen on vault.yml