How to incorporate password along with passwordless login in ansible dynamic inventory

30 views
Skip to first unread message

shif...@gmail.com

unread,
Feb 9, 2022, 12:36:43 AM2/9/22
to Ansible Project

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 thier 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 accomodate both username for passwordless login and both username-password?

Reply all
Reply to author
Forward
0 new messages