I\'m trying to use ansible (version 2.1.2.0) to create named ssh access across our network of servers. Running ansible from a jump box I\'m creating a set of users and creating
OK, the problem is with lookup plugin.
It is executed on ansible control host with permissions of user that run ansible-playbook
and become: yes
don't elevate plugins' permissions.
To overcome this, capture result of user
task and use its output in further tasks:
- user:
name: "{{ item }}"
shell: /bin/bash
group: docker
generate_ssh_key: yes
ssh_key_comment: "ansible-generated for {{ item }}"
with_items:
- ansible5
- ansible6
register: new_users
become: yes
- debug: msg="user {{ item.item }} pubkey {{ item.ssh_public_key }}"
with_items: "{{ new_users.results }}"
Although you need to delegate some of this tasks, the idea will be the same.