# Issue with generating passwords as part of a host\_vars file

**URL:** <https://forum.ansible.com/t/issue-with-generating-passwords-as-part-of-a-host-vars-file/13536>\
**Category:** Ansible Project\
**Created:** [September 23, 2013, 6:53pm UTC](https://forum.ansible.com/t/issue-with-generating-passwords-as-part-of-a-host-vars-file/13536 "2013-09-23T18:53:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jake\_Clarkson1](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@Jake\_Clarkson1](https://forum.ansible.com/u/Jake_Clarkson1)\
**Post date:** [September 23, 2013, 6:53pm UTC](https://forum.ansible.com/t/issue-with-generating-passwords-as-part-of-a-host-vars-file/13536/1 "2013-09-23T18:53:41Z")

</div>

Hey guys,

I’m having an issue with trying to use generate a random password as part of a `host_vars` file.

I’m using the `lookup` tool to generate a password as described in [http://www.ansibleworks.com/docs/playbooks2.html#lookup-plugins-accessing-outside-data](http://www.ansibleworks.com/docs/playbooks2.html#lookup-plugins-accessing-outside-data).

In my file within `host_vars` I have the following:

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [September 25, 2013, 12:36am UTC](https://forum.ansible.com/t/issue-with-generating-passwords-as-part-of-a-host-vars-file/13536/2 "2013-09-25T00:36:44Z")

</div>

Looks like you have some quoting issues

server\_http\_auth\_password: “{{ lookup(‘password’, ‘credentials/’ + inventory\_hostname + ‘’/password length=10 ) }}”

Should likely be:

server\_http\_auth\_password: “{{ lookup(‘password’, ‘credentials/’ + inventory\_hostname + ‘/password length=10’ ) }}”

---

<div class="post-metadata">

**Author:** ![Jake\_Clarkson1](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@Jake\_Clarkson1](https://forum.ansible.com/u/Jake_Clarkson1)\
**Post date:** [September 25, 2013, 1:04pm UTC](https://forum.ansible.com/t/issue-with-generating-passwords-as-part-of-a-host-vars-file/13536/3 "2013-09-25T13:04:09Z")

</div>

Sorry, my mistake, my `host_vars` file now looks like this:

---

<div class="post-metadata">

**Author:** ![Dave\_Cottlehuber](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@Dave\_Cottlehuber](https://forum.ansible.com/u/Dave_Cottlehuber)\
**Post date:** [September 25, 2013, 3:11pm UTC](https://forum.ansible.com/t/issue-with-generating-passwords-as-part-of-a-host-vars-file/13536/4 "2013-09-25T15:11:28Z")

</div>

> Sorry, my mistake, my `host_vars` file now looks like this:
> 
> ---  
> name: client01  
> server\_http\_auth\_password: "{{ lookup('password', 'credentials/' +  
> inventory\_hostname + '/http\_password length=10') }}"
> 
> I am still seeing the same issue.
> 
> Thanks!

Hi Jake,

I'm using passwords successfully like so on ansible-devel branch:

- name: create kdb if not already present  
command: kdb5\_util create -s -P '{{ lookup('password', '../credentials/kerberos/kdb') }}'  
creates=/etc/krb5kdc/stash  
notify:  
- restart kdc  
- restart kadmin

- debug: msg="kdb password is {{ lookup('password', '../credentials/kerberos/kdb') }}"

But not in vars of course. Do you need the initial "{{ .. }}" quotes.

A+  
Dave
