diff --git a/roles/init-server/tasks/spawn.yml b/roles/init-server/tasks/spawn.yml index eaa2178..e11e808 100644 --- a/roles/init-server/tasks/spawn.yml +++ b/roles/init-server/tasks/spawn.yml @@ -89,18 +89,16 @@ vars: ansible_user: root loop: "{{ groups[instance] | default(hostvars[instance]) }}" - # @TODO find way to incorporate use of 'groups[instance] | default(hostvars[instance]' for - # looping without loop nesting in below task - name: Providing authorized keys for server root account - delegate_to: "{{ (groups[instance] | default(hostvars[instance]))[0] }}" + delegate_to: "{{ item[0] }}" delegate_facts: true remote_user: root ansible.posix.authorized_key: user: "{{ ansible_user }}" - key: "{{ lookup('file', item) }}" + key: "{{ lookup('file', item[1]) }}" state: present vars: ansible_user: root - loop: "{{ root_pubkey_paths }}" + loop: "{{ (groups[instance] | default(hostvars[instance])) | product(root_pubkey_paths) }}" tags: - lan