On Tue, 11 Feb 2020 14:02:45 -0800 (PST) Anand Solomon <[email protected]> wrote:
> "msg": {
> "ansible_facts": {
> "discovered_interpreter_python": "/usr/bin/python"
> },
> "changed": false,
> "failed": false,
> "msg": [
> [
> "Revoke EXECUTE on UTL_FILE from TESTACC1;"
> ],
> [
> "Revoke EXECUTE on UTL_FILE from TESTACC2;"
> ]
> ]
> }
> }
>
> What I need to do is to generate another sql statement using this json
> output. When I run your command, it gives me
> [u'Revoke EXECUTE on UTL_FILE from TESTACC1;'][u'Revoke EXECUTE on UTL_FILE
> from TESTACC2;']
>
> Is there a filter or something we can use to get a cleaner output ?
>
>
> On Tuesday, February 11, 2020 at 4:39:08 PM UTC-5, Hugo Gonzalez wrote:
> > Without knowing anything about how you got those values, it would be {{
> > query_result.msg | join(' ') }}
Try "template". For example
- local_action:
template src=revoke.sql.j2
dest=/home/ansible/Playbooks/{{sname}}/sql/revoke.sql
with the template
$ cat revoke.sql.j2
{% for line in query_result.msg|flatten %}
{{ line }}
{% endfor %}
give
$ cat revoke.sql
Revoke EXECUTE on UTL_FILE from TESTACC1;
Revoke EXECUTE on UTL_FILE from TESTACC2;
HTH,
-vlado
--
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/20200211232940.03b42943%40gmail.com.
pgpSh1YEXgAmU.pgp
Description: OpenPGP digital signature
