# password variable scope for delegate\_to

**URL:** <https://forum.ansible.com/t/password-variable-scope-for-delegate-to/27606>\
**Category:** Ansible Project\
**Created:** [May 23, 2018, 7:55pm UTC](https://forum.ansible.com/t/password-variable-scope-for-delegate-to/27606 "2018-05-23T19:55:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tod](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tod/32/4140_2.png) [@tod](https://forum.ansible.com/u/tod)\
**Post date:** [May 23, 2018, 7:55pm UTC](https://forum.ansible.com/t/password-variable-scope-for-delegate-to/27606/1 "2018-05-23T19:55:02Z")

</div>

Hello all,

I have a password I need to have on a delegate\_to task, but I don’t really want it passed to the other hosts. Is there a way to do this?

I’ve tried setting the variable in a group\_vars for the machine the task is delegated to, but it doesn’t load those variables, just the ones for the current host.

I can’t think of how to use the vars: option on the task itself without having another variable that would be passed on to the host.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [May 25, 2018, 6:10pm UTC](https://forum.ansible.com/t/password-variable-scope-for-delegate-to/27606/2 "2018-05-25T18:10:33Z")

</div>

Variables in Ansible is always referencing the current host, delegate\_to doesn't change that.  
To get variables from other host you need to use hostvars['\<inventory hostname of the host\>']

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [June 1, 2018, 2:41pm UTC](https://forum.ansible.com/t/password-variable-scope-for-delegate-to/27606/3 "2018-06-01T14:41:55Z")

</div>

So Kai answered your question, but I think I should clarify something  
else i see as a misconception.

Hosts don't get variables passed to them, ONLY the values assigned to  
the modules executed on the host get pushed, so defining data for a  
host does not mean that data ever makes it to the host.

Templating always happens on the controller (otherwise we would  
require jinja2 and other things on the targets) and then ONLY the data  
assigned to the specific task (module options) get passed with the  
code of the module for execution on that host.
