Hi all,
If someone could help me on the following:
I am trying to automate as maximum as possible the addition of authorized keys to my new remote servers by doing the below playbook, but I am getting the following error:
Hi all,
If someone could help me on the following:
I am trying to automate as maximum as possible the addition of authorized keys to my new remote servers by doing the below playbook, but I am getting the following error:
Something like this should work:
- name: Set up authorized_keys for the deploy user
authorized_key: user=root key="{{ lookup('file', 'public_keys/{{ item.name }}/authorized_key') }}"
with_items: pcs
Thanks Kai! That’s another way of looking at the problem Much appreciated!
But also I’m still curious, if I’d need to do a loop in a loop like I intended in the previous example, is it possible to do that in Ansible?
Kind regards,
Acrobis
To do a loop in a loop in Ansible, you need to put the inner loop in a yaml file, and the use - include: with a loop and loop_control.
You can see an example here:
https://docs.ansible.com/ansible/playbooks_loops.html#loop-control
Thanks Kai! You were really helpful!
Kind regards,
Acrobis