Skip to content

Commit 38dc7f3

Browse files
committed
fix generated public key not being injected into authorized_keys
1 parent 339f195 commit 38dc7f3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ansible/roles/basic_users/tasks/main.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,19 @@
4848
- basic_users_manage_homedir
4949

5050
- name: Write generated public key as authorized for SSH access
51+
# this only runs on the basic_users_manage_homedir so has registered var
52+
# from that host too
5153
authorized_key:
5254
user: "{{ item.name }}"
5355
state: present
5456
manage_dir: no
5557
key: "{{ item.ssh_public_key }}"
56-
loop: "{{ hostvars[ansible_play_hosts | first].basic_users_info.results }}"
58+
loop: "{{ basic_users_info.results }}"
5759
loop_control:
5860
label: "{{ item.name }}"
5961
when:
6062
- item.ssh_public_key is defined
6163
- basic_users_manage_homedir
62-
run_once: true
6364

6465
- name: Write sudo rules
6566
blockinfile:

0 commit comments

Comments
 (0)