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

**URL:** <https://forum.ansible.com/t/how-to-incorporate-password-along-with-passwordless-login-in-ansible-dynamic-inventory/36308>\
**Category:** Ansible Project\
**Created:** [February 9, 2022, 5:36am UTC](https://forum.ansible.com/t/how-to-incorporate-password-along-with-passwordless-login-in-ansible-dynamic-inventory/36308 "2022-02-09T05:36:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shifa\_Shaikh](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Shifa\_Shaikh](https://forum.ansible.com/u/Shifa_Shaikh)\
**Post date:** [February 9, 2022, 5:36am UTC](https://forum.ansible.com/t/how-to-incorporate-password-along-with-passwordless-login-in-ansible-dynamic-inventory/36308/1 "2022-02-09T05:36:42Z")

</div>

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?
