Add role for adding ssh key to remote nodes

Some tasks, such as proposal tasks, need to make outbound ssh
connections via non-ansible means. Add a role that takes a secret and
writes out a private key and optionally a known hosts entry.

Change-Id: I569b93ba0e775896b5a4f59b544fe32d1e2dce9b
This commit is contained in:
Monty Taylor 2017-08-25 17:18:27 -05:00
parent f49614bbcd
commit b214e276ec
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
2 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,20 @@
Add an ssh key to the host so that non-ansible ssh connections can be made.
**Role Variables**
.. zuul:rolevar:: ssh_key
Complex argument which contains the ssh key information. It is
expected that this argument comes from a `Secret`.
.. zuul:rolevar:: ssh_known_hosts
String containing known host signature for the remote host.
.. zuul:rolevar:: ssh_private_key
Contents of the ssh private key to use.
.. zuul:rolevar:: fqdn
The FQDN of the remote host.

View File

@ -0,0 +1,10 @@
- name: Write out ssh key
file:
path: "~/.ssh/id_rsa"
content: "{{ ssh_key.ssh_private_key }}"
- name: Add host key information to known hosts
known_hosts:
name: "{{ ssh_key.fqdn }}"
key: "{{ ssh_key.ssh_known_hosts }}"
when: ssh_key.ssh_known_hosts is defined and ssh_key.fqdn is defined