Run authorized_keys as root

Using become_user only works if either the ansible_user is root
or pipeling is enabled. Use become instead to avoid the dependency
on pipelining being enabled.

Change-Id: I2ca65ab38b51d4949295674abfe594ce26fe35a1
This commit is contained in:
Andrea Frittoli (andreaf) 2018-04-24 11:57:43 +01:00
parent 4ea02ec487
commit e79be26f70

View File

@ -1,15 +1,13 @@
---
# 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') }}"
become: true
become_user: "{{ copy_sshkey_target_user }}"
# Use a block to add become to a set of tasks
- 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 {{ copy_sshkey_target_user }} user home folder
user:
name: "{{ copy_sshkey_target_user }}"