c0sco / ansible-modules-bitwarden

Bitwarden integrations for Ansible
GNU General Public License v3.0
109 stars 45 forks source link

Add `--version` when testing if `bw` command works #15

Closed saulrh closed 3 years ago

saulrh commented 3 years ago

The bw cli program recently changed so that running bw without any arguments returned a failing status, causing subprocess to raise a CalledProcessError that resulted in the lookup module failing. Invoking the program with a no-op argument like --version causes it to exit successfully, which allows us to test for its presence.

Fixes #14.

skeetmtp commented 3 years ago

👍 did similar patch on my side https://github.com/skeetmtp/ansible-modules-bitwarden/commit/14a9c0cf8f25702aa018bd6d0c72a58e27ada296

ljlapierre commented 3 years ago

I tried this change using the custom_field=true flag, I'm still seeing an error although the error is different

fatal: [hostname]: FAILED! => {"msg": "An unhandled exception occurred while templating '{{ lookup('bitwarden', 'ansible-secrets', field='my_custom_field', custom_field=true) }}'. Error was a <class 'ansible.errors.AnsibleError'>, original message: An unhandled exception occurred while running the lookup plugin 'bitwarden'. Error was a <class 'StopIteration'>, original message: "}
skeetmtp commented 3 years ago

I use custom_field too and got no issues with my similar patch.

I tried this change using the custom_field=true flag, I'm still seeing an error although the error is different

fatal: [hostname]: FAILED! => {"msg": "An unhandled exception occurred while templating '{{ lookup('bitwarden', 'ansible-secrets', field='my_custom_field', custom_field=true) }}'. Error was a <class 'ansible.errors.AnsibleError'>, original message: An unhandled exception occurred while running the lookup plugin 'bitwarden'. Error was a <class 'StopIteration'>, original message: "}
ljlapierre commented 3 years ago

I use custom_field too and got no issues with my similar patch.

Huh... I tried it on one machine yesterday and got an error, tried it on another machine today and it worked

I'll do more investigating

rkokkelk commented 3 years ago

Verified that this patch fixes issue mentioned in #14; tested on:

Weltraumschaf commented 3 years ago

Would you please merge this fix? I can't deploy anything since weeks :-(

c0sco commented 3 years ago

Apologies for the delay. Thank you so much for fixing this!