I have the below output that I'm trying to parse and filter:
- name: lvs
debug:
msg: "{{ ansible_lvm.lvs }}"
ok: [localhost] => {
"msg": {
"av_root_snapshot": {
"size_g": "4.00",
"vg": "vg_root"
},
"av_var_snapshot": {
"size_g": "5.00",
"vg": "vg_root"
},
"lv_root": {
"size_g": "20.00",
"vg": "vg_root"
},
"lv_var": {
"size_g": "15.00",
"vg": "vg_root"
}
}
}
I'm trying to create a list of out it so it returns the following:
av_root_snapshot vg_root
av_var_snapshot vg_root
I am able to get the values of 'vg' via:
- name: get snap
debug:
msg: "{{ ansible_lvm.lvs | json_query('*.vg') }}"
But what I can't seem to figure out is how to filter the root object names that end in *snapshot and parse the value of "vg". I'm trying to do this so I can also delete those snapshots.
How do I properly filter the above output and parse for the information I need?