ansible-vault
ansible-vault copied to clipboard
vault_enterprise variable failure due to lack of else
The playbook fails on https://github.com/ansible-community/ansible-vault/blob/v3.0.0/tasks/main.yml#L52 with this error message when not installing vault_enterprise:
TASK [ansible-community.ansible-vault : Compute if installation is required] ***
fatal: [default]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: the inline if-expres
sion on line 1 evaluated to false and no else section was defined.\n\nThe error appears to be in '/etc/ansible/roles/ansible-comm
unity.ansible-vault/tasks/main.yml': line 52, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Compute if installation is required\n ^ here\n"}
If I change line 54 to this, it will pass:
installation_required: "{{ vault_installation is failed or installed_vault_version.stdout != vault_version~('+ent' if vault_enterprise else '') }}"
But fails upon running the installation, due to two lines at https://github.com/ansible-community/ansible-vault/blob/v3.0.0/defaults/main.yml#L11-L12. Changing those to the following allows the installation to complete successfully (alternatively, overriding those variables):
vault_version_release_site_suffix: "{{ '+ent' if vault_enterprise else '' }}{{ '.hsm' if vault_enterprise_hsm else '' }}"
vault_version_repo_suffix: "{{ '+ent' if vault_enterprise else '' }}"
I am not sure if it is my version of Ansible that doesn't like if without else, or if this is an issue in general. I'm using Ansible 2.9.27.