Hello Abhijeet,
And Todd's solution just worked for me as well...! :-)
The issue was the oversight of "[0]" on cacti_query.query_result.
Just in case...
For a few of those still having to deal with 2.9, going with "{{
cacti_query.query_result[0] | map(attribute='hostname') | list }}" also
OK, thanks again for taking the time to help...
- name: print query result 01
debug:
msg: "{{ cacti_query }}"
Gives:
ok: [] => {
"msg": {
"changed": false,
"executed_queries": [
"SELECT hostname FROM host WHERE status=1"
],
"faile
Hi Alex,
Todd's solution works for me -
```
- name: print query result
debug:
msg: "{{ cacti_query.query_result[0] | map(attribute='hostname') }}"
```
```
TASK [print query result]
task path: /root/mysql.yml:13
ok
You'd need to show what's registered to cacti_query. It appears to be
saying it doesn't contain anything named "hostname". It may not contain "
query_result" either. Like I said before, it makes me question what's
registered by your query *in that particular run*. Stick another debug task
before
Yes, I'm afraid we indeed are still in a transition process...
But you did help a lot: I didn't think straight and did not try to run the
same playbook on one of our future servers, running 2.14.3.
However, it did not like the map solution.
msg: "{{ cacti_query.query_result | map(attribute='hos
That's twice this morning a working solution was inapplicable b/c someone
was still running Ansible 2.9. I know people don't always get to pick the
version of whatever software they have to use because of factors beyond
their control. We were stuck on 2.9 far longer than we would have liked.
Ho
Hi Todd,
Thanks for helping...
{{ cacti_query.query_result | map(attribute='hostname') }}
Gave me the output:
"msg": ""
Looking around I found that {{ cacti_query.query_result |
map(attribute='hostname') | list }} would be the solution for the message
above, but instead I got:
"msg": "[AnsibleUn
{{ 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:
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: ca