ACI Private_Key String to Allow for Vaulting (#54251)

* Allows the use of Private_Keys to be entered as a string instead of just a file. Making it possible to use VAULT to encrypt the key

* Fixed Issues auto check found

* Provide helpful information while avoiding credential exposure

* Restore original variable name :-)

* Fix a few other things

* Influence the default certificate_name in both cases

* Update documentation

* Add contributed docs

* Fix CI issue
This commit is contained in:
Derrick Johnson 2019-03-27 11:19:50 -05:00 committed by Dag Wieers
commit 62d3ed0e2f
4 changed files with 112 additions and 23 deletions

View file

@ -204,10 +204,14 @@ Every Ansible ACI module accepts the following parameters that influence the mod
Password for ``username`` to log on to the APIC, using password-based authentication.
private_key
Private key for ``username`` to log on to APIC, using signature-based authentication. *New in version 2.5*
Private key for ``username`` to log on to APIC, using signature-based authentication.
This could either be the raw private key content (include header/footer) or a file that stores the key content.
*New in version 2.5*
certificate_name
Name of the certificate in the ACI Web GUI. (Defaults to ``private_key`` file base name) *New in version 2.5*
Name of the certificate in the ACI Web GUI.
This defaults to either the ``username`` value or the ``private_key`` file base name).
*New in version 2.5*
timeout
Timeout value for socket-level communication.
@ -367,11 +371,70 @@ You need the following parameters with your ACI module(s) for it to work:
private_key: pki/admin.key
certificate_name: admin # This could be left out !
or you can use the private key content:
.. code-block:: yaml
:emphasize-lines: 2,3
username: admin
private_key: |
-----BEGIN PRIVATE KEY-----
<<your private key content>>
-----END PRIVATE KEY-----
certificate_name: admin # This could be left out !
.. hint:: If you use a certificate name in ACI that matches the private key's basename, you can leave out the ``certificate_name`` parameter like the example above.
Using Ansible Vault to encrypt the private key
``````````````````````````````````````````````
.. versionadded:: 2.8
To start, encrypt the private key and give it a strong password.
.. code-block:: bash
ansible-vault encrypt admin.key
Use a text editor to open the private-key. You should have an encrypted cert now.
.. code-block:: bash
$ANSIBLE_VAULT;1.1;AES256
56484318584354658465121889743213151843149454864654151618131547984132165489484654
45641818198456456489479874513215489484843614848456466655432455488484654848489498
....
Copy and paste the new encrypted cert into your playbook as a new variable.
.. code-block:: yaml
private_key: !vault |
$ANSIBLE_VAULT;1.1;AES256
56484318584354658465121889743213151843149454864654151618131547984132165489484654
45641818198456456489479874513215489484843614848456466655432455488484654848489498
....
Use the new variable for the private_key:
.. code-block:: yaml
username: admin
private_key: "{{ private_key }}"
certificate_name: admin # This could be left out !
When running the playbook, use "--ask-vault-pass" to decrypt the private key.
.. code-block:: bash
ansible-playbook site.yaml --ask-vault-pass
More information
````````````````
Detailed information about Signature-based Authentication is available from `Cisco APIC Signature-Based Transactions <https://www.cisco.com/c/en/us/td/docs/switches/datacenter/aci/apic/sw/kb/b_KB_Signature_Based_Transactions.html>`_.
- Detailed information about Signature-based Authentication is available from `Cisco APIC Signature-Based Transactions <https://www.cisco.com/c/en/us/td/docs/switches/datacenter/aci/apic/sw/kb/b_KB_Signature_Based_Transactions.html>`_.
- More information on Ansible Vault can be found on the :ref:`Ansible Vault <vault>` page.
.. _aci_guide_rest:

View file

@ -1,3 +1,5 @@
.. _vault:
Ansible Vault
=============