
ansible-lint's name[template] check looks for templates and says they should only be at the end of the string. This is because in many circumstances, including errors, the name can't be templated in -- so the message has a chance of not making sense. Honestly I can never remember when it's safe to use templates in names and not; this seems reasonable enough compromise. Change-Id: I3a415c7706494f393b126b36d7eec7193638a3f1
36 lines
1.2 KiB
YAML
36 lines
1.2 KiB
YAML
---
|
|
# Use a block to add become to a set of tasks
|
|
- name: Add build ssh key
|
|
block:
|
|
# Add the authorization first, to take advantage of manage_dir
|
|
- name: Authorize build key
|
|
authorized_key:
|
|
user: "{{ copy_sshkey_target_user }}"
|
|
manage_dir: yes
|
|
key: "{{ lookup('file', zuul_temp_ssh_key ~ '.pub') }}"
|
|
|
|
- name: 'Get the user home folder for {{ copy_sshkey_target_user }}'
|
|
user:
|
|
name: "{{ copy_sshkey_target_user }}"
|
|
register: target_user_registered
|
|
|
|
# The copy module does not work with become_user even if pipelining is
|
|
# enabled when both ansible user and become_user are not root:
|
|
# http://docs.ansible.com/ansible/latest/user_guide/become.html#becoming-an-unprivileged-user
|
|
- name: Install the build private key
|
|
copy:
|
|
src: "{{ zuul_temp_ssh_key }}"
|
|
dest: "{{ target_user_registered.home }}/.ssh/id_rsa"
|
|
mode: 0600
|
|
owner: "{{ copy_sshkey_target_user }}"
|
|
force: no
|
|
|
|
- name: Install the build public key
|
|
copy:
|
|
src: "{{ zuul_temp_ssh_key }}.pub"
|
|
dest: "{{ target_user_registered.home }}/.ssh/id_rsa.pub"
|
|
mode: 0644
|
|
owner: "{{ copy_sshkey_target_user }}"
|
|
force: no
|
|
become: true
|