invalid syntax (keepass_http_password.py, line 121)"}

#1 · closed · 1 comments

View on GitHub ↗

stilsch

Hi Andre! I wanted to try your `keepass_http_password.py` but failing every single time. ```yaml # workstation.yaml --- ############################# - name: Workstation hosts: workstation gather_facts: false remote_user: steffen vars: #- _ansible_become_pass: "{{ lookup('keepass_http_password', 'url=ansible://linux-user login=foo') }}" #- _ansible_become_pass: "{{ lookup('keepass_http_password', 'url=https://linux-user login=foo') }}" #- _ansible_become_pass: "{{ lookup('keepass_http_password', 'ansible://linux-user login=foo') }}" - _ansible_become_pass: "{{ lookup('keepass_http_password', 'https://linux-user login=foo') }}" tasks: ############################# - set_fact: ansible_become_pass: "{{ ansible_become_pass | default(_ansible_become_pass) | default(omit) }}" - name: create bla become: true file: path: /etc/bla ``` I've tried all 4 syntax-styles you see at `vars`- but get the below error every single time. ``` bash steffen@Dell:~/ansible/workstation$ ansible-playbook workstation.yaml /home/steffen/.local/lib/python2.7/site-packages/ansible/parsing/vault/__init__.py:44: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release. from cryptography.exceptions import InvalidSignature PLAY [Workstation] *********************************************************************************************************** TASK [set_fact] ************************************************************************************************************** fatal: [localhost]: FAILED! => {"msg": "An unhandled exception occurred while templating '{{ lookup('keepass_http_password', 'https://linux-user login=foo') }}'. Error was a <type 'exceptions.SyntaxError'>, original message: invalid syntax (keepass_http_password.py, line 121)"} PLAY RECAP ******************************************************************************************************************* localhost : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0 ``` Do you have a hint for me?

Comments

aisbergg

Hi, the plugin is written with only Python 3 in mind. Python 2 is not supported. You can tell Ansible to use a specific python executable by defining the variable `ansible_python_interpreter` in your inventory, e.g.: as ini format: ```ini # for all your hosts [all:vars] ansible_python_interpreter=/usr/bin/python3 [all] # or just for a single host some_host ansible_python_interpreter=/usr/bin/python3 ``` Running the plugin on Windows hosts with WSL requires some more settings. Maybe add some notes on that topic.