Dear all,
I started re-organising my playbooks with roles, but stumbled on some password lookup issues.
file: ansible/roles/mysql/tasks/main.yml
-
name: MySQL | Set the root password
mysql_user: user=root password=“{{ lookup(‘password’, ‘credentials/mysql/root’) }}” host=localhost -
name: MySQL | Config for easy access as root user
template: src=root-my-cnf.j2 dest=/root/.my.cnf
file: ansible/roles/mysql/template/root-my-cnf.j2
[client]
user=root
pass={{ lookup(‘password’, ‘credentials/mysql/root’) }}
I stored all my credentials previously in top-level ansible/credentials/
, and expected running the site.yml playbook with Ansible 1.4 wouldn’t change anything to my database settings.
However:
- the template action correctly and as expected uses the current password from
ansible/credentials/mysql/root
. - the mysql_user action generates a new password and writes it into
ansible/roles/mysql/files/credentials/mysql/root
.
(Note: the directory ansible/roles/mysql/files exists and contains other files but didn’t contain the credentials dir before running the site.yml)
Any ideas, besides using absolute paths which I rather not prefer, on how to make both lookups result in using the password in ansible/credentials/files/mysql/root
?
Kind regards,
Koen