I have a json file (/tmp/lst_instalaciones_wordpress.json) on a group of servers. This json has the info about some Wordpress installs (domain, path, version...)
{
"id": 1,
"name": "My blog",
"version": "5.9.1",
"fullPath": "/var/www/vhosts/myblog"
}
{
"id": 2,
"name": "My blog2",
"version": "5.9.2",
"fullPath": "/var/www/vhosts/myblog2"
}
{
"id": 3,
"name": "My blog3",
"version": "5.7.6",
"fullPath": "/var/www/vhosts/myblog3"
}
{
"id": 4,
"name": "My blog4",
"version": "5.9.2",
"fullPath": "/var/www/vhosts/myblog4"
}
I slurped it in a var:
- slurp:
src: /tmp/lst_instalaciones_wordpress.json
register: fichero_json
- set_fact:
lst_versiones: "{{ fichero_json.content | b64decode | from_json}}"
I have a list of all the versions, and I need to print how much installs are for each versions.
all_vers:
- 5.7.6
- 5.9.1
- 5.9.2
I'am trying different options like this but nothing works:
- set_fact:
all_installs_vers: "{{ lst_versiones | json_query('[?version==`'{{item}}'`].version') | length }}"
with_items: "{{all_vers}}"