jmespath prior to running json_query filter, yet already installed

I’m running this section of code on a proxmox ansible controller. And I still get an error saying jmespath not found.

fatal: [master]: FAILED! => {“msg”: “You need to install "jmespath" prior to running json_query filter”}

In the same playbook, as a pre-task, I’ve tried to apt install python3-jmespath and python-jmespath, and still get the error.

  • name: 06_create_vm_template | Install jmespath and proxmoxer via pip
    pip:
    name:

  • jmespath

  • proxmoxer
    tags: [ install ]

  • name: 06_create_vm_template | set vm_ip_addrs from qm guest network-get-interfaces
    set_fact:
    vm_ip_addrs: “{{ vm_ip_addrs + (template_ip | from_json | json_query(jmesquery) | ipaddr(‘10.9.0.10/16’) | list) }}”
    vars:
    jmesquery: ‘[*].“ip-addresses”.“ip-address”’
    loop: “{{ result.results | map(attribute=‘stdout’) | list }}”
    loop_control:
    loop_var: “template_ip”
    index_var: counter

Any ideas? Thanks!

You cannot install a dependency needed for a filter plugin, within the same playbook that requires it as a dependency. Filter plugins are loaded at ansible startup, and the imports are processed and cached by python at this time.

As such, if it is missing at the beginning of the playbook execution, it will remain missing for the remainder of the execution.

I should also indicate that the dependency for filters, must be installed on the Ansible controller, and installed using the python used to run Ansible.

Thank you Matt. I must have missed that in the documentation. I appreciate the help!!