used 'product' filter to avoid nested loop for host/group server address and SSH public key paths
This commit is contained in:
@@ -89,18 +89,16 @@
|
|||||||
vars:
|
vars:
|
||||||
ansible_user: root
|
ansible_user: root
|
||||||
loop: "{{ groups[instance] | default(hostvars[instance]) }}"
|
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
|
- name: Providing authorized keys for server root account
|
||||||
delegate_to: "{{ (groups[instance] | default(hostvars[instance]))[0] }}"
|
delegate_to: "{{ item[0] }}"
|
||||||
delegate_facts: true
|
delegate_facts: true
|
||||||
remote_user: root
|
remote_user: root
|
||||||
ansible.posix.authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: "{{ ansible_user }}"
|
user: "{{ ansible_user }}"
|
||||||
key: "{{ lookup('file', item) }}"
|
key: "{{ lookup('file', item[1]) }}"
|
||||||
state: present
|
state: present
|
||||||
vars:
|
vars:
|
||||||
ansible_user: root
|
ansible_user: root
|
||||||
loop: "{{ root_pubkey_paths }}"
|
loop: "{{ (groups[instance] | default(hostvars[instance])) | product(root_pubkey_paths) }}"
|
||||||
tags:
|
tags:
|
||||||
- lan
|
- lan
|
||||||
|
|||||||
Reference in New Issue
Block a user