Re: [ansible-project] Passing MariaDB query result - Solved

2023-07-20 Thread Alex Wanderley
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

Re: [ansible-project] Passing MariaDB query result

2023-07-20 Thread Alex Wanderley
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

Re: [ansible-project] Passing MariaDB query result

2023-07-20 Thread Abhijeet Kasurde
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

Re: [ansible-project] Passing MariaDB query result

2023-07-20 Thread Todd Lewis
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

Re: [ansible-project] Passing MariaDB query result

2023-07-20 Thread Alex Wanderley
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

Re: [ansible-project] Passing MariaDB query result

2023-07-20 Thread Todd Lewis
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

Re: [ansible-project] Passing MariaDB query result

2023-07-20 Thread Alex Wanderley
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

Re: [ansible-project] Passing MariaDB query result

2023-07-20 Thread Todd Lewis
{{ 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:  

[ansible-project] Passing MariaDB query result

2023-07-20 Thread Alex Wanderley
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