Issue with generating passwords as part of a host_vars file

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.

In my file within host_vars I have the following:

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’ ) }}”

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

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