{{ cacti_query.query_result | map(attribute='hostname') }}
On 7/20/23 11:42 AM, Alex Wanderley wrote:
Hello,
I need to collect some hostnames from a MariaDB database but don't
know exactly how to properly parse the result of my query... Could
somebody help?
This how the tasks look like:
- name: Collect devices in down state
community.mysql.mysql_query:
login_db: cacti
query: SELECT hostname FROM host WHERE status=1
login_unix_socket: /run/mysqld/mysqld.sock
register: cacti_query
- name: print query result
debug:
msg: "{{ cacti_query.query_result }}"
And this is the output:
ok: [xxxxxxxxx] => {
"msg": [
[
{
"hostname": "host_A"
},
{
"hostname": "host_B"
},
{
"hostname": "host_C"
},
{
"hostname": "host_D"
}
]
]
}
How could I create a list with just the actual host names "host_A
host_*B * host_C host_D" to be used/referenced in a loop further down
my playbook?
Thanks a lot,
Alex
--
You received this message because you are subscribed to the Google Groups "Ansible
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/7cbbf374-1d36-1fa6-c7ed-15b133d656f6%40gmail.com.