gantsign / ansible-role-intellij

Ansible role for installing the IntelliJ IDEA IDE

Home Page:https://galaxy.ansible.com/gantsign/intellij

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fail to apply if inject_facts_as_vars is False

kai2nenobu opened this issue · comments

Description

If inject-facts-as-vars is False, a play fails with a following error.

The task includes an option with an undefined variable. The error was: {{ x_ansible_download_dir | default(ansible_env.HOME + '/.ansible/tmp/downloads') }}: 'ansible_env' is undefined

The error appears to be in '/home/kai2nenobu/.ansible/roles/gantsign.intellij/tasks/install.yml': line 33, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: create download directory
  ^ here

This is because ansible cannot access ansible_env.HOME when inject-facts-as-vars is False. Instead, ansible_facts.env.HOME should be used. (Related FAQ)

Step to reproduce

playbook.yml

- hosts: localhost
  vars:
    ansible_connection: local
  roles:
    - role: gantsign.intellij

ansible.cfg

[defaults]
inject_facts_as_vars = False

and execute a following command.

ansible-playbook -i localhost, playbook.yml
console output
$ ansible-playbook -i localhost, playbook.yml -vvv
ansible-playbook 2.10.6
  config file = /home/kai2nenobu/tmp/intellij-bug/ansible.cfg
  configured module search path = ['/home/kai2nenobu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/kai2nenobu/.cache/pypoetry/virtualenvs/my-ansible-roles-URnQRtvU-py3.8/lib/python3.8/site-packages/ansible
  executable location = /home/kai2nenobu/.cache/pypoetry/virtualenvs/my-ansible-roles-URnQRtvU-py3.8/bin/ansible-playbook
  python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
Using /home/kai2nenobu/tmp/intellij-bug/ansible.cfg as config file
Parsed localhost, inventory source with host_list plugin
statically imported: /home/kai2nenobu/.ansible/roles/gantsign.intellij/tasks/install.yml
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: playbook.yml *************************************************************************************************************************************************************************************************************************************
1 plays in playbook.yml

PLAY [localhost] *******************************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] *************************************************************************************************************************************************************************************************************************************
task path: /home/kai2nenobu/tmp/intellij-bug/playbook.yml:1
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: kai2nenobu
<localhost> EXEC /bin/sh -c 'echo ~kai2nenobu && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/kai2nenobu/.ansible/tmp `"&& mkdir "` echo /home/kai2nenobu/.ansible/tmp/ansible-tmp-1615552210.9651847-2339-174108017781163 `" && echo ansible-tmp-1615552210.9651847-2339-174108017781163="` echo /home/kai2nenobu/.ansible/tmp/ansible-tmp-1615552210.9651847-2339-174108017781163 `" ) && sleep 0'
<localhost> Attempting python interpreter discovery
<localhost> EXEC /bin/sh -c 'echo PLATFORM; uname; echo FOUND; command -v '"'"'/usr/bin/python'"'"'; command -v '"'"'python3.7'"'"'; command -v '"'"'python3.6'"'"'; command -v '"'"'python3.5'"'"'; command -v '"'"'python2.7'"'"'; command -v '"'"'python2.6'"'"'; command -v '"'"'/usr/libexec/platform-python'"'"'; command -v '"'"'/usr/bin/python3'"'"'; command -v '"'"'python'"'"'; echo ENDFOUND && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python && sleep 0'
Using module file /home/kai2nenobu/.cache/pypoetry/virtualenvs/my-ansible-roles-URnQRtvU-py3.8/lib/python3.8/site-packages/ansible/modules/setup.py
<localhost> PUT /home/kai2nenobu/.ansible/tmp/ansible-local-2335ouq_2phb/tmpg7rygul9 TO /home/kai2nenobu/.ansible/tmp/ansible-tmp-1615552210.9651847-2339-174108017781163/AnsiballZ_setup.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/kai2nenobu/.ansible/tmp/ansible-tmp-1615552210.9651847-2339-174108017781163/ /home/kai2nenobu/.ansible/tmp/ansible-tmp-1615552210.9651847-2339-174108017781163/AnsiballZ_setup.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python /home/kai2nenobu/.ansible/tmp/ansible-tmp-1615552210.9651847-2339-174108017781163/AnsiballZ_setup.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/kai2nenobu/.ansible/tmp/ansible-tmp-1615552210.9651847-2339-174108017781163/ > /dev/null 2>&1 && sleep 0'
[DEPRECATION WARNING]: Distribution ubuntu 20.04 on host localhost should use /usr/bin/python3, but is using /usr/bin/python for backward compatibility with prior Ansible releases. A future Ansible release will default to using the discovered platform
 python for this host. See https://docs.ansible.com/ansible/2.10/reference_appendices/interpreter_discovery.html for more information. This feature will be removed in version 2.12. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.
ok: [localhost]
META: ran handlers

TASK [gantsign.intellij : include OS family specific vars] *************************************************************************************************************************************************************************************************
task path: /home/kai2nenobu/.ansible/roles/gantsign.intellij/tasks/install.yml:2
ok: [localhost] => (item=/home/kai2nenobu/.ansible/roles/gantsign.intellij/vars/../vars/os-families/default.yml) => {
    "ansible_facts": {
        "intellij_dependencies": []
    },
    "ansible_included_var_files": [
        "/home/kai2nenobu/.ansible/roles/gantsign.intellij/vars/os-families/default.yml"
    ],
    "ansible_loop_var": "item",
    "changed": false,
    "item": "/home/kai2nenobu/.ansible/roles/gantsign.intellij/vars/../vars/os-families/default.yml"
}

TASK [gantsign.intellij : assert edition vars] *************************************************************************************************************************************************************************************************************
task path: /home/kai2nenobu/.ansible/roles/gantsign.intellij/tasks/install.yml:8
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [gantsign.intellij : load edition vars] ***************************************************************************************************************************************************************************************************************
task path: /home/kai2nenobu/.ansible/roles/gantsign.intellij/tasks/install.yml:13
ok: [localhost] => {
    "ansible_facts": {
        "intellij_application_name": "IntelliJ IDEA Community Edition",
        "intellij_desktop_filename": "jetbrains-idea-ce.desktop",
        "intellij_redis_filename": "ideaIC-{{ intellij_version }}.tar.gz",
        "intellij_startup_wm_class": "jetbrains-idea-ce",
        "intellij_user_dir": "IdeaIC{{ intellij_version | regex_replace('^([0-9]+\\.[0-9]+)(\\..*)?$', '\\1') }}"
    },
    "ansible_included_var_files": [
        "/home/kai2nenobu/.ansible/roles/gantsign.intellij/vars/../vars/editions/community.yml"
    ],
    "changed": false
}

TASK [gantsign.intellij : load version vars] ***************************************************************************************************************************************************************************************************************
task path: /home/kai2nenobu/.ansible/roles/gantsign.intellij/tasks/install.yml:16
ok: [localhost] => (item=/home/kai2nenobu/.ansible/roles/gantsign.intellij/vars/../vars/versions/2020.3.2-community.yml) => {
    "ansible_facts": {
        "intellij_redis_sha256sum": "2db84ef019da6157d544c43d780901d6178bd029ce686267eec9ac23e2ae727e"
    },
    "ansible_included_var_files": [
        "/home/kai2nenobu/.ansible/roles/gantsign.intellij/vars/versions/2020.3.2-community.yml"
    ],
    "ansible_loop_var": "item",
    "changed": false,
    "item": "/home/kai2nenobu/.ansible/roles/gantsign.intellij/vars/../vars/versions/2020.3.2-community.yml"
}

TASK [gantsign.intellij : assert version vars] *************************************************************************************************************************************************************************************************************
task path: /home/kai2nenobu/.ansible/roles/gantsign.intellij/tasks/install.yml:22
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [gantsign.intellij : install dependencies] ************************************************************************************************************************************************************************************************************
task path: /home/kai2nenobu/.ansible/roles/gantsign.intellij/tasks/install.yml:27
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: kai2nenobu
<localhost> EXEC /bin/sh -c 'echo ~kai2nenobu && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/kai2nenobu/.ansible/tmp `"&& mkdir "` echo /home/kai2nenobu/.ansible/tmp/ansible-tmp-1615552218.744042-2444-14956246146862 `" && echo ansible-tmp-1615552218.744042-2444-14956246146862="` echo /home/kai2nenobu/.ansible/tmp/ansible-tmp-1615552218.744042-2444-14956246146862 `" ) && sleep 0'
Using module file /home/kai2nenobu/.cache/pypoetry/virtualenvs/my-ansible-roles-URnQRtvU-py3.8/lib/python3.8/site-packages/ansible/modules/apt.py
<localhost> PUT /home/kai2nenobu/.ansible/tmp/ansible-local-2335ouq_2phb/tmpz9la63lz TO /home/kai2nenobu/.ansible/tmp/ansible-tmp-1615552218.744042-2444-14956246146862/AnsiballZ_apt.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/kai2nenobu/.ansible/tmp/ansible-tmp-1615552218.744042-2444-14956246146862/ /home/kai2nenobu/.ansible/tmp/ansible-tmp-1615552218.744042-2444-14956246146862/AnsiballZ_apt.py && sleep 0'
<localhost> EXEC /bin/sh -c 'sudo -H -S -n  -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-nqiffzkpehofinvbhkxoeyygcwxqzfbi ; /usr/bin/python /home/kai2nenobu/.ansible/tmp/ansible-tmp-1615552218.744042-2444-14956246146862/AnsiballZ_apt.py'"'"' && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/kai2nenobu/.ansible/tmp/ansible-tmp-1615552218.744042-2444-14956246146862/ > /dev/null 2>&1 && sleep 0'
ok: [localhost] => {
    "cache_update_time": 1615472791,
    "cache_updated": false,
    "changed": false,
    "invocation": {
        "module_args": {
            "allow_unauthenticated": false,
            "autoclean": false,
            "autoremove": false,
            "cache_valid_time": 0,
            "deb": null,
            "default_release": null,
            "dpkg_options": "force-confdef,force-confold",
            "force": false,
            "force_apt_get": false,
            "install_recommends": null,
            "name": [],
            "only_upgrade": false,
            "package": [],
            "policy_rc_d": null,
            "purge": false,
            "state": "present",
            "update_cache": null,
            "update_cache_retries": 5,
            "update_cache_retry_max_delay": 12,
            "upgrade": null
        }
    }
}

TASK [gantsign.intellij : create download directory] *******************************************************************************************************************************************************************************************************
task path: /home/kai2nenobu/.ansible/roles/gantsign.intellij/tasks/install.yml:33
fatal: [localhost]: FAILED! => {
    "msg": "The task includes an option with an undefined variable. The error was: {{ x_ansible_download_dir | default(ansible_env.HOME + '/.ansible/tmp/downloads') }}: 'ansible_env' is undefined\n\nThe error appears to be in '/home/kai2nenobu/.ansible/roles/gantsign.intellij/tasks/install.yml': line 33, 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: create download directory\n  ^ here\n"
}

PLAY RECAP *************************************************************************************************************************************************************************************************************************************************
localhost                  : ok=7    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

Environment

  • OS: Ubuntu 20.04
  • python: 3.8.5
  • ansible version: 3.0.0
  • ansible-base version: 2.10.6
  • gantsign.intellij version: 6.2.2