ansible / proposals

Repository for sharing and tracking progress on enhancement proposals for Ansible.
Creative Commons Zero v1.0 Universal
93 stars 19 forks source link

Retrieve secrets vars from azure key vault #135

Closed yungezz closed 4 years ago

yungezz commented 6 years ago

Proposal:

Author: @yungezz

Date: 2018-08-01

Motivation

Secrets used in Ansible playbooks, such as ssh key, are saved in environment variables or files on specific ansible control machine. This will cause setup/management effort when swtiching to new control machines. When secrets are updated, all copy will need be updated.

Problems

Solution proposal

   vars:
     new_password: !azurekeyvault | <your_vault_name>.vault.azure.net:<secret_name>(/<secret_version>)

   tasks:
   - name: update mysql root password
     mysql_user:
       name: root
       host: "{{ item }}"
       password: "{{ new_password }}
       priv: "*.*:ALL,GRANT"

Dependencies

More info

We have a PR here on implementation, and below is an example on how to use it:

 - name: copy
    copy:
      content=!azurekeyvault | !azurekeyvault:https://kvtesttest.vault.azure.net/:ansiblesecret
      dest=~/src/ansible-testapp/kvtest.txt
agaffney commented 6 years ago

This sounds like something that should probably be a lookup plugin.

webknjaz commented 6 years ago

And it should probably be more generic. There's also HashiCorp Vault and others.

tlourey commented 5 years ago

+1 for this

jamesjrwood commented 5 years ago

+1 here as well - is this in the works?

jullianoacqio commented 4 years ago

+1

yungezz commented 4 years ago

this proposal and PR is rejected since it changed ansible core. while the PR of implementation is still could be used as a reference https://github.com/ansible/ansible/pull/42290. Meanwhile, we added a lookup plugin in our role: https://github.com/Azure/azure_preview_modules/blob/master/lookup_plugins/azure_keyvault_secret.py.