brocade / ansible

56 stars 33 forks source link

Please consider not distributing ansible.cfg #66

Closed mgoetze5 closed 4 years ago

mgoetze5 commented 4 years ago

Some context: I have this repo checked out under /root/ansible/brocade, and I have my configuration under /root/ansible/ansible.cfg. Among other things this sets vault_identity_list. This works fine for my vault encrypted variables under /root/ansible/host_vars.

However, when I try to encrypt something in /root/ansible/playbooks/distribute_ssh_keys.yaml and call it from (working directory) /root/ansible, I get this error:

fatal: [fcsw-gts-b1]: FAILED! => {"msg": "An unhandled exception occurred while templating '{u'fos_password': u'{{fos_password}}', u'fos_ip_addr': u'{{fos_ip_addr}}', u'https': u'self', u'fos_user_name': u'{{fos_username}}'}'. Error was a <class 'ansible.parsing.vault.AnsibleVaultError'>, original message: Decryption failed (no vault secrets were found that could decrypt)"}

Deleting /root/ansible/brocade/ansible.cfg solves the problem and causes my playbook to work as expected.

I don't know why ansible is choosing the ansible.cfg from your repository, but somehow it is, so it would make my life easier if there were no ansible.cfg in your repository.

daniel-chung-broadcom commented 4 years ago

The primary job of the ansible.cfg under the repo is to point the utils directory to be included in the module_utils path. I wonder how yours is working without it if you are only using your default cfg. Did you copy the line that looks like

module_utils = utils

to your cfg file?

mgoetze5 commented 4 years ago

Yes, I have module_utils = ./brocade/utils in mine.

daniel-chung-broadcom commented 4 years ago

ok. that makes sense.

I am reluctant to simply get rid of the cfg file since, if I get rid of the ansible.cfg file, I believe that is going to mess up other users that are running the playbook as downloaded. I think it may be better to figure out what is going on here and see some other changes are needed.

Based on how I under this, you are doing something like this

cd /root/ansible ansible-playbook -i xxx playbook/distribute_ssh_key.yml

and your ansible.cfg under /root/ansible has module_utils set to ./brocade/utils

are you having trouble with vault only or other troubles as well if ansible.cfg is still under /root/ansible/brocade directory?

Thanks.

daniel-chung-broadcom commented 4 years ago

Any updates on the last question? Has this issue been resolved on your side?

mgoetze5 commented 4 years ago

Hey Daniel, sorry this has been a bit of a Heisenbug, I reinstated the ansible.cfg in your repository so I could try to trace why it was being used and then the problem just didn't occur again. I guess you can close this one if you like and I'll let you know if I have more problems in the future.

daniel-chung-broadcom commented 4 years ago

Let's go ahead and close the issue for the moment. Let's open another issue if you do run into the issue again to follow up. Thanks.