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:
parent
f49614bbcd
commit
b214e276ec
20
roles/add-sshkey/README.rst
Normal file
20
roles/add-sshkey/README.rst
Normal 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.
|
10
roles/add-sshkey/tasks/main.yaml
Normal file
10
roles/add-sshkey/tasks/main.yaml
Normal 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
|
Loading…
Reference in New Issue
Block a user