# Can I set ansible\_ssh\_pass in a task?

**URL:** <https://forum.ansible.com/t/can-i-set-ansible-ssh-pass-in-a-task/15621>\
**Category:** Ansible Project\
**Created:** [July 8, 2014, 7:22am UTC](https://forum.ansible.com/t/can-i-set-ansible-ssh-pass-in-a-task/15621 "2014-07-08T07:22:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Larry\_Fast](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@Larry\_Fast](https://forum.ansible.com/u/Larry_Fast)\
**Post date:** [July 8, 2014, 7:22am UTC](https://forum.ansible.com/t/can-i-set-ansible-ssh-pass-in-a-task/15621/1 "2014-07-08T07:22:24Z")

</div>

I’m using a database system for passwords. It has a CLI for pulling data. For each server I would like to do something like

- hosts: all  
gather\_facts: no  
tasks:

local\_action: ansible\_ssh\_pass=`db_cli cli_params`

I realize this code is complete invalid. Can I do this in a task, a programatic variables section or do I need to write a dynamic inventory to access my database?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 8, 2014, 11:55am UTC](https://forum.ansible.com/t/can-i-set-ansible-ssh-pass-in-a-task/15621/2 "2014-07-08T11:55:37Z")

</div>

You can use “set\_fact” to do this.

There is a slight question of whether this actually works, as I haven’t tested it 🙂

Really, it sounds like you should look into an external inventory script for me, but if you have a CLI interface, it will hit that CLI lots of times and potentially overwhelm the local or remote end if you use large fork counts or large numbers of hosts - I’d see if it had an API if possible.

---

<div class="post-metadata">

**Author:** ![Larry\_Fast](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@Larry\_Fast](https://forum.ansible.com/u/Larry_Fast)\
**Post date:** [July 9, 2014, 3:53am UTC](https://forum.ansible.com/t/can-i-set-ansible-ssh-pass-in-a-task/15621/3 "2014-07-09T03:53:00Z")

</div>

> You can use “set\_fact” to do this.

Thanks that worked out fine.

> It sounds like you should look into an external inventory script.

What I working with is CyberArk. It’s primarily a secure password management system that does things like automatic rollover and hidden login. So I’m looking for ways to pull the passwords into my existing inventory.

Can Ansible reference two inventories? Or is there a sample external inventory script that pulls in a ‘normal’ inventory and then allows me to add to it dynamically? I suppose I could build off your existing inventory import code.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 9, 2014, 7:31pm UTC](https://forum.ansible.com/t/can-i-set-ansible-ssh-pass-in-a-task/15621/4 "2014-07-09T19:31:41Z")

</div>

"Can Ansible reference two inventories? "

If both inventories are in the same directory, “-i directory\_name” will load them both.

Any number of them can be executable or static (INI based) and group\_vars/ and host\_vars/ variables in that directory will also be loaded for each.

---

<div class="post-metadata">

**Author:** ![AnsiNoob](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@AnsiNoob](https://forum.ansible.com/u/AnsiNoob)\
**Post date:** [October 13, 2016, 4:31am UTC](https://forum.ansible.com/t/can-i-set-ansible-ssh-pass-in-a-task/15621/5 "2016-10-13T04:31:25Z")

</div>

were you able to use Ansible to pull passwords automatically from CyberArk?
