This task is part of a role which decommissions VM’s. To test one part of the role separately which is causing an issue, i have put it into a playbook.
The error i get is: "msg": "template error while templating string: No module named 'ansible.module_utils.compat.version'. String: {{ mountfat | community.general.json_query( query ) }}",
Playbook used in AAP:
---
- name: test get instana mounts
hosts: localhost
vars:
- vmname: vmcode1234
tasks:
- ansible.builtin.setup:
filter: 'ansible_mounts'
delegate_to: "{{ vmname }}"
connection: ssh
register: mountfat
- debug:
msg: "{{ mountfat | community.general.json_query( query ) }}"
vars:
query: "ansible_facts.ansible_mounts[?contains(mount,'instana')].mount"
mountfat:
{
"ansible_facts": {
"ansible_mounts": [
{
"mount": "/foo",
"device": "n/a",
"fstype": "xfs",
"options": "n/a",
"size_total": 37558423552,
"size_available": 34027737088,
"block_size": 4096,
"block_total": 9169537,
"block_available": 8307553,
"block_used": 861984,
"inode_total": 18348032,
"inode_available": 18293524,
"inode_used": 54508,
"uuid": "n/a"
},
{
"mount": "/foo",
"device": "n/a",
"fstype": "xfs",
"options": "n/a",
"size_total": 5358223360,
"size_available": 5286584320,
"block_size": 4096,
"block_total": 1308160,
"block_available": 1290670,
"block_used": 17490,
"inode_total": 2621440,
"inode_available": 2621418,
"inode_used": 22,
"uuid": "n/a"
},
{
"mount": "/foo",
"device": "n/a",
"fstype": "xfs",
"options": "n/a",
"size_total": 5358223360,
"size_available": 5276213248,
"block_size": 4096,
"block_total": 1308160,
"block_available": 1288138,
"block_used": 20022,
"inode_total": 2621440,
"inode_available": 2621365,
"inode_used": 75,
"uuid": "n/a"
},
{
"mount": "/foo",
"device": "n/a",
"fstype": "xfs",
"options": "n/a",
"size_total": 1063256064,
"size_available": 785780736,
"block_size": 4096,
"block_total": 259584,
"block_available": 191841,
"block_used": 67743,
"inode_total": 524288,
"inode_available": 523971,
"inode_used": 317,
"uuid": "n/a"
},
{
"mount": "/app/instana",
"device": "n/a",
"fstype": "xfs",
"options": "n/a",
"size_total": 2136997888,
"size_available": 2088247296,
"block_size": 4096,
"block_total": 521728,
"block_available": 509826,
"block_used": 11902,
"inode_total": 1048576,
"inode_available": 1048571,
"inode_used": 5,
"uuid": "n/a"
},
{
"mount": "/app/instana/metrics",
"device": "n/a",
"fstype": "xfs",
"options": "n/a",
"size_total": 518684672,
"size_available": 488591360,
"block_size": 4096,
"block_total": 126632,
"block_available": 119285,
"block_used": 7347,
"inode_total": 256000,
"inode_available": 255997,
"inode_used": 3,
"uuid": "n/a"
}
]
},
"invocation": {
"module_args": {
"filter": "ansible_mounts",
"gather_subset": [
"all"
],
"gather_timeout": 10,
"fact_path": "/etc/ansible/facts.d"
}
},
"_ansible_verbose_override": true,
"_ansible_no_log": false,
"changed": false,
"_ansible_delegated_vars": {
"ansible_host": "vmcode1234",
"ansible_port": null,
"ansible_user": "ansibleuser"
}
}
The module module_utils is to create plugins, i’m not using this module at all, which makes me believe AAP/podman is maybe using that. Googling on that error did not give me any leads.
What i tried and didn’t work:
1 quoted ‘qry
2 msg to var
3 set_fact used instead of debug
4 add connection: local, comment connection: ssh; comment connection: local
1: - debug:
msg: "{{ mountfat | community.general.json_query( 'query' ) }}"
vars:
query: "ansible_facts.ansible_mounts[?contains(mount,'instana')].mount"
2: - debug:
var: "{{ mountfat | community.general.json_query( query ) }}"
vars:
query: "ansible_facts.ansible_mounts[?contains(mount,'instana')].mount"
3: - set_fact:
insta_m: "{{ mountfat | community.general.json_query( qry ) }}"
vars:
qry: "ansible_facts.ansible_mounts[?contains(mount,'instana')].mount"
- debug:
var: "{{ insta_m }}"
4: - name: test get instana mounts
hosts: localhost
#connection: local
vars:
- vmname: vmcode1234
tasks:
- ansible.builtin.setup:
filter: 'ansible_mounts'
delegate_to: "{{ vmname }}"
#connection: ssh
register: mountfat
Before to try this in AAP, i tested it locally ( in my VM) and this did work. I’m puzzled how to troubleshoot this further.
---
- name: get /app/instana mounts
hosts: test
connection: local
vars:
#vars_files:
# - mountfact.yml
tasks:
- ansible.builtin.setup:
filter: 'ansible_mounts'
delegate_to: "vmcode1234"
connection: ssh
register: mountfat
- set_fact:
inst_m: "{{ mountfat | community.general.json_query( query ) }}"
vars:
query: "ansible_facts.ansible_mounts[?contains(mount,'instana')].mount"
- debug:
msg: "{{ inst_m }}"
output of above and intended required output in AAP:
TASK [debug] ***********************************************************************************************************************************************
ok: [vmcode1235] => {
"msg": [
"/app/instana",
"/app/instana/metrics"
]
}