I give the end user to either provide username i.e dest_user for which ssh-keys is already setup on Linux for all destination hosts i.e dest_host.
Below is how I setup dynamic inventory for passwordless user
- add_host:
name: "{{ item }}"
groups: dest_nodes
ansible_user: "{{ dest_user }}"
with_items: "{{ dest_host.split() }}"
when: dest_user != ""
All good. The second scenario is when the user does not provide any dest_user then his SSO username (I get this from their Jenkins login) and password i.e., dest_pass which he enters manually should be used for all hosts in the dynamic inventory.
How can I construct dest_nodes group to accommodate both username for passwordless login and both username-password for SSO login?