MSYS2-packages icon indicating copy to clipboard operation
MSYS2-packages copied to clipboard

ansible incompatible to python-jinja 3.1

Open olafmandel opened this issue 2 years ago • 7 comments

Description

In python-jinja 3.1, the environmentfilter decorator got renamed to pass_environment, which is not taken into account in the two files core.py and mathstuff.py in the /usr/lib/python3.10/site-packages/ansible/plugins/filter directory. Fixes I can think of:

  • either search&replace all instances of environmentfilter with pass_environment
  • or change only the import lines in those files to something like from jinja2.filters import pass_environment as environmentfilter

Verification

  • [X] I have verified that my MSYS2 is up-to-date before submitting the report (see https://www.msys2.org/docs/updating/)

Windows Version

Microsoft Windows [Version 10.0.19044.1889]

Expected behavior

PLAY [Demo] ******************************************************************************************************

TASK [Saying hello] **********************************************************************************************
ok: [localhost] => {
    "msg": "Hello World"
}

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

Actual behavior

PLAY [Demo] ******************************************************************************************************

TASK [Saying hello] **********************************************************************************************
[WARNING]: Skipping plugin (/usr/lib/python3.10/site-packages/ansible/plugins/filter/core.py) as it seems to be invalid: cannot import name 'environmentfilter' from 'jinja2.filters' (/usr/lib/python3.10/site-packages/jinja2/filters.py)
[WARNING]: Skipping plugin (/usr/lib/python3.10/site-packages/ansible/plugins/filter/mathstuff.py) as it seems to be invalid: cannot import name 'environmentfilter' from 'jinja2.filters' (/usr/lib/python3.10/site-packages/jinja2/filters.py)
ok: [localhost] => {
    "msg": "Hello World"
}

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

Repro steps

$ cat <<EOF >demo.yml
- name: Demo
  hosts: localhost
  connection: local
  gather_facts: false
  vars:
    greetee: World
  tasks:
  - name: Saying hello
    debug:
      msg: 'Hello {{ greetee }}'
EOF
$ ansible-playbook -i localhost, test.yml

Are you willing to submit a PR?

No response

olafmandel avatar Sep 12 '22 18:09 olafmandel

Just checked:

So an update to a newer Ansible version is not as simple as bumping the version number and updating the checksum.

olafmandel avatar Sep 12 '22 18:09 olafmandel

thanks. we should update ansible (likely needs quite a few new packages :/)

lazka avatar Sep 14 '22 06:09 lazka

Is it possible to move ansible package to mingw?

Biswa96 avatar Sep 14 '22 06:09 Biswa96

I am running ansible under an msys shell and using things like when: ansible_os_family is match("MSYS_NT-") in my playbooks to detect if this is an MSYS2 environment or not. If this gets moved to mingw, then I need to update the MSYS2 detection: is there something more stable to detect MSYS2 independent of the specific shell that ansible is run under?

olafmandel avatar Sep 14 '22 08:09 olafmandel

Just checked:

So an update to a newer Ansible version is not as simple as bumping the version number and updating the checksum.

Subscribed. Thank you @olafmandel, don't use Windows that often anymore, will set a clean MSYS env, try to replicate the behavior, updating Ansible major version and the Python dependencies should fix this issue

alexjorgef avatar Sep 15 '22 15:09 alexjorgef

Is it possible to move ansible package to mingw?

I guess no: https://docs.ansible.com/ansible/latest/user_guide/windows_faq.html#can-ansible-run-on-windows

No, Ansible can only manage Windows hosts. Ansible cannot run on a Windows host natively, though it can run under the Windows Subsystem for Linux (WSL).

lazka avatar Sep 16 '22 06:09 lazka

I'm working on this

  • [ ] Update dependencies
  • [ ] Migrate ansible to ansible-core

alexjorgef avatar Oct 03 '22 19:10 alexjorgef