Re: [ansible-project] Re: KEY: VALUE iterations

2020-02-16 Thread Anand Solomon
Hi, I still don’t have an answer for this. Is there someone to help me ?

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5bbb8f05-382d-4a9d-a09f-a3adf85ceb12%40googlegroups.com.


Re: [ansible-project] Re: KEY: VALUE iterations

2020-02-14 Thread Anand Solomon
That was reading the first msg

 "msg": "All items completed"

We want to read the msg in results
"msg": [
[
"Revoke EXECUTE on UTL_FILE from TESTDBA;"
],
[
"Revoke EXECUTE on UTL_FILE from TSTSCH;"
]
]



On Friday, February 14, 2020 at 8:28:12 AM UTC-5, Stefan Hornburg (Racke) 
wrote:
>
> On 2/14/20 2:10 PM, Anand Solomon wrote: 
> > Thanks Rache, 
> > This didn't solve the issue. I need to read the content in the "msg" in 
> "results" section  
> > 
>
> What's the output when you run it in a loop as suggested? 
>
> Regards 
>  Racke 
>
> > 
> > 
> > On Friday, February 14, 2020 at 7:52:31 AM UTC-5, Stefan Hornburg 
> (Racke) wrote: 
> > 
> > On 2/14/20 1:31 PM, Anand Solomon wrote: 
> > > Thanks Vlado, 
> > > I am new to Ansible. I tried "query_result.results' etc. But no 
> luck. Will really appreciate and also will learn 
> > at the 
> > > same time if you can help me crack the mystery. 
> > > 
> > > Thanks for all your help. 
> > 
> > Amand, you need to use the loop in the debug task as well: 
> > 
> > - name: Display the query results 
> >   debug: 
> > msg: "{{query_result.msg}} 
> >   loop: "{{ scripts|dict2items }}" 
> > 
> > Regards 
> > Racke 
> > 
> > > 
> > > On Thursday, February 13, 2020 at 5:08:12 PM UTC-5, Vladimir Botka 
> wrote: 
> > > 
> > > On Thu, 13 Feb 2020 13:33:32 -0800 (PST) 
> > > Anand Solomon > wrote: 
> > > 
> > > > - name: Display the query results 
> > > >   debug: 
> > > > msg: "{{query_result.msg}} 
> > > > 
> > > > I get the below 
> > > >   "msg": "All items completed" 
> > > > 
> > > > I couldn't get the below, what ever I put in my debug 
> statement. Is there 
> > > > is something I should do in order to get the below messages 
> ? Thanks again 
> > > > for your help. 
> > > > 
> > > > "msg": [ 
> > > > [ 
> > > > "Revoke EXECUTE on UTL_FILE from 
> TESTDBA;" 
> > > > ], 
> > > > [ 
> > > > "Revoke EXECUTE on UTL_FILE from 
> TSTSCH;" 
> > > > ] 
> > > > ] 
> > > 
> > > What you should do in order to get the above messages? Solve 
> the mystery and 
> > > find out how you get the "msg" below. Perhaps? 
> > > 
> > > 
> > > > > > TASK [Display the query results] 
> > > > > >   
> > > > > 
> 
>  
>
> > > > >   
> > > > > > ok: "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com 
> >  <
> http://tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com 
> > >] => { 
> > > > > > "msg": { 
> > > > > > "ansible_loop_var": "item", 
> > > > > > "changed": false, 
> > > > > > "failed": false, 
> > > > > > "invocation": { 
> > > > > > "module_args": { 
> > > > > > "host": 
> > > > > > "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com <
> http://tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com> 
> >  http://tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com>>", 
> > > > > > "hostname": 
> > > > > > "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com <
> http://tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com> 
> >  http://tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com>>", 
> > > > > > "mode": "normal", 
> > > > > > "password":   
> > > > > "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",   
> > > > > > "port": "1521", 
> > > > > > "script": null, 
> > > > > > "service_name": "tstdb", 
> > > > > > "sql": "select 'Revoke ' || 
> privilege || ' on 
> > > > > > UTL_FILE from ' || grantee || ';' from dba_tab_privs 
> where 
> > > > > > table_name='UTL_FILE' and grantee not like 'APEX%' and 
> grantee !=   
> > > > > 'CTXSYS'   
> > > > > > and grantee != 'DBSNMP'  order by grantee;", 
> > > > > > "user": "SYSDBA", 
> > > > > > "username": "SYSDBA" 
> > >  

Re: [ansible-project] Re: KEY: VALUE iterations

2020-02-14 Thread Stefan Hornburg (Racke)
On 2/14/20 2:10 PM, Anand Solomon wrote:
> Thanks Rache,
> This didn't solve the issue. I need to read the content in the "msg" in 
> "results" section 
> 

What's the output when you run it in a loop as suggested?

Regards
 Racke

> 
> 
> On Friday, February 14, 2020 at 7:52:31 AM UTC-5, Stefan Hornburg (Racke) 
> wrote:
> 
> On 2/14/20 1:31 PM, Anand Solomon wrote:
> > Thanks Vlado,
> > I am new to Ansible. I tried "query_result.results' etc. But no luck. 
> Will really appreciate and also will learn
> at the
> > same time if you can help me crack the mystery.
> >
> > Thanks for all your help.
> 
> Amand, you need to use the loop in the debug task as well:
> 
> - name: Display the query results
>   debug:
>     msg: "{{query_result.msg}}
>   loop: "{{ scripts|dict2items }}"
> 
> Regards
>         Racke
> 
> >
> > On Thursday, February 13, 2020 at 5:08:12 PM UTC-5, Vladimir Botka 
> wrote:
> >
> >     On Thu, 13 Feb 2020 13:33:32 -0800 (PST)
> >     Anand Solomon > wrote:
> >
> >     > - name: Display the query results
> >     >       debug:
> >     >         msg: "{{query_result.msg}}
> >     >
> >     > I get the below
> >     >   "msg": "All items completed"
> >     >
> >     > I couldn't get the below, what ever I put in my debug statement. 
> Is there
> >     > is something I should do in order to get the below messages ? 
> Thanks again
> >     > for your help.
> >     >
> >     >                 "msg": [
> >     >                     [
> >     >                         "Revoke EXECUTE on UTL_FILE from TESTDBA;"
> >     >                     ],
> >     >                     [
> >     >                         "Revoke EXECUTE on UTL_FILE from TSTSCH;"
> >     >                     ]
> >     >                 ]
> >
> >     What you should do in order to get the above messages? Solve the 
> mystery and
> >     find out how you get the "msg" below. Perhaps?
> >
> >
> >     > > > TASK [Display the query results]
> >     > > >  
> >     > > 
> 
> >     > >  
> >     > > > ok: "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com
>  
>  >] => {
> >     > > >     "msg": {
> >     > > >                 "ansible_loop_var": "item",
> >     > > >                 "changed": false,
> >     > > >                 "failed": false,
> >     > > >                 "invocation": {
> >     > > >                     "module_args": {
> >     > > >                         "host":
> >     > > > "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com 
> 
>  >",
> >     > > >                         "hostname":
> >     > > > "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com 
> 
>  >",
> >     > > >                         "mode": "normal",
> >     > > >                         "password":  
> >     > > "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",  
> >     > > >                         "port": "1521",
> >     > > >                         "script": null,
> >     > > >                         "service_name": "tstdb",
> >     > > >                         "sql": "select 'Revoke ' || privilege 
> || ' on
> >     > > > UTL_FILE from ' || grantee || ';' from dba_tab_privs where
> >     > > > table_name='UTL_FILE' and grantee not like 'APEX%' and 
> grantee !=  
> >     > > 'CTXSYS'  
> >     > > > and grantee != 'DBSNMP'  order by grantee;",
> >     > > >                         "user": "SYSDBA",
> >     > > >                         "username": "SYSDBA"
> >     > > >                     }
> >     > > >                 },
> >     > > >                 "item": {
> >     > > >                     "key": "Script1",
> >     > > >                     "value": "select 'Revoke ' || privilege 
> || ' on
> >     > > > UTL_FILE from ' || grantee || ';' from dba_tab_privs where
> >     > > > table_name='UTL_FILE' and grantee not like 'APEX%' and 
> grantee !=  
> >     > > 'CTXSYS'  
> >     > > > and grantee != 'DBSNMP' and grantee != 'DMSYS' and grantee != 
> 'EXFSYS'  
> >     > > and  
> >     > > > grantee != 'MDSYS' order by grantee;"
> >     > > >                 },
> >     > > >                 "msg": [

Re: [ansible-project] Re: KEY: VALUE iterations

2020-02-14 Thread Anand Solomon
Thanks Rache,
This didn't solve the issue. I need to read the content in the "msg" in 
"results" section 



On Friday, February 14, 2020 at 7:52:31 AM UTC-5, Stefan Hornburg (Racke) 
wrote:
>
> On 2/14/20 1:31 PM, Anand Solomon wrote: 
> > Thanks Vlado, 
> > I am new to Ansible. I tried "query_result.results' etc. But no luck. 
> Will really appreciate and also will learn at the 
> > same time if you can help me crack the mystery. 
> > 
> > Thanks for all your help. 
>
> Amand, you need to use the loop in the debug task as well: 
>
> - name: Display the query results 
>   debug: 
> msg: "{{query_result.msg}} 
>   loop: "{{ scripts|dict2items }}" 
>
> Regards 
> Racke 
>
> > 
> > On Thursday, February 13, 2020 at 5:08:12 PM UTC-5, Vladimir Botka 
> wrote: 
> > 
> > On Thu, 13 Feb 2020 13:33:32 -0800 (PST) 
> > Anand Solomon > wrote: 
> > 
> > > - name: Display the query results 
> > >   debug: 
> > > msg: "{{query_result.msg}} 
> > > 
> > > I get the below 
> > >   "msg": "All items completed" 
> > > 
> > > I couldn't get the below, what ever I put in my debug statement. 
> Is there 
> > > is something I should do in order to get the below messages ? 
> Thanks again 
> > > for your help. 
> > > 
> > > "msg": [ 
> > > [ 
> > > "Revoke EXECUTE on UTL_FILE from TESTDBA;" 
> > > ], 
> > > [ 
> > > "Revoke EXECUTE on UTL_FILE from TSTSCH;" 
> > > ] 
> > > ] 
> > 
> > What you should do in order to get the above messages? Solve the 
> mystery and 
> > find out how you get the "msg" below. Perhaps? 
> > 
> > 
> > > > > TASK [Display the query results] 
> > > > >   
> > > > 
> 
>  
>
> > > >   
> > > > > ok: "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com <
> http://tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com>] => { 
> > > > > "msg": { 
> > > > > "ansible_loop_var": "item", 
> > > > > "changed": false, 
> > > > > "failed": false, 
> > > > > "invocation": { 
> > > > > "module_args": { 
> > > > > "host": 
> > > > > "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com <
> http://tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com>", 
> > > > > "hostname": 
> > > > > "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com <
> http://tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com>", 
> > > > > "mode": "normal", 
> > > > > "password":   
> > > > "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",   
> > > > > "port": "1521", 
> > > > > "script": null, 
> > > > > "service_name": "tstdb", 
> > > > > "sql": "select 'Revoke ' || privilege 
> || ' on 
> > > > > UTL_FILE from ' || grantee || ';' from dba_tab_privs where 
> > > > > table_name='UTL_FILE' and grantee not like 'APEX%' and grantee 
> !=   
> > > > 'CTXSYS'   
> > > > > and grantee != 'DBSNMP'  order by grantee;", 
> > > > > "user": "SYSDBA", 
> > > > > "username": "SYSDBA" 
> > > > > } 
> > > > > }, 
> > > > > "item": { 
> > > > > "key": "Script1", 
> > > > > "value": "select 'Revoke ' || privilege || 
> ' on 
> > > > > UTL_FILE from ' || grantee || ';' from dba_tab_privs where 
> > > > > table_name='UTL_FILE' and grantee not like 'APEX%' and grantee 
> !=   
> > > > 'CTXSYS'   
> > > > > and grantee != 'DBSNMP' and grantee != 'DMSYS' and grantee != 
> 'EXFSYS'   
> > > > and   
> > > > > grantee != 'MDSYS' order by grantee;" 
> > > > > }, 
> > > > > "msg": [ 
> > > > > [ 
> > > > > "Revoke EXECUTE on UTL_FILE from 
> TESTDBA;" 
> > > > > ], 
> > > > > [ 
> > > > > "Revoke EXECUTE on UTL_FILE from 
> TSTSCH;" 
> > > > > ] 
> > > > > ] 
> > > > > } 
> > > > > ] 
> > > > > } 
> > > > > } 
> > > > > --- 
> > > > > I just want to get  extract the below value and pass it on to 
> my Jinja 
> > > > > template. 
> > > > > 
> > > > >   [ 
> > > > > "Revoke EXECUTE on UTL_FILE from 
> TESTDBA;" 
> 

Re: [ansible-project] Re: KEY: VALUE iterations

2020-02-14 Thread Stefan Hornburg (Racke)
On 2/14/20 1:31 PM, Anand Solomon wrote:
> Thanks Vlado,
> I am new to Ansible. I tried "query_result.results' etc. But no luck. Will 
> really appreciate and also will learn at the
> same time if you can help me crack the mystery.
> 
> Thanks for all your help.

Amand, you need to use the loop in the debug task as well:

- name: Display the query results
  debug:
msg: "{{query_result.msg}}
  loop: "{{ scripts|dict2items }}"

Regards
Racke

> 
> On Thursday, February 13, 2020 at 5:08:12 PM UTC-5, Vladimir Botka wrote:
> 
> On Thu, 13 Feb 2020 13:33:32 -0800 (PST)
> Anand Solomon > wrote:
> 
> > - name: Display the query results
> >       debug:
> >         msg: "{{query_result.msg}}
> >
> > I get the below
> >   "msg": "All items completed"
> >
> > I couldn't get the below, what ever I put in my debug statement. Is 
> there
> > is something I should do in order to get the below messages ? Thanks 
> again
> > for your help.
> >
> >                 "msg": [
> >                     [
> >                         "Revoke EXECUTE on UTL_FILE from TESTDBA;"
> >                     ],
> >                     [
> >                         "Revoke EXECUTE on UTL_FILE from TSTSCH;"
> >                     ]
> >                 ]
> 
> What you should do in order to get the above messages? Solve the mystery 
> and
> find out how you get the "msg" below. Perhaps?
> 
> 
> > > > TASK [Display the query results]
> > > >  
> > > 
> 
> > >  
> > > > ok: "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com 
> ] => {
> > > >     "msg": {
> > > >                 "ansible_loop_var": "item",
> > > >                 "changed": false,
> > > >                 "failed": false,
> > > >                 "invocation": {
> > > >                     "module_args": {
> > > >                         "host":
> > > > "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com 
> ",
> > > >                         "hostname":
> > > > "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com 
> ",
> > > >                         "mode": "normal",
> > > >                         "password":  
> > > "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",  
> > > >                         "port": "1521",
> > > >                         "script": null,
> > > >                         "service_name": "tstdb",
> > > >                         "sql": "select 'Revoke ' || privilege || ' 
> on
> > > > UTL_FILE from ' || grantee || ';' from dba_tab_privs where
> > > > table_name='UTL_FILE' and grantee not like 'APEX%' and grantee !=  
> > > 'CTXSYS'  
> > > > and grantee != 'DBSNMP'  order by grantee;",
> > > >                         "user": "SYSDBA",
> > > >                         "username": "SYSDBA"
> > > >                     }
> > > >                 },
> > > >                 "item": {
> > > >                     "key": "Script1",
> > > >                     "value": "select 'Revoke ' || privilege || ' on
> > > > UTL_FILE from ' || grantee || ';' from dba_tab_privs where
> > > > table_name='UTL_FILE' and grantee not like 'APEX%' and grantee !=  
> > > 'CTXSYS'  
> > > > and grantee != 'DBSNMP' and grantee != 'DMSYS' and grantee != 
> 'EXFSYS'  
> > > and  
> > > > grantee != 'MDSYS' order by grantee;"
> > > >                 },
> > > >                 "msg": [
> > > >                     [
> > > >                         "Revoke EXECUTE on UTL_FILE from TESTDBA;"
> > > >                     ],
> > > >                     [
> > > >                         "Revoke EXECUTE on UTL_FILE from TSTSCH;"
> > > >                     ]
> > > >                 ]
> > > >             }
> > > >         ]
> > > >     }
> > > > }
> > > > ---
> > > > I just want to get  extract the below value and pass it on to my 
> Jinja
> > > > template.
> > > >
> > > >                   [
> > > >                         "Revoke EXECUTE on UTL_FILE from TESTDBA;"
> > > >                     ],
> > > >                     [
> > > >                         "Revoke EXECUTE on UTL_FILE from TSTSCH;"
> > > >                     ]
> > > >
> > > > Here is my Jinja template
> > > >
> > > >     - name: Generate Revoke Statement
> > > >       copy:
> > > >         dest:  
> > > /home/ansible/Playbooks/{{sname}}/sql/{{item.key}}_revoke.sql  
> > > >         content: |
> > > >          spool 
> 

Re: [ansible-project] Re: KEY: VALUE iterations

2020-02-14 Thread Anand Solomon
Thanks Vlado,
I am new to Ansible. I tried "query_result.results' etc. But no luck. Will 
really appreciate and also will learn at the same time if you can help me 
crack the mystery.

Thanks for all your help.

On Thursday, February 13, 2020 at 5:08:12 PM UTC-5, Vladimir Botka wrote:
>
> On Thu, 13 Feb 2020 13:33:32 -0800 (PST) 
> Anand Solomon > wrote: 
>
> > - name: Display the query results 
> >   debug: 
> > msg: "{{query_result.msg}} 
> > 
> > I get the below 
> >   "msg": "All items completed" 
> > 
> > I couldn't get the below, what ever I put in my debug statement. Is 
> there 
> > is something I should do in order to get the below messages ? Thanks 
> again 
> > for your help. 
> > 
> > "msg": [ 
> > [ 
> > "Revoke EXECUTE on UTL_FILE from TESTDBA;" 
> > ], 
> > [ 
> > "Revoke EXECUTE on UTL_FILE from TSTSCH;" 
> > ] 
> > ] 
>
> What you should do in order to get the above messages? Solve the mystery 
> and 
> find out how you get the "msg" below. Perhaps? 
>
>
> > > > TASK [Display the query results] 
> > > >   
> > > 
> 
>  
>
> > >   
> > > > ok: "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com] => { 
> > > > "msg": { 
> > > > "ansible_loop_var": "item", 
> > > > "changed": false, 
> > > > "failed": false, 
> > > > "invocation": { 
> > > > "module_args": { 
> > > > "host": 
> > > > "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com", 
> > > > "hostname": 
> > > > "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com", 
> > > > "mode": "normal", 
> > > > "password":   
> > > "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",   
> > > > "port": "1521", 
> > > > "script": null, 
> > > > "service_name": "tstdb", 
> > > > "sql": "select 'Revoke ' || privilege || ' 
> on 
> > > > UTL_FILE from ' || grantee || ';' from dba_tab_privs where 
> > > > table_name='UTL_FILE' and grantee not like 'APEX%' and grantee !=   
> > > 'CTXSYS'   
> > > > and grantee != 'DBSNMP'  order by grantee;", 
> > > > "user": "SYSDBA", 
> > > > "username": "SYSDBA" 
> > > > } 
> > > > }, 
> > > > "item": { 
> > > > "key": "Script1", 
> > > > "value": "select 'Revoke ' || privilege || ' on 
> > > > UTL_FILE from ' || grantee || ';' from dba_tab_privs where 
> > > > table_name='UTL_FILE' and grantee not like 'APEX%' and grantee !=   
> > > 'CTXSYS'   
> > > > and grantee != 'DBSNMP' and grantee != 'DMSYS' and grantee != 
> 'EXFSYS'   
> > > and   
> > > > grantee != 'MDSYS' order by grantee;" 
> > > > }, 
> > > > "msg": [ 
> > > > [ 
> > > > "Revoke EXECUTE on UTL_FILE from TESTDBA;" 
> > > > ], 
> > > > [ 
> > > > "Revoke EXECUTE on UTL_FILE from TSTSCH;" 
> > > > ] 
> > > > ] 
> > > > } 
> > > > ] 
> > > > } 
> > > > } 
> > > > --- 
> > > > I just want to get  extract the below value and pass it on to my 
> Jinja 
> > > > template. 
> > > > 
> > > >   [ 
> > > > "Revoke EXECUTE on UTL_FILE from TESTDBA;" 
> > > > ], 
> > > > [ 
> > > > "Revoke EXECUTE on UTL_FILE from TSTSCH;" 
> > > > ] 
> > > > 
> > > > Here is my Jinja template 
> > > > 
> > > > - name: Generate Revoke Statement 
> > > >   copy: 
> > > > dest:   
> > > /home/ansible/Playbooks/{{sname}}/sql/{{item.key}}_revoke.sql   
> > > > content: | 
> > > >  spool 
> /home/ansible/Playbooks/{{sname}}/log/{{item.key}}.log 
> > > >  {% for line in query_result  | flatten %} 
> > > >  {{ line }} 
> > > >  {% endfor %} 
> > > >  spool off; 
> > > >   delegate_to: localhost 
> > > >   connection: local 
> > > >   loop: "{{ scripts|dict2items }}"   
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/16c46f66-32bb-4719-97a6-b63fb4883f17%40googlegroups.com.


Re: [ansible-project] Re: KEY: VALUE iterations

2020-02-13 Thread Vladimir Botka
On Thu, 13 Feb 2020 13:33:32 -0800 (PST)
Anand Solomon  wrote:

> - name: Display the query results
>   debug:
> msg: "{{query_result.msg}}
> 
> I get the below
>   "msg": "All items completed"
> 
> I couldn't get the below, what ever I put in my debug statement. Is there 
> is something I should do in order to get the below messages ? Thanks again 
> for your help.
> 
> "msg": [
> [
> "Revoke EXECUTE on UTL_FILE from TESTDBA;"
> ],
> [
> "Revoke EXECUTE on UTL_FILE from TSTSCH;"
> ]
> ]

What you should do in order to get the above messages? Solve the mystery and
find out how you get the "msg" below. Perhaps?


> > > TASK [Display the query results] 
> > >   
> > 
> >  
> >  
> > > ok: "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com] => { 
> > > "msg": { 
> > > "ansible_loop_var": "item", 
> > > "changed": false, 
> > > "failed": false, 
> > > "invocation": { 
> > > "module_args": { 
> > > "host": 
> > > "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com", 
> > > "hostname": 
> > > "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com", 
> > > "mode": "normal", 
> > > "password":   
> > "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",   
> > > "port": "1521", 
> > > "script": null, 
> > > "service_name": "tstdb", 
> > > "sql": "select 'Revoke ' || privilege || ' on 
> > > UTL_FILE from ' || grantee || ';' from dba_tab_privs where 
> > > table_name='UTL_FILE' and grantee not like 'APEX%' and grantee !=   
> > 'CTXSYS'   
> > > and grantee != 'DBSNMP'  order by grantee;", 
> > > "user": "SYSDBA", 
> > > "username": "SYSDBA" 
> > > } 
> > > }, 
> > > "item": { 
> > > "key": "Script1", 
> > > "value": "select 'Revoke ' || privilege || ' on 
> > > UTL_FILE from ' || grantee || ';' from dba_tab_privs where 
> > > table_name='UTL_FILE' and grantee not like 'APEX%' and grantee !=   
> > 'CTXSYS'   
> > > and grantee != 'DBSNMP' and grantee != 'DMSYS' and grantee != 'EXFSYS'   
> > and   
> > > grantee != 'MDSYS' order by grantee;" 
> > > }, 
> > > "msg": [ 
> > > [ 
> > > "Revoke EXECUTE on UTL_FILE from TESTDBA;" 
> > > ], 
> > > [ 
> > > "Revoke EXECUTE on UTL_FILE from TSTSCH;" 
> > > ] 
> > > ] 
> > > } 
> > > ] 
> > > } 
> > > } 
> > > --- 
> > > I just want to get  extract the below value and pass it on to my Jinja 
> > > template. 
> > > 
> > >   [ 
> > > "Revoke EXECUTE on UTL_FILE from TESTDBA;" 
> > > ], 
> > > [ 
> > > "Revoke EXECUTE on UTL_FILE from TSTSCH;" 
> > > ] 
> > > 
> > > Here is my Jinja template 
> > > 
> > > - name: Generate Revoke Statement 
> > >   copy: 
> > > dest:   
> > /home/ansible/Playbooks/{{sname}}/sql/{{item.key}}_revoke.sql   
> > > content: | 
> > >  spool /home/ansible/Playbooks/{{sname}}/log/{{item.key}}.log 
> > >  {% for line in query_result  | flatten %} 
> > >  {{ line }} 
> > >  {% endfor %} 
> > >  spool off; 
> > >   delegate_to: localhost 
> > >   connection: local 
> > >   loop: "{{ scripts|dict2items }}"   

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200213230755.57d4000d%40gmail.com.


pgpCSLkEFqvau.pgp
Description: OpenPGP digital signature


Re: [ansible-project] Re: KEY: VALUE iterations

2020-02-13 Thread Anand Solomon
Thank you so very much Vlado

 if I say   

- name: Display the query results
  debug:
msg: "{{query_result.msg}}

I get the below
  "msg": "All items completed"


I couldn't get the below, what ever I put in my debug statement. Is there 
is something I should do in order to get the below messages ? Thanks again 
for your help.

"msg": [
[
"Revoke EXECUTE on UTL_FILE from TESTDBA;"
],
[
"Revoke EXECUTE on UTL_FILE from TSTSCH;"
]
]


On Thursday, February 13, 2020 at 4:28:06 PM UTC-5, Vladimir Botka wrote:
>
>
> There is nothing to parse. The result is a dictionary with the attributes 
> listed in "msg". Simply access the attributes of the dictionary to "take 
> the 
> values". 
>
> On Thu, 13 Feb 2020 11:52:30 -0800 (PST) 
> Anand Solomon > wrote: 
>
> > I want to parse the json output and take the values 
> > Here is the json debug output from the playbook I run, 
> > 
> > TASK [Display the query results] 
> > 
> 
>  
>
> > ok: "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com] => { 
> > "msg": { 
> > "ansible_loop_var": "item", 
> > "changed": false, 
> > "failed": false, 
> > "invocation": { 
> > "module_args": { 
> > "host": 
> > "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com", 
> > "hostname": 
> > "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com", 
> > "mode": "normal", 
> > "password": 
> "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
> > "port": "1521", 
> > "script": null, 
> > "service_name": "tstdb", 
> > "sql": "select 'Revoke ' || privilege || ' on 
> > UTL_FILE from ' || grantee || ';' from dba_tab_privs where 
> > table_name='UTL_FILE' and grantee not like 'APEX%' and grantee != 
> 'CTXSYS' 
> > and grantee != 'DBSNMP'  order by grantee;", 
> > "user": "SYSDBA", 
> > "username": "SYSDBA" 
> > } 
> > }, 
> > "item": { 
> > "key": "Script1", 
> > "value": "select 'Revoke ' || privilege || ' on 
> > UTL_FILE from ' || grantee || ';' from dba_tab_privs where 
> > table_name='UTL_FILE' and grantee not like 'APEX%' and grantee != 
> 'CTXSYS' 
> > and grantee != 'DBSNMP' and grantee != 'DMSYS' and grantee != 'EXFSYS' 
> and 
> > grantee != 'MDSYS' order by grantee;" 
> > }, 
> > "msg": [ 
> > [ 
> > "Revoke EXECUTE on UTL_FILE from TESTDBA;" 
> > ], 
> > [ 
> > "Revoke EXECUTE on UTL_FILE from TSTSCH;" 
> > ] 
> > ] 
> > } 
> > ] 
> > } 
> > } 
> > --- 
> > I just want to get  extract the below value and pass it on to my Jinja 
> > template. 
> > 
> >   [ 
> > "Revoke EXECUTE on UTL_FILE from TESTDBA;" 
> > ], 
> > [ 
> > "Revoke EXECUTE on UTL_FILE from TSTSCH;" 
> > ] 
> > 
> > Here is my Jinja template 
> > 
> > - name: Generate Revoke Statement 
> >   copy: 
> > dest: 
> /home/ansible/Playbooks/{{sname}}/sql/{{item.key}}_revoke.sql 
> > content: | 
> >  spool /home/ansible/Playbooks/{{sname}}/log/{{item.key}}.log 
> >  {% for line in query_result  | flatten %} 
> >  {{ line }} 
> >  {% endfor %} 
> >  spool off; 
> >   delegate_to: localhost 
> >   connection: local 
> >   loop: "{{ scripts|dict2items }}" 
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b3c2dd89-b95e-4fe1-ba5e-1e5c083b9f51%40googlegroups.com.


Re: [ansible-project] Re: KEY: VALUE iterations

2020-02-13 Thread Vladimir Botka

There is nothing to parse. The result is a dictionary with the attributes
listed in "msg". Simply access the attributes of the dictionary to "take the
values".

On Thu, 13 Feb 2020 11:52:30 -0800 (PST)
Anand Solomon  wrote:

> I want to parse the json output and take the values 
> Here is the json debug output from the playbook I run, 
> 
> TASK [Display the query results] 
> 
> ok: "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com] => {
> "msg": {
> "ansible_loop_var": "item",
> "changed": false,
> "failed": false,
> "invocation": {
> "module_args": {
> "host": 
> "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com",
> "hostname": 
> "tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com",
> "mode": "normal",
> "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
> "port": "1521",
> "script": null,
> "service_name": "tstdb",
> "sql": "select 'Revoke ' || privilege || ' on 
> UTL_FILE from ' || grantee || ';' from dba_tab_privs where 
> table_name='UTL_FILE' and grantee not like 'APEX%' and grantee != 'CTXSYS' 
> and grantee != 'DBSNMP'  order by grantee;",
> "user": "SYSDBA",
> "username": "SYSDBA"
> }
> },
> "item": {
> "key": "Script1",
> "value": "select 'Revoke ' || privilege || ' on 
> UTL_FILE from ' || grantee || ';' from dba_tab_privs where 
> table_name='UTL_FILE' and grantee not like 'APEX%' and grantee != 'CTXSYS' 
> and grantee != 'DBSNMP' and grantee != 'DMSYS' and grantee != 'EXFSYS' and 
> grantee != 'MDSYS' order by grantee;"
> },
> "msg": [
> [
> "Revoke EXECUTE on UTL_FILE from TESTDBA;"
> ],
> [
> "Revoke EXECUTE on UTL_FILE from TSTSCH;"
> ]
> ]
> }
> ]
> }
> }
> ---
> I just want to get  extract the below value and pass it on to my Jinja 
> template.
> 
>   [
> "Revoke EXECUTE on UTL_FILE from TESTDBA;"
> ],
> [
> "Revoke EXECUTE on UTL_FILE from TSTSCH;"
> ]
> 
> Here is my Jinja template
> 
> - name: Generate Revoke Statement
>   copy:
> dest: /home/ansible/Playbooks/{{sname}}/sql/{{item.key}}_revoke.sql
> content: |
>  spool /home/ansible/Playbooks/{{sname}}/log/{{item.key}}.log
>  {% for line in query_result  | flatten %}
>  {{ line }}
>  {% endfor %}
>  spool off;
>   delegate_to: localhost
>   connection: local
>   loop: "{{ scripts|dict2items }}"

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200213222748.101aa2c2%40gmail.com.


pgpnT98n5utYH.pgp
Description: OpenPGP digital signature