Open muelli opened 9 years ago
It looks like the Ansible password
lookup plugin does not handle paths with spaces correctly. You can test this using the playbook:
---
- hosts: localhost
vars:
dir: '/tmp/dir with spaces'
tasks:
- name: Lookup the password
set_fact:
pass: '{{ lookup("password", dir + "/subdir/password") }}'
- name: Display password
debug: var=pass
When the file is created manually and looked up with file
plugin, Ansible works correctly.
I suggest that you should create an issue in the Ansible project repository about this. It cannot be sloved with a playbook change.
yep, that fails:
>cat ansible/playbook.yml
---
- hosts: localhost
vars:
dir: '/tmp/dir with spaces'
tasks:
- name: Lookup the password
set_fact:
pass: '{{ lookup("password", dir + "/subdir/password") }}'
- name: Display password
debug: var=pass
>
ansible-playbook --inventory-file=ansible/vagrant_ansible_inventory -vv ansible/playbook.yml
[WARNING]: provided hosts list is empty, only localhost is available
PLAY [localhost] **************************************************************
GATHERING FACTS ***************************************************************
<localhost> REMOTE_MODULE setup
ok: [localhost]
TASK: [Lookup the password] ***************************************************
fatal: [localhost] => Failed to template {{ lookup("password", dir + "/subdir/password") }}: need more than 1 value to unpack
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/home/muelli/playbook.retry
localhost : ok=1 changed=0 unreachable=1 failed=0
Other lookup plugins work (well, I've only tested the file one), but the password one seems to be broken. Let me file a bug.
I am trying to use the MySQL role and debops uses the lookup function to locate a password. That, however, does not work when the directory contains spaces.
The playbook is as simple as that:
and I run ansible like this:
I expected it to work fine, because it does in a directory without spaces.