zuul-jobs/roles/add-fileserver/tasks/main.yaml
Ian Wienand f76cfbab11 linters: fix spaces between filters
This fixes a number of places where we do not have spaces between
filters.  I think that this is a reasonable rule for readability (I
also think it probably was enforced, but maybe later versions got
better at detecting it?).

These are detected by a later version of Ansible lint; this change
should have no operational change to any roles but prepares us to
update in a follow-on change.

Change-Id: I07e1a109b87adce86f483d14d7e02fcecb8313d5
2022-07-27 17:13:39 +10:00

28 lines
899 B
YAML

- name: Create SSH private key tempfile
tempfile:
state: file
register: ssh_private_key_tmp
- name: Create SSH private key from secret
copy:
content: "{{ fileserver.ssh_private_key }}"
dest: "{{ ssh_private_key_tmp.path }}"
mode: 0600
- name: Add fileserver ssh key
command: "ssh-add {{ ssh_private_key_tmp.path }}"
- name: Remove SSH private key from disk
command: "shred {{ ssh_private_key_tmp.path }}"
- name: Add fileserver to inventory
add_host:
name: "{{ fileserver.fqdn }}"
ansible_user: "{{ fileserver.ssh_username | default(ansible_user) }}"
zuul_fileserver_project_path: "{{ fileserver.path }}{{ '/' + fileserver_leading_path if fileserver_leading_path is defined else '' }}/{{ zuul.project.short_name }}"
- name: Add fileserver server to known hosts
known_hosts:
name: "{{ fileserver.fqdn }}"
key: "{{ fileserver.ssh_known_hosts }}"