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> <
> http://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 <
> http://tstdb.fdst3sb9ngoi.us-east-1.rds.amazonaws.com>>", 
> > > > > > "hostname&

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", 
> > > > > 

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 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.


[ansible-project] Re: KEY: VALUE iterations

2020-02-13 Thread Anand Solomon
Thanks again Vlado

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 }}"






On Wednesday, February 12, 2020 at 9:02:20 PM UTC-5, Anand Solomon wrote:
>
> Hi,
> What is the best way to loop the below KEY : VALUE ?
>
>
> *main.yml*
>  
>  var_files:
>  - /home/ansible/sqlvar.yml
>  
>  - name: Script 
>  oracle_sql:
>  sql: {{Value}}
>  environment: "{{oracle_env}}"
>  register: query_result
>  connection: local
>  
>  - name: Runs statements 
>  command: $ORACLE_HOME/sqlplus -s {{user}}/{{password}}@{{sname}} 
> @/home/ansible/Playbooks/{{sname}}/sql/{{Key}}_revoke.sql
>  environment: "{{oracle_env}}"
>  register: sqloutput
>  connection: local
>  
>  --
>  sqlvar.yml
>  
>  Key: Value
>  Script1: select username from dba_users;
>  Script2: select file_name from dba_data_files;
>  Script3: select name from v$profile;
>  Script4: select username from dba_profile;
>
>

-- 
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/c697b56c-df8a-4c1e-93cd-c582c0706385%40googlegroups.com.


Re: [ansible-project] KEY: VALUE iterations

2020-02-13 Thread Anand Solomon
I want to parse the json output and take the values 

Here is the json 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' and grantee != 'DMSYS' and grantee != 'EXFSYS' and 
> grantee not like 'FLOWS%' and grantee != 'MDSYS' and grantee != 'OLAPSYS' 
> and grantee != 'ORACLE' and grantee != 'ORACLE_OCM' and grantee != 
> 'ORDPLUGINS' and grantee != 'ORDSYS' and grantee != 'SQLTXPLAIN' and 
> grantee != 'SYSMAN' and grantee != 'SYSTEM' and grantor != 'SYS' order by 
> grantee;",
> "user": "SYSDBA",
> "username": "SYSDBA"
> }
> },
> "item": {
> "key": "RDS_Guardium_Compliance_24",
> "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 not like 'FLOWS%' and grantee != 'MDSYS' and grantee != 'OLAPSYS' 
> and grantee != 'ORACLE' and grantee != 'ORACLE_OCM' and grantee != 
> 'ORDPLUGINS' and grantee != 'ORDSYS' and grantee != 'SQLTXPLAIN' and 
> grantee != 'SYSMAN' and grantee != 'SYSTEM' and grantor != 'SYS' order by 
> grantee;"
> },
> "msg": [
> [
> "Revoke EXECUTE on UTL_FILE from TESTDBA;"
> ],
> [
> "Revoke EXECUTE on UTL_FILE from TSTSCH;"
> ]
> ]
> }
> ]
> }
> }

---
I just want to get the one extract the below value and pass it on.

  [
"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.results | flatten %}
 {{ line }}
 {% endfor %}
 spool off;
  delegate_to: localhost
  connection: local
  loop: "{{ scripts|dict2items }}"






---
On Thursday, February 13, 2020 at 12:34:31 PM UTC-5, Vladimir Botka wrote:
>
> On Thu, 13 Feb 2020 09:25:16 -0800 (PST) 
> Anand Solomon > wrote: 
>
> > Here is what I get as the debug out when I run my loop. I need to parse 
> the 
> > JSON and get the hightlighted value to my Jinja template. 
>
>   I don't see anything highlighted. What am I missing? 
>
>
> > "msg": { 
> > "changed": false, 
> > "msg": "All items completed", 
> > "results": [ 
> > { 
> > "ansible_facts": { 
> > "discovered_interpreter_python": "/usr/bin/python" 
> > }, 
> >   

Re: [ansible-project] KEY: VALUE iterations

2020-02-13 Thread Anand Solomon
Sorry about that.

Here is what I get as the debug out when I run my loop. I need to parse the 
JSON and get the hightlighted value to my Jinja template.
"msg": {
"changed": false,
"msg": "All items completed",
"results": [
{
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"ansible_loop_var": "item",
"changed": false,
"failed": false,
"invocation": {
"module_args": {
"host": 
"tstdb.cds56fb9ngoi.us-east-1.rds.amazonaws.com",
"hostname": 
"tstdb.cdst2nb9ngoi.us-east-1.rds.amazonaws.com",
"mode": "normal",
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"port": "1521",
"script": null,
"service_name": "tstdb",
"sql": "select name from v$database;",
"user": "DBUSER",
"username": "DBUSER"
}
},
"item": {
"key": "Script1",
"value": "select name from v$database;"
},
"msg": [
[
"LCKTSTDB"
]
]
}

On Thursday, February 13, 2020 at 12:17:18 PM UTC-5, Vladimir Botka wrote:
>
> On Thu, 13 Feb 2020 08:32:08 -0800 (PST) 
> Anand Solomon > wrote: 
>
> > sql works fine actually. No issues with that. I am getting the query 
> > results. Here is the result 
> > 
> > "msg": { 
> > "changed": false, 
> > "msg": "All items completed", 
> > "results": [ 
> > { 
> > "ansible_facts": { 
> > "discovered_interpreter_python": "/usr/bin/python" 
> > }, 
> > "ansible_loop_var": "item", 
> > "changed": false, 
> > "failed": false, 
> > "invocation": { 
> > "module_args": { 
> > "host": 
> > "tstdb.cdst2lsongoi.us-east-1.rds.amazonaws.com", 
> > "hostname": 
> > "tstdb.cdst2lsongoi.us-east-1.rds.amazonaws.com", 
> > "mode": "normal", 
> > "password": 
> "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
> > "port": "1521", 
> > "script": null, 
> > "service_name": "tstdb", 
> > "sql": "select name from v$database;", 
> > "user": "DBUSER", 
> > "username": "DBAUSER" 
> > } 
> > }, 
> > "item": { 
> > "key": "Script1", 
> > "value": "select name from v$database;" 
> > }, 
> > "msg": [ 
> > [ 
> > "TSTDB" 
> > ] 
> > ] 
> > } 
> > 
> > [...] 
> > How do I capture only the query result which is just the username ? 
>
> > > 
> > >   - name: Script will revoke 
> > > oracle_sql: 
> > >   username: "{{ user }}" 
> > >   password: "{{ password }}" 
> > >   service_name: "{{ sname }}" 
> > >   port: "{{ prt }}" 
> > >   sqlId: "{{ hostnme }}" 
> > >   sql: "{{ item.value }}' 
> > > loop: "{{ scripts|dict2items }}" 
>
> I don't understand what "the query result which is just the username" 
> means. 
> What result do you expect? 
>

-- 
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/8166c484-d1d9-4b16-b282-6f511f600c65%40googlegroups.com.


Re: [ansible-project] KEY: VALUE iterations

2020-02-13 Thread Anand Solomon
Hello Vlado,
sql works fine actually. No issues with that. I am getting the query 
results. Here is the result

"msg": {
"changed": false,
"msg": "All items completed",
"results": [
{
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"ansible_loop_var": "item",
"changed": false,
"failed": false,
"invocation": {
"module_args": {
"host": 
"tstdb.cdst2lsongoi.us-east-1.rds.amazonaws.com",
"hostname": 
"tstdb.cdst2lsongoi.us-east-1.rds.amazonaws.com",
"mode": "normal",
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"port": "1521",
"script": null,
"service_name": "tstdb",
"sql": "select name from v$database;",
"user": "DBUSER",
"username": "DBAUSER"
}
},
"item": {
"key": "Script1",
"value": "select name from v$database;"
},
"msg": [
[
"TSTDB"
]
]
}


I have jinja template embedded in my play book, it captures the whole json 

Thank you so much for your help !!!

- Anand


- 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.msg |flatten %}
 {{ line }}
 {% endfor %}
 spool off;
  delegate_to: localhost
  connection: local
  loop: "{{ scripts|dict2items }}"


How do I capture only the query result which is just the username ?



On Thursday, February 13, 2020 at 10:24:36 AM UTC-5, Vladimir Botka wrote:
>
> On Thu, 13 Feb 2020 05:57:39 -0800 (PST) 
> Anand Solomon > wrote: 
>
> > - include_vars: 
> > file: /home/ansible/Playbooks/Compliance1.yml 
> > name: scripts 
> > - debug: 
> > msg: "{{ sqlqry }}: {{ sqlid }}" 
> >   vars: 
> > sqlqry: "{{ item.key }}" 
> > sqlid: "{{ item.value }}" 
> >   loop: "{{ scripts|dict2items }}" 
> > [...] 
> > The Complaince1.yml has the below 
> > 
> >  Script1: select username from dba_users; 
> >  Script2: select name from v$profile; 
> > [...] 
> > "msg": "Script1: select username from dba_users;" 
> > "msg": "Script2: select name from v$profile;" 
> > 
> > My problem is, I don't know how to get the key (like "Script1") and 
> value 
> > (like "select username from dba_users;") to another block as 
> > 
> > - name: Script will revoke 
> >   oracle_sql: 
> > username: "{{user}}" 
> > password: "{{password}}" 
> > service_name: "{{sname}}" 
> > port: "{{prt}}" 
> > sqlId: "{{hostnme}}" 
> > sql: "{{sqlqry}}' 
> vars: 
>   sqlqry: "{{ item.key }}" 
>   sqlid: "{{ item.value }}" 
> loop: "{{ scripts|dict2items }}" 
>
> Simply append "vars" and "loop". 
>
> But I think the above task "oracle_sql" won't work because of attribute 
> "sql". The documentation says "sql: The sql you want to execute" but 
> "item.key" is the label of the script. See 
> https://github.com/oravirt/ansible-oracle-modules/blob/master/oracle_sql 
>
> Instead, "item.value" is the SQL you want to execute. Correct syntax is 
> (substitution is not necessary) 
>
>   - name: Script will revoke 
> oracle_sql: 
>   username: "{{ user }}" 
>   password: "{{ password }}" 
>   service_name: "{{ sname }}" 
>   port: "{{ prt }}" 
>   sqlId: "{{ hostnme }}" 
>   sql: "{{ it

Re: [ansible-project] KEY: VALUE iterations

2020-02-13 Thread Anand Solomon
Thanks again Vlado. I am struggling with the basics here...

This is my block

- include_vars:
file: /home/ansible/Playbooks/Compliance1.yml
name: scripts
- debug:
msg: "{{ sqlqry }}: {{ sqlid }}"
  vars:
sqlqry: "{{ item.key }}"
sqlid: "{{ item.value }}"
  loop: "{{ scripts|dict2items }}"


The Complaince1.yml has the below 

 Script1: select username from dba_users;
 Script2: select name from v$profile;

 I am seeing my key & values in my output
TASK [debug] 
*
ok: [tstdb.cdst2ld65goi.us-east-1.rds.amazonaws.com] => (item={'key': 
u'Script1', 'value': u'select username from dba_users;'}) => {
"msg": "Script1: select username from dba_users;"
}
ok: [tstdb.cdst2ld65goi.us-east-1.rds.amazonaws.com] => (item={'key': 
u'Script2', 'value': u'select name from v$profile;'}) => {
"msg": "Script2: select name from v$profile;"

My problem is, I don't know how to get the key (like "Script1") and value 
(like "select username from dba_users;") to another block as 


- name: Script will revoke
  oracle_sql:
username: "{{user}}"
password: "{{password}}"
service_name: "{{sname}}"
port: "{{prt}}"
sqlId: "{{hostnme}}"
sql: "{{sqlqry}}'


- name: Runs the revoke statements and spool out.
  command: $ORACLE_HOME/sqlplus -s {{user}}/{{password}}@{{sname}} 
@/home/ansible/Playbooks/{{sname}}/sql/{{sqlid}}_revoke.sql
  environment: "{{oracle_env}}"
  register: sqloutput
  connection: local



On Wednesday, February 12, 2020 at 11:22:46 PM UTC-5, Vladimir Botka wrote:
>
> On Wed, 12 Feb 2020 19:52:31 -0800 (PST) 
> Anand Solomon > wrote: 
>
> > How will get the value of item.key and item.value to variable 
> > 
> > sqlqry = "{{ item.key }}" 
> > sqlid = "{{ item.value }}" 
>
> Declare the vars in the scope of the task. For example 
>
>- debug: 
> msg: "{{ sqlqry }}: {{ sqlid }}" 
>   vars: 
> sqlqry: "{{ item.key }}" 
> sqlid: "{{ item.value }}" 
>   loop: "{{ scripts|dict2items }}" 
>
> 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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d5c4a522-6bf7-4438-bc78-c6298f6fbc23%40googlegroups.com.


Re: [ansible-project] KEY: VALUE iterations

2020-02-12 Thread Anand Solomon
Basically I want to read sqlvar.yml, pass the "select username from 
dba_users;" to SQLID and "Script1" to SQLQRY  one by one.

On Wednesday, February 12, 2020 at 10:52:32 PM UTC-5, Anand Solomon wrote:
>
> You helped me Vlado. Thanks again. This works very well. 
>
> How will get the value of item.key and item.value to variable
>
> sqlqry = "{{ item.key }}"
> sqlid = "{{ item.value }}"
>
>
> On Wednesday, February 12, 2020 at 10:38:22 PM UTC-5, Vladimir Botka wrote:
>>
>> On Wed, 12 Feb 2020 18:02:20 -0800 (PST) 
>> Anand Solomon  wrote: 
>>
>> > What is the best way to loop the below KEY : VALUE ? 
>> > [...] 
>> >  sqlvar.yml 
>> >  Key: Value 
>> >  Script1: select username from dba_users; 
>> >  Script2: select file_name from dba_data_files; 
>> >  Script3: select name from v$profile; 
>> >  Script4: select username from dba_profile; 
>>
>> Try this 
>>
>> - include_vars: 
>> file: /home/ansible/sqlvar.yml 
>> name: scripts 
>> - debug: 
>> msg: "{{ item.key }}: {{ item.value }}" 
>>   loop: "{{ scripts|dict2items }}" 
>>
>> 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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fdf234ef-3362-4af9-9f8d-e65d2558bc19%40googlegroups.com.


[ansible-project] KEY: VALUE iterations

2020-02-12 Thread Anand Solomon
Hi,
What is the best way to loop the below KEY : VALUE ?


*main.yml*
 
 var_files:
 - /home/ansible/sqlvar.yml
 
 - name: Script 
 oracle_sql:
 sql: {{Value}}
 environment: "{{oracle_env}}"
 register: query_result
 connection: local
 
 - name: Runs statements 
 command: $ORACLE_HOME/sqlplus -s {{user}}/{{password}}@{{sname}} 
@/home/ansible/Playbooks/{{sname}}/sql/{{Key}}_revoke.sql
 environment: "{{oracle_env}}"
 register: sqloutput
 connection: local
 
 --
 sqlvar.yml
 
 Key: Value
 Script1: select username from dba_users;
 Script2: select file_name from dba_data_files;
 Script3: select name from v$profile;
 Script4: select username from dba_profile;

-- 
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/61eb0fae-6370-42ec-bfb4-841dfb244a6d%40googlegroups.com.


Re: [ansible-project] How to get clean output ?

2020-02-12 Thread Anand Solomon
Thank you so much Vlado.

It works fine. 

On Wednesday, February 12, 2020 at 1:49:13 PM UTC-5, Vladimir Botka wrote:
>
> On Wed, 12 Feb 2020 08:51:12 -0800 (PST) 
> Anand Solomon > wrote: 
>
> > - name: Generate Revoke Statement 
> >   local_action: 
> > copy dest= /home/ansible/query.sql 
> > content= {% for line in query_result.msg|flatten %} {{ line }} 
> {% 
> > endfor %} 
> >   connection: local 
> > 
> > I get -->  localhost]: FAILED! => {"changed": false, "msg": "dest is 
> > required"} 
>
> Very probably the problem is the formatting and indentation of the 
> "shorthand 
> syntax". Try this 
>
> - name: Generate Revoke Statement 
>   copy: 
> dest: /home/ansible/query.sql 
> content: | 
>   {% for line in query_result.msg|flatten %} {{ line }} {% endfor 
> %} 
>   delegate_to: localhost 
>   connection: local 
>
> 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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/13321f95-962b-42d3-bb87-eeecb88d3af8%40googlegroups.com.


Re: [ansible-project] How to get clean output ?

2020-02-12 Thread Anand Solomon
Thanks Vlado,
We don't want to maintain separate files.

Here is my 
- name: Generate Revoke Statement
  local_action:
copy dest= /home/ansible/query.sql
content= {% for line in query_result.msg|flatten %} {{ line }} {% 
endfor %}
  connection: local

I get -->  localhost]: FAILED! => {"changed": false, "msg": "dest is 
required"}

Is that something I am missing ?

On Tuesday, February 11, 2020 at 6:06:42 PM UTC-5, Vladimir Botka wrote:
>
> On Tue, 11 Feb 2020 14:59:04 -0800 (PST) 
> Anand Solomon > wrote: 
>
> > Instead of maintaining another template file. Can I embed the content in 
> > the playbook itself ? 
>
> Sure you can. Put it into the "content". For example 
>
> - local_action: 
> copy dest=/scratch/tmp/revoke.sql 
> content="{% for line in query_result.msg|flatten %}{{ line }}{% 
> endfor %}" 
>
> But, why to get rid of the flexibility and modularity? 
>
> 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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2cf96e8b-80a5-43a7-8bcd-7c157854474e%40googlegroups.com.


Re: [ansible-project] How to get clean output ?

2020-02-11 Thread Anand Solomon
Instead of maintaining another template file. Can I embed the content in 
the playbook itself ?

On Tuesday, February 11, 2020 at 5:57:09 PM UTC-5, Anand Solomon wrote:
>
> Thank you so much Vlado. This works fine. 
>
> On Tuesday, February 11, 2020 at 5:40:05 PM UTC-5, Vladimir Botka wrote:
>>
>> On Tue, 11 Feb 2020 14:02:45 -0800 (PST) 
>> Anand Solomon  wrote: 
>>
>> > I need to get this 
>> > Revoke EXECUTE on UTL_FILE from TESTACC1; Revoke EXECUTE on UTL_FILE 
>> from 
>> > TESTACC2; 
>>
>> To keep the element of the list in one line change the template. For 
>> example 
>>
>> $ cat revoke.sql.j2 
>> {% for line in query_result.msg|flatten %}{{ line }}{% endfor %} 
>>
>> 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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7916702f-dad6-4c61-a512-77586d7cc1b6%40googlegroups.com.


Re: [ansible-project] How to get clean output ?

2020-02-11 Thread Anand Solomon
Thank you so much Vlado. This works fine. 

On Tuesday, February 11, 2020 at 5:40:05 PM UTC-5, Vladimir Botka wrote:
>
> On Tue, 11 Feb 2020 14:02:45 -0800 (PST) 
> Anand Solomon > wrote: 
>
> > I need to get this 
> > Revoke EXECUTE on UTL_FILE from TESTACC1; Revoke EXECUTE on UTL_FILE 
> from 
> > TESTACC2; 
>
> To keep the element of the list in one line change the template. For 
> example 
>
> $ cat revoke.sql.j2 
> {% for line in query_result.msg|flatten %}{{ line }}{% endfor %} 
>
> 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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/507aba02-4db6-4a55-abba-a1b358cb6d22%40googlegroups.com.


Re: [ansible-project] How to get clean output ?

2020-02-11 Thread Anand Solomon
Thanks Hugo for helping me. Basically I am running a sql command that runs 
a sql query which gives the below results. (this is a debug out)

"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(' ') }}
>
> Hugo G. 
>
>  
>
> If I do 
> - local_action:
> copy content={{query_result.msg}}
> dest=/home/ansible/Playbooks/{{sname}}/sql/revoke.sql
>
> I am getting 
> [["Revoke EXECUTE on UTL_FILE from TESTACC1;"], ["Revoke EXECUTE on 
> UTL_FILE from TESTACC2;"]]
>
> I need to get this
> Revoke EXECUTE on UTL_FILE from TESTACC1; Revoke EXECUTE on UTL_FILE from 
> TESTACC2;
>
> -- 
> 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...@googlegroups.com .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/2a69d90d-3ea8-4615-8f63-ace11f83c622%40googlegroups.com
>  
> 
> .
>
>

-- 
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/e42fb674-799a-4f7d-bda2-b7c4905eb8d1%40googlegroups.com.


[ansible-project] How to get clean output ?

2020-02-11 Thread Anand Solomon
Hi,
How will I get only the sql statement from the json output ? I am 
registering this as " register: query_result"

Here is my json output



"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;"
]
]
}
}



If I do 
- local_action:
copy content={{query_result.msg}}
dest=/home/ansible/Playbooks/{{sname}}/sql/revoke.sql

I am getting 
[["Revoke EXECUTE on UTL_FILE from TESTACC1;"], ["Revoke EXECUTE on 
UTL_FILE from TESTACC2;"]]

I need to get this
Revoke EXECUTE on UTL_FILE from TESTACC1; Revoke EXECUTE on UTL_FILE from 
TESTACC2;

-- 
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/2a69d90d-3ea8-4615-8f63-ace11f83c622%40googlegroups.com.


[ansible-project] Running Playbooks against RDS

2020-02-06 Thread Anand Solomon


Hi,
How to even run ansible commands to the RDS Oracle instance ? Is there a 
special parameter I should be passing ? . I have "connection; local" in the 
task. I tried to execute the playbook, I get the below error. Am i missing 
something ?


Here is my playbook variable.

vars:
oracle_home: /home/ansible/instantclient_12_2
user: USERNAME
prt: "1521"
host: "dbname.ymst2nb7ngoi.us-east-1.rds.amazonaws.com"
sname: dbname
oracle_env:
ORACLE_HOME: "{{oracle_home}}"
LD_LIBRARY_PATH: "{{oracle_home}}"
PATH: "{{oracle_home}}"


I am getting the below error

TASK [Gathering Facts] 
***
fatal: [dbname.ymst2nb7ngoi.us-east-1.rds.amazonaws.com]: UNREACHABLE! => 
{"changed": false, "msg": "Failed to connect to the host via ssh: 
ssh_exchange_identification: Connection closed by remote host", 
"unreachable": true}

PLAY RECAP 
***
dbname.ymst2nb7ngoi.us-east-1.rds.amazonaws.com : ok=0 changed=0 
unreachable=1 failed=0 skipped=0 rescued=0 ignored=0

-- 
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/613194b4-53da-475c-9a8b-bce50ab7997d%40googlegroups.com.


[ansible-project] Ansible for RDS

2020-02-06 Thread Anand Solomon


Hi,
How to even run ansible commands to the RDS Oracle instance ? Is there a 
special parameter I should be passing ? . I have "connection; local" in the 
task. I tried to execute the playbook, I get the below error. Am i missing 
something ?


Here is my playbook variable.

vars:
oracle_home: /home/ansible/instantclient_12_2
user: ANTMSYSDBA
prt: "1521"
host: "dbname.ymst2nb7ngoi.us-east-1.rds.amazonaws.com"
sname: lcktstdb
oracle_env:
ORACLE_HOME: "{{oracle_home}}"
LD_LIBRARY_PATH: "{{oracle_home}}"
PATH: "{{oracle_home}}"


I am getting the below error

TASK [Gathering Facts] 
***
fatal: [dbname.ymst2nb7ngoi.us-east-1.rds.amazonaws.com]: UNREACHABLE! => 
{"changed": false, "msg": "Failed to connect to the host via ssh: 
ssh_exchange_identification: Connection closed by remote host", 
"unreachable": true}

PLAY RECAP 
***
dbname.ymst2nb7ngoi.us-east-1.rds.amazonaws.com : ok=0 changed=0 
unreachable=1 failed=0 skipped=0 rescued=0 ignored=0

-- 
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/329a8e50-c98f-4fcb-bae0-5f5526be35f9%40googlegroups.com.


Re: [ansible-project] How to do 3 with_items in the same task ?

2020-02-05 Thread Anand Solomon
Thanks very much.

Basically what I want is , I have a file to store my variable, it has the 
following contents

value1: Something1
value2: Something2

privs1: privs_value1
privs2: privs_value2

In my playbook, I want to iterate this 

value: "{{value1}}"
privilege: "{{privs1}}"

value: "{{value2}}"
privilege: "{{privs2}}"



On Monday, February 3, 2020 at 11:36:40 PM UTC-5, Vladimir Botka wrote:
>
> On Mon, 3 Feb 2020 16:31:21 -0800 (PST) 
> Anand Solomon > wrote: 
>
> > variablefile.yml 
> > 
> > var1: 
> >  - first_value1 
> >  - first_value2 
> > var2: 
> >  - second_value1 
> >  - second_value2 
> > var3: 
> >  - third_value1 
> >  - third_value2 
> > 
> > I want to read the value from the text file and pass that as a variable 
> in 
> > loop. 
>
> The tasks below 
>
> - include_vars: variablefile.yml 
> - debug: 
> var: item 
>   loop: "{{ var1 + var2 + var3 }}" 
>
> give 
>
> "item": "first_value1" 
> "item": "first_value2" 
> "item": "second_value1" 
> "item": "second_value2" 
> "item": "third_value1" 
> "item": "third_value2" 
>
> 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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/443e0ea1-80f5-44be-b01d-198f1f6208e3%40googlegroups.com.


[ansible-project] How to do 3 with_items in the same task ?

2020-02-03 Thread Anand Solomon
Hi,
I am reading 3 different variable from a text file and want to iterate in 3 
different with_items.

variablefile.yml

vars1 :
 - first_value1
 - first_value 2

var2:
 - second_value1
 - second_value2

var3:
 - third_value1
 - third_value2 

I want to read the value from the text file and pass that as a variable in 
loop. 

var_value1: "{{ item }}"
  with_items: "{{ var_value1}}"

var_value2: "{{ item }}"
  with_items: "{{ var_value2}}"

var_value3: "{{ item }}"
  with_items: "{{ var_value3}}"

Not sure how do I do this ?


-- 
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/c0007dd2-0cbb-4de1-8e81-ed8bf3572df4%40googlegroups.com.


Re: [ansible-project] Filter out text from a json object created by an ansible register

2020-01-30 Thread Anand Solomon
Just this made the trick. Thanks very much

roles: "{{item}}"
quiet: false
  environment: "{{oracle_env}}"
  register: user_privs
  with_items : "{{query_result.msg}}"


On Thursday, January 30, 2020 at 3:20:38 PM UTC-5, Anand Solomon wrote:
>
> The result I get from the query_result is something like 
> this [["TESTDBA"], ["TESTDBA2"]]
>
> I want to know how to pass this variable removing the square brackets and 
> the *roles* in the task
>
> On Thursday, January 30, 2020 at 2:52:43 PM UTC-5, Anand Solomon wrote:
>>
>> Hi,
>> Thanks for your help. I may be asking a simple question. I am new to 
>> ansible, so trying to learn. 
>>
>> This is what I need to understand. 
>>
>> 1. Run the below
>> sql: select grantee FROM DBA_SYS_PRIVS where PRIVILEGE='INSERT 
>> ANY TABLE' and grantee not like 'SYS' and grantee != 'WMSYS' and grantee != 
>> 'DBA' and grantee != 'IMP_FULL_DATABASE';
>>   register: query_result
>>
>> The query result will be the users in the DB has DBA_SYS_PRIVS and it can 
>> be more than one.I want to iterate the below task passing the username 
>> dynamically.
>>
>> 2. The query_result have to be iterated in the below
>>
>> - name: This playbook will grant or revoke privilges in the user.
>>   oracle_privs:
>> user: "{{user}}"
>> password: "{{password}}"
>> service_name: "{{sname}}"
>> port: "{{prt}}"
>> hostname: "{{hostname}}"
>> privs:
>>   - INSERT ANY TABLE
>> state: absent
>> *roles: "{{ query_result }}"*
>> quiet: false
>>   environment: "{{oracle_env}}"
>>   register: user_privs
>>   delegate_to: localhost
>>
>> On Thursday, January 30, 2020 at 9:02:02 AM UTC-5, Vladimir Botka wrote:
>>>
>>> On Thu, 30 Jan 2020 05:38:17 -0800 (PST) 
>>> Anand Solomon  wrote: 
>>>
>>> > - name: Display the query results 
>>> >   debug: 
>>> > msg: "{{ query_result }}" 
>>> > 
>>> > and I get [["TESTDBA"]], I want the value to be TESTDBA. 
>>>
>>> The value you're looking for is the first item of the first list 
>>>
>>>  - debug: 
>>>  msg: "{{ query_result.0.0 }}" 
>>>
>>> gives 
>>>
>>> "msg": "TESTDBA" 
>>>
>>> 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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/697bb7ee-8d1c-4068-bde4-758d945b4b21%40googlegroups.com.


Re: [ansible-project] Filter out text from a json object created by an ansible register

2020-01-30 Thread Anand Solomon
The result I get from the query_result is something like this [["TESTDBA"], 
["TESTDBA2"]]

I want to know how to pass this variable removing the square brackets and 
the *roles* in the task

On Thursday, January 30, 2020 at 2:52:43 PM UTC-5, Anand Solomon wrote:
>
> Hi,
> Thanks for your help. I may be asking a simple question. I am new to 
> ansible, so trying to learn. 
>
> This is what I need to understand. 
>
> 1. Run the below
> sql: select grantee FROM DBA_SYS_PRIVS where PRIVILEGE='INSERT ANY 
> TABLE' and grantee not like 'SYS' and grantee != 'WMSYS' and grantee != 
> 'DBA' and grantee != 'IMP_FULL_DATABASE';
>   register: query_result
>
> The query result will be the users in the DB has DBA_SYS_PRIVS and it can 
> be more than one.I want to iterate the below task passing the username 
> dynamically.
>
> 2. The query_result have to be iterated in the below
>
> - name: This playbook will grant or revoke privilges in the user.
>   oracle_privs:
> user: "{{user}}"
> password: "{{password}}"
> service_name: "{{sname}}"
> port: "{{prt}}"
> hostname: "{{hostname}}"
> privs:
>   - INSERT ANY TABLE
> state: absent
> *roles: "{{ query_result }}"*
> quiet: false
>   environment: "{{oracle_env}}"
>       register: user_privs
>   delegate_to: localhost
>
> On Thursday, January 30, 2020 at 9:02:02 AM UTC-5, Vladimir Botka wrote:
>>
>> On Thu, 30 Jan 2020 05:38:17 -0800 (PST) 
>> Anand Solomon  wrote: 
>>
>> > - name: Display the query results 
>> >   debug: 
>> > msg: "{{ query_result }}" 
>> > 
>> > and I get [["TESTDBA"]], I want the value to be TESTDBA. 
>>
>> The value you're looking for is the first item of the first list 
>>
>>  - debug: 
>>  msg: "{{ query_result.0.0 }}" 
>>
>> gives 
>>
>> "msg": "TESTDBA" 
>>
>> 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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/166a09c3-d4ae-4f36-b303-b15c80998a04%40googlegroups.com.


Re: [ansible-project] Filter out text from a json object created by an ansible register

2020-01-30 Thread Anand Solomon
Hi,
Thanks for your help. I may be asking a simple question. I am new to 
ansible, so trying to learn. 

This is what I need to understand. 

1. Run the below
sql: select grantee FROM DBA_SYS_PRIVS where PRIVILEGE='INSERT ANY 
TABLE' and grantee not like 'SYS' and grantee != 'WMSYS' and grantee != 
'DBA' and grantee != 'IMP_FULL_DATABASE';
  register: query_result

The query result will be the users in the DB has DBA_SYS_PRIVS and it can 
be more than one.I want to iterate the below task passing the username 
dynamically.

2. The query_result have to be iterated in the below

- name: This playbook will grant or revoke privilges in the user.
  oracle_privs:
user: "{{user}}"
password: "{{password}}"
service_name: "{{sname}}"
port: "{{prt}}"
hostname: "{{hostname}}"
privs:
  - INSERT ANY TABLE
state: absent
*roles: "{{ query_result }}"*
quiet: false
  environment: "{{oracle_env}}"
  register: user_privs
  delegate_to: localhost

On Thursday, January 30, 2020 at 9:02:02 AM UTC-5, Vladimir Botka wrote:
>
> On Thu, 30 Jan 2020 05:38:17 -0800 (PST) 
> Anand Solomon > wrote: 
>
> > - name: Display the query results 
> >   debug: 
> > msg: "{{ query_result }}" 
> > 
> > and I get [["TESTDBA"]], I want the value to be TESTDBA. 
>
> The value you're looking for is the first item of the first list 
>
>  - debug: 
>  msg: "{{ query_result.0.0 }}" 
>
> gives 
>
> "msg": "TESTDBA" 
>
> 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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7fc50e5e-dc52-41b7-a477-6b67a8efc36b%40googlegroups.com.


Re: [ansible-project] Filter out text from a json object created by an ansible register

2020-01-30 Thread Anand Solomon
Hi,
Thanks for the solution. The question, I am asking may be a simple 
question. I am new to ansible, so trying to learn. 

This is what I need to understand. 

1. Run the below
sql: select grantee FROM DBA_SYS_PRIVS where PRIVILEGE='INSERT ANY 
TABLE' and grantee not like 'SYS' and grantee != 'WMSYS' and grantee != 
'DBA' and grantee != 'IMP_FULL_DATABASE';
  register: query_result

The query result will be the users in the DB has DBA_SYS_PRIVS and it can 
be more than one.I want to iterate the below task passing the username 
dynamically.

2. The query_result have to be iterated in the below

- name: This playbook will grant or revoke privilges in the user.
  oracle_privs:
user: "{{user}}"
password: "{{password}}"
service_name: "{{sname}}"
port: "{{prt}}"
hostname: "{{hostname}}"
privs:
  - INSERT ANY TABLE
state: absent
*roles: "{{ query_result }}"*
quiet: false
  environment: "{{oracle_env}}"
  register: user_privs
  delegate_to: localhost




On Thursday, January 30, 2020 at 9:02:02 AM UTC-5, Vladimir Botka wrote:
>
> On Thu, 30 Jan 2020 05:38:17 -0800 (PST) 
> Anand Solomon > wrote: 
>
> > - name: Display the query results 
> >   debug: 
> > msg: "{{ query_result }}" 
> > 
> > and I get [["TESTDBA"]], I want the value to be TESTDBA. 
>
> The value you're looking for is the first item of the first list 
>
>  - debug: 
>  msg: "{{ query_result.0.0 }}" 
>
> gives 
>
> "msg": "TESTDBA" 
>
> 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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8079ec29-738a-4cdc-8a67-4549fd2b55b8%40googlegroups.com.


Re: [ansible-project] oracle_user module error expecting cx_oracle in DB server

2020-01-30 Thread Anand Solomon
Hi,
Thank you so much. I made this work by commenting with -- instead of #

Thank you for your help.

On Tuesday, January 28, 2020 at 3:38:06 PM UTC-5, Stefan Hornburg (Racke) 
wrote:
>
> On 1/28/20 7:05 PM, Anand Solomon wrote: 
> > It goes soon after the comments 
> > 
> >  /*  
> > 
>  
> ###
>   
>
> >  # Program   : .sql  
> >  # Programmer: x  
> >  # Date  : x  
> >  # Usage :   
> >  # Revisions : x  
> >  # Dependencies  :  
> >  # 1. Sqlplus Binaries.  
> >  #  
> >  # Notes : Script will creates Oracle packages on AWS RDS.  
> >  # Author:   
> >  # Creates change passwords and lock a/c's   
> >  # after the user is done .  
> > 
> ###
>   
>
> >  */  
> > set serveroutput on; 
> > select username from dba_users; 
> > / 
> > .. 
>
> Hello Anand, 
>
> given that this text is in the variable "sql", you can use the following 
> filter: 
>
> {{sql | regex_replace('/\\*([\\s\\S]*)\\*/', '') | trim() }} 
>
> The result would be: 
>
> set serveroutput on; 
> select username from dba_users; 
>
> I found out that you have to use [\\s\\S]* instead of the more 
> straightforward .* as .* doesn't match newlines. 
>
> Regards 
>   Racke 
>
> > 
> > On Tuesday, January 28, 2020 at 12:34:00 PM UTC-5, Stefan Hornburg 
> (Racke) wrote: 
> > 
> > On 1/28/20 6:31 PM, Anand Solomon wrote: 
> > > My sql script will look like 
> > > 
> > > /* 
> > > 
> > 
> ###
>  
>
> > 
> > > # Program   : .sql 
> > > # Programmer: x 
> > > # Date  : x 
> > > # Usage :  
> > > # Revisions : x 
> > > # Dependencies  : 
> > > # 1. Sqlplus Binaries. 
> > > # 
> > > # Notes : Script will creates Oracle packages on AWS RDS. 
> > > # Author:  
> > > # Creates change passwords and lock a/c's  
> > > # after the user is done . 
> > > 
> > > 
> > 
> ###
>  
>
> > 
> > > */ 
> > > 
> > 
> >   
> > 
> > So where is the SQL code? 
> > 
> > Regards 
> >  Racke 
> > 
> > > 
> > > On Tuesday, January 28, 2020 at 12:18:33 PM UTC-5, Stefan Hornburg 
> (Racke) wrote: 
> > > 
> > > On 1/28/20 6:05 PM, Anand Solomon wrote: 
> > > > Hi, 
> > > > I am using oracle_sql module and running a sql script. The 
> sql script contains comments. The playbook fails 
> > because " 
> > > > FAILED! => {"changed": false, "msg": "Something went wrong 
> while executing sql - ORA-00911: invalid 
> > character sql:  
> > > > 
> > > > Is there a way I can keep the comments and execute the sql 
> script ? 
> > > > 
> > > 
> > > I suppose you could filter out the comments. How does your SQL 
> script looks like? 
> > > 
> > > Regards 
> > > Racke 
> > > 
> > > > 
> > > > On Saturday, January 25, 2020 at 5:17:44 PM UTC-5, Dick 
> Visser wrote: 
> > > > 
> > > > Hi 
> > > > 
> > > > Ansible doesn’t have such a module, so I assume this is 
> a 3rd party module? 
> > > > In that case you might have more luck asking the 
> module’s authors for support.  
> > > > 
> > > > 
> > > > On Sat, 25 Jan 2020 at 16:07, Anand Solomon <
> anand@gmail.com > wrote: 
> > > > 
> > > > I am try

[ansible-project] Filter out text from a json object created by an ansible register

2020-01-30 Thread Anand Solomon
Hi,
How do I take only the text from the below from json created by an ansible 
register

I have this 
- name: Display the query results
  debug:
msg: "{{ query_result }}"

and I get [["TESTDBA"]], I want the value to be TESTDBA. Basically I am 
passing this value to another parameter in the same playbook like the below

roles: "{{query_result.msg }}"



-- 
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/c01e16df-1b7f-4a72-a836-3aeda869bdbd%40googlegroups.com.


Re: [ansible-project] Error using state: absent in oracle_grant module

2020-01-29 Thread Anand Solomon
Thanks very much.

On Tuesday, January 28, 2020 at 11:03:26 AM UTC-5, Dick Visser wrote:
>
> Hi Anand
>
> As I told you (twice) before, those oracle modules are NOT part of the 
> ansible distribution. Please get support with the authors of those modules.
> I see that you’ve done that:
>
> https://github.com/oravirt/ansible-oracle-modules/issues
>
> So, please don’t cross post questions regarding those modules to this 
> list. 
>
> Thx !
>
> On Tue, 28 Jan 2020 at 15:23, Anand Solomon  > wrote:
>
>> Hi,
>>
>> I am running the below playbook and I am getting errors when having 
>> 'state: absent', but when I have 'present', it works fine.
>>
>>
>>   tasks:
>>
>> - name: This playbook will create the user.
>>
>>   oracle_grants:
>>
>> user: "{{user}}"
>>
>> password: "{{password}}"
>>
>> service_name: "{{sname}}"
>>
>> port: "{{prt}}"
>>
>> hostname: "{{hostname}}"
>>
>> schema: TSTSCH
>>
>> #grants: "'DBA','create session','create any 
>> table',connect,resource"
>>
>> grants: 'create session'
>>
>> state: absent
>>
>>   environment: "{{oracle_env}}"
>>
>>   register: user_grants
>>
>>   delegate_to: localhost
>>
>>
>>
>>
>> I am getting the below error
>>
>> The full traceback is:
>> Traceback (most recent call last):
>> File 
>> "/home/ansible/.ansible/tmp/ansible-tmp-1580220579.04-228603469188212/AnsiballZ_oracle_grants",
>>  
>> line 102, in
>> _ansiballz_main()
>> File 
>> "/home/ansible/.ansible/tmp/ansible-tmp-1580220579.04-228603469188212/AnsiballZ_oracle_grants",
>>  
>> line 94, in _ansiballz_main
>> invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
>> File 
>> "/home/ansible/.ansible/tmp/ansible-tmp-1580220579.04-228603469188212/AnsiballZ_oracle_grants",
>>  
>> line 40, in invoke_module
>> runpy.run_module(mod_name='ansible.modules.oracle_grants', 
>> init_globals=None, run_name='main', alter_sys=True)
>> File "/usr/lib64/python2.7/runpy.py", line 176, in run_module
>> fname, loader, pkg_name)
>> File "/usr/lib64/python2.7/runpy.py", line 82, in _run_module_code
>> mod_name, mod_fname, mod_loader, pkg_name)
>> File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
>> exec code in run_globals
>> File 
>> "/tmp/ansible_oracle_grants_payload_GK4fah/ansible_oracle_grants_payload.zip/ansible/modules/oracle_grants.py",
>>  
>> line 673, in
>> File 
>> "/tmp/ansible_oracle_grants_payload_GK4fah/ansible_oracle_grants_payload.zip/ansible/modules/oracle_grants.py",
>>  
>> line 646, in main
>> TypeError: remove_grants() takes exactly 7 arguments (6 given)
>>
>> fatal: [22.174.101.30 -> localhost]: FAILED! => {
>> "changed": false,
>> "module_stderr": "Traceback (most recent call last):\n File 
>> "/home/ansible/.ansible/tmp/ansible-tmp-1580220579.04-228603469188212/AnsiballZ_oracle_grants",
>>  
>> line 102, in \n _ansiballz_main()\n File 
>> "/home/ansible/.ansible/tmp/ansible-tmp-1580220579.04-228603469188212/AnsiballZ_oracle_grants",
>>  
>> line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, 
>> ANSIBALLZ_PARAMS)\n File 
>> "/home/ansible/.ansible/tmp/ansible-tmp-1580220579.04-228603469188212/AnsiballZ_oracle_grants",
>>  
>> line 40, in invoke_module\n 
>> runpy.run_module(mod_name='ansible.modules.oracle_grants', 
>> init_globals=None, run_name='main', alter_sys=True)\n File 
>> "/usr/lib64/python2.7/runpy.py", line 176, in run_module\n fname, loader, 
>> pkg_name)\n File "/usr/lib64/python2.7/runpy.py", line 82, in 
>> _run_module_code\n mod_name, mod_fname, mod_loader, pkg_name)\n File 
>> "/usr/lib64/python2.7/runpy.py", line 72, in _run_code\n exec code in 
>> run_globals\n File 
>> "/tmp/ansible_oracle_grants_payload_GK4fah/ansible_oracle_grants_payload.zip/ansible/modules/oracle_grants.py",
>>  
>> line 673, in \n File 
>> "/tmp/ansible_oracle_grants_payload_GK4fah/ansible_oracle_grants_payload.zip/ansible/modules/oracle_grants.py",
>>  
>> line 646, in main\nTypeError: remove_grants() takes exactly 7 arguments (6 
>> given)\n",
>> "module_st

[ansible-project] oracle_privs doesn

2020-01-29 Thread Anand Solomon
I am trying to use oracle_privs module to revoke privileges in account. 
Below is my playbook


  tasks:
- name: This playbook will grant or revoke privilges in the user.
  oracle_privs:
user: "{{user}}"
password: "{{password}}"
service_name: "{{sname}}"
port: "{{prt}}"
hostname: "{{hostname}}"
privs:
  - INSERT ANY TABLE
state: absent
roles:
  - TSTSCH
  environment: "{{oracle_env}}"
  register: user_privs
  delegate_to: localhost

And here is what I get 

"msg": {
"changed": false,
"failed": false,
"msg": null
}
}


What am I missing here ?

-- 
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/510bad9a-41a0-4587-98f6-a09a2d0ab603%40googlegroups.com.


Re: [ansible-project] oracle_user module error expecting cx_oracle in DB server

2020-01-28 Thread Anand Solomon
It goes soon after the comments

 /* 
 
###
 
 # Program   : .sql 
 # Programmer: x 
 # Date  : x 
 # Usage :  
 # Revisions : x 
 # Dependencies  : 
 # 1. Sqlplus Binaries. 
 # 
 # Notes : Script will creates Oracle packages on AWS RDS. 
 # Author:  
 # Creates change passwords and lock a/c's  
 # after the user is done . 
###
 
 */ 
set serveroutput on;
select username from dba_users;
/
..

On Tuesday, January 28, 2020 at 12:34:00 PM UTC-5, Stefan Hornburg (Racke) 
wrote:
>
> On 1/28/20 6:31 PM, Anand Solomon wrote: 
> > My sql script will look like 
> > 
> > /* 
> > 
> ###
>  
>
> > # Program   : .sql 
> > # Programmer: x 
> > # Date  : x 
> > # Usage :  
> > # Revisions : x 
> > # Dependencies  : 
> > # 1. Sqlplus Binaries. 
> > # 
> > # Notes : Script will creates Oracle packages on AWS RDS. 
> > # Author:  
> > # Creates change passwords and lock a/c's  
> > # after the user is done . 
> > 
> > 
> ###
>  
>
> > */ 
> > 
>
>  

> So where is the SQL code? 
>
> Regards 
>  Racke 
>
> > 
> > On Tuesday, January 28, 2020 at 12:18:33 PM UTC-5, Stefan Hornburg 
> (Racke) wrote: 
> > 
> > On 1/28/20 6:05 PM, Anand Solomon wrote: 
> > > Hi, 
> > > I am using oracle_sql module and running a sql script. The sql 
> script contains comments. The playbook fails because " 
> > > FAILED! => {"changed": false, "msg": "Something went wrong while 
> executing sql - ORA-00911: invalid character sql:  
> > > 
> > > Is there a way I can keep the comments and execute the sql script 
> ? 
> > > 
> > 
> > I suppose you could filter out the comments. How does your SQL 
> script looks like? 
> > 
> > Regards 
> > Racke 
> > 
> > > 
> > > On Saturday, January 25, 2020 at 5:17:44 PM UTC-5, Dick Visser 
> wrote: 
> > > 
> > > Hi 
> > > 
> > > Ansible doesn’t have such a module, so I assume this is a 3rd 
> party module? 
> > > In that case you might have more luck asking the module’s 
> authors for support.  
> > > 
> > > 
> > > On Sat, 25 Jan 2020 at 16:07, Anand Solomon <
> anand@gmail.com > wrote: 
> > > 
> > > I am trying to create oracle user using oracle_user module 
> in a RDS server. Here is my playbook 
> > > 
> > > - hosts: all 
> > >   vars: 
> > > oracle_home: /home/ansible/instantclient_12_2 
> > > user: SYSDBA 
> > > password: ** 
> > > prt: "1521" 
> > > hostname: "RDS Instance" 
> > > sname: TESTDB 
> > > oracle_env: 
> > >   ORACLE_HOME: "{{oracle_home}}" 
> > >   LD_LIBRARY_PATH: "{{oracle_home}}" 
> > >   PATH: "{{oracle_home}}" 
> > > 
> > >   vars_files: 
> > > - vault-pass.yml 
> > > 
> > >   tasks: 
> > > - name: This playbook will create the user. 
> > >   oracle_user: 
> > > oracle_home: /home/ansible/instantclient_12_2 
> > > user: "{{user}}" 
> > > password: "{{password}}" 
> > > service_name: "{{sname}}" 
> > > port: "{{prt}}" 
> > > hostname: "{{hostname}}" 
> > > schema: * 
> > >  

Re: [ansible-project] oracle_user module error expecting cx_oracle in DB server

2020-01-28 Thread Anand Solomon
My sql script will look like

/* 
###
# Program   : .sql
# Programmer: x
# Date  : x
# Usage : 
# Revisions : x
# Dependencies  :
# 1. Sqlplus Binaries.
#
# Notes : Script will creates Oracle packages on AWS RDS.
# Author: 
# Creates change passwords and lock a/c's 
# after the user is done .

###
 
*/


On Tuesday, January 28, 2020 at 12:18:33 PM UTC-5, Stefan Hornburg (Racke) 
wrote:
>
> On 1/28/20 6:05 PM, Anand Solomon wrote: 
> > Hi, 
> > I am using oracle_sql module and running a sql script. The sql script 
> contains comments. The playbook fails because " 
> > FAILED! => {"changed": false, "msg": "Something went wrong while 
> executing sql - ORA-00911: invalid character sql:  
> > 
> > Is there a way I can keep the comments and execute the sql script ? 
> > 
>
> I suppose you could filter out the comments. How does your SQL script 
> looks like? 
>
> Regards 
> Racke 
>
> > 
> > On Saturday, January 25, 2020 at 5:17:44 PM UTC-5, Dick Visser wrote: 
> > 
> > Hi 
> > 
> > Ansible doesn’t have such a module, so I assume this is a 3rd party 
> module? 
> >     In that case you might have more luck asking the module’s authors 
> for support.  
> > 
> > 
> > On Sat, 25 Jan 2020 at 16:07, Anand Solomon  > wrote: 
> > 
> > I am trying to create oracle user using oracle_user module in a 
> RDS server. Here is my playbook 
> > 
> > - hosts: all 
> >   vars: 
> > oracle_home: /home/ansible/instantclient_12_2 
> > user: SYSDBA 
> > password: ** 
> > prt: "1521" 
> > hostname: "RDS Instance" 
> > sname: TESTDB 
> > oracle_env: 
> >   ORACLE_HOME: "{{oracle_home}}" 
> >   LD_LIBRARY_PATH: "{{oracle_home}}" 
> >   PATH: "{{oracle_home}}" 
> > 
> >   vars_files: 
> > - vault-pass.yml 
> > 
> >   tasks: 
> > - name: This playbook will create the user. 
> >   oracle_user: 
> > oracle_home: /home/ansible/instantclient_12_2 
> > user: "{{user}}" 
> > password: "{{password}}" 
> > service_name: "{{sname}}" 
> > port: "{{prt}}" 
> > hostname: "{{hostname}}" 
> > schema: * 
> > schema_password:  
> > default_tablespace: USERS 
> > #state: present 
> > grants: "'create session', create any table'" 
> >   environment: "{{oracle_env}}" 
> > 
> > This fails with below error 
> > FAILED! => {"changed": false, "msg": "The cx_Oracle module is 
> required. 'pip install cx_Oracle' should do the 
> > trick. If cx_Oracle is installed, make sure ORACLE_HOME & 
> LD_LIBRARY_PATH is set"} 
> > 
> > DO we need to have cx_oracle installed in the target server too? 
> I had this same issue with oracle_sql module 
> > too, but I used "connection: local" to enforced the playbook to 
> look at the local cx_oracle install. This is not 
> > working in oracle_user module. 
> > 
> > -- 
> > 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...@googlegroups.com 
> > . 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/ansible-project/c1c30471-934e-42e2-9e2b-991c1e57db87%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/c1c30471-934e-42e2-9e2b-991c1e57db87%40googlegroups.com?utm_medium=email_source=footer>.
>  
>
> > 
> > -- 
> > Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation. 
> > 
> > -- 
> 

Re: [ansible-project] oracle_user module error expecting cx_oracle in DB server

2020-01-28 Thread Anand Solomon
Hi,
I am using oracle_sql module and running a sql script. The sql script 
contains comments. The playbook fails because "
FAILED! => {"changed": false, "msg": "Something went wrong while executing 
sql - ORA-00911: invalid character sql: 

Is there a way I can keep the comments and execute the sql script ?


On Saturday, January 25, 2020 at 5:17:44 PM UTC-5, Dick Visser wrote:
>
> Hi
>
> Ansible doesn’t have such a module, so I assume this is a 3rd party module?
> In that case you might have more luck asking the module’s authors for 
> support. 
>
>
> On Sat, 25 Jan 2020 at 16:07, Anand Solomon  > wrote:
>
>> I am trying to create oracle user using oracle_user module in a RDS 
>> server. Here is my playbook
>>
>> - hosts: all
>>   vars:
>> oracle_home: /home/ansible/instantclient_12_2
>> user: SYSDBA
>> password: **
>> prt: "1521"
>> hostname: "RDS Instance"
>> sname: TESTDB
>> oracle_env:
>>   ORACLE_HOME: "{{oracle_home}}"
>>   LD_LIBRARY_PATH: "{{oracle_home}}"
>>   PATH: "{{oracle_home}}"
>>
>>   vars_files:
>> - vault-pass.yml
>>
>>   tasks:
>> - name: This playbook will create the user.
>>   oracle_user:
>> oracle_home: /home/ansible/instantclient_12_2
>> user: "{{user}}"
>> password: "{{password}}"
>> service_name: "{{sname}}"
>> port: "{{prt}}"
>> hostname: "{{hostname}}"
>> schema: *
>> schema_password: 
>> default_tablespace: USERS
>> #state: present
>> grants: "'create session', create any table'"
>>   environment: "{{oracle_env}}"
>>
>> This fails with below error
>> FAILED! => {"changed": false, "msg": "The cx_Oracle module is required. 
>> 'pip install cx_Oracle' should do the trick. If cx_Oracle is installed, 
>> make sure ORACLE_HOME & LD_LIBRARY_PATH is set"}
>>
>> DO we need to have cx_oracle installed in the target server too? I had 
>> this same issue with oracle_sql module too, but I used "connection: local" 
>> to enforced the playbook to look at the local cx_oracle install. This is 
>> not working in oracle_user module.
>>
>> -- 
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/c1c30471-934e-42e2-9e2b-991c1e57db87%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/c1c30471-934e-42e2-9e2b-991c1e57db87%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
> -- 
> Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation.
>

-- 
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/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com.


[ansible-project] Error using state: absent in oracle_grant module

2020-01-28 Thread Anand Solomon


Hi,

I am running the below playbook and I am getting errors when having 'state: 
absent', but when I have 'present', it works fine.


  tasks:

- name: This playbook will create the user.

  oracle_grants:

user: "{{user}}"

password: "{{password}}"

service_name: "{{sname}}"

port: "{{prt}}"

hostname: "{{hostname}}"

schema: TSTSCH

#grants: "'DBA','create session','create any 
table',connect,resource"

grants: 'create session'

state: absent

  environment: "{{oracle_env}}"

  register: user_grants

  delegate_to: localhost




I am getting the below error

The full traceback is:
Traceback (most recent call last):
File 
"/home/ansible/.ansible/tmp/ansible-tmp-1580220579.04-228603469188212/AnsiballZ_oracle_grants",
 
line 102, in
_ansiballz_main()
File 
"/home/ansible/.ansible/tmp/ansible-tmp-1580220579.04-228603469188212/AnsiballZ_oracle_grants",
 
line 94, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File 
"/home/ansible/.ansible/tmp/ansible-tmp-1580220579.04-228603469188212/AnsiballZ_oracle_grants",
 
line 40, in invoke_module
runpy.run_module(mod_name='ansible.modules.oracle_grants', 
init_globals=None, run_name='main', alter_sys=True)
File "/usr/lib64/python2.7/runpy.py", line 176, in run_module
fname, loader, pkg_name)
File "/usr/lib64/python2.7/runpy.py", line 82, in _run_module_code
mod_name, mod_fname, mod_loader, pkg_name)
File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File 
"/tmp/ansible_oracle_grants_payload_GK4fah/ansible_oracle_grants_payload.zip/ansible/modules/oracle_grants.py",
 
line 673, in
File 
"/tmp/ansible_oracle_grants_payload_GK4fah/ansible_oracle_grants_payload.zip/ansible/modules/oracle_grants.py",
 
line 646, in main
TypeError: remove_grants() takes exactly 7 arguments (6 given)

fatal: [22.174.101.30 -> localhost]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n File 
"/home/ansible/.ansible/tmp/ansible-tmp-1580220579.04-228603469188212/AnsiballZ_oracle_grants",
 
line 102, in \n _ansiballz_main()\n File 
"/home/ansible/.ansible/tmp/ansible-tmp-1580220579.04-228603469188212/AnsiballZ_oracle_grants",
 
line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, 
ANSIBALLZ_PARAMS)\n File 
"/home/ansible/.ansible/tmp/ansible-tmp-1580220579.04-228603469188212/AnsiballZ_oracle_grants",
 
line 40, in invoke_module\n 
runpy.run_module(mod_name='ansible.modules.oracle_grants', 
init_globals=None, run_name='main', alter_sys=True)\n File 
"/usr/lib64/python2.7/runpy.py", line 176, in run_module\n fname, loader, 
pkg_name)\n File "/usr/lib64/python2.7/runpy.py", line 82, in 
_run_module_code\n mod_name, mod_fname, mod_loader, pkg_name)\n File 
"/usr/lib64/python2.7/runpy.py", line 72, in _run_code\n exec code in 
run_globals\n File 
"/tmp/ansible_oracle_grants_payload_GK4fah/ansible_oracle_grants_payload.zip/ansible/modules/oracle_grants.py",
 
line 673, in \n File 
"/tmp/ansible_oracle_grants_payload_GK4fah/ansible_oracle_grants_payload.zip/ansible/modules/oracle_grants.py",
 
line 646, in main\nTypeError: remove_grants() takes exactly 7 arguments (6 
given)\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}

-- 
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/b597c7c3-37b3-475a-bc25-420ab0519830%40googlegroups.com.


Re: [ansible-project] Running a select statement as script using oracle_sql module

2020-01-27 Thread Anand Solomon
Looks like we can only use sql parameter in oracle_sql module.

On Saturday, January 25, 2020 at 5:30:05 PM UTC-5, Dick Visser wrote:
>
> This isn't a module that ships with ansible, please contact the 
> module's authors for support. 
>
> On Sat, 25 Jan 2020 at 16:03, Anand Solomon  > wrote: 
> > 
> > Hi, 
> > I am trying to run a sql script which has simple select statement. 
> (select username from dba_users). Will oracle_sql module run a "Select" 
> statement and returns the results ? 
> > 
> > My playbook is 
> > 
> > - name: Script will creates Oracle DBA IDs and Profiles on AWS RDS. 
> >   oracle_sql: 
> > username: "{{user}}" 
> > password: "{{password}}" 
> > service_name: "{{sname}}" 
> > port: "{{prt}}" 
> > host: "{{host}}" 
> > script: "/home/ansible/Compliance.sql" 
> >   environment: "{{oracle_env}}" 
> >   register: query_result 
> >   connection: local 
> > 
> > If I run the sql statement as sql: "select username from dba_users", it 
> works. The same sql statement if I run script: 
> /home/ansible/Compliance.sql. It is not working. 
> > 
> > 
> > I am getting "{"changed": false, "msg": "Something went wrong while 
> executing sql - ORA-00972: identifier is too long sql: \"Finished running 
> script /home/ansible/Compliance.sql \\nContents: \\nselect username\\\n  \\ 
> from dba_users\""} 
> > 
> > The debug output is as below: 
> > 
> > TASK [Display the query results] 
> 
>  
>
> > ok: [22.174.101.30] => (item=msg.stdout) => { 
> > "msg": { 
> > "changed": true, 
> > "failed": false, 
> > "msg": "Finished running script /home/ansible/Compliance.sql 
> \nContents: \nselect username from dba_users" 
> > } 
> > } 
> > 
> > -- 
> > 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...@googlegroups.com . 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/d4403538-8111-4e52-87af-390efa2dd5cd%40googlegroups.com.
>  
>
>
>
>
> -- 
> Dick Visser 
> Trust & Identity Service Operations Manager 
> GÉANT 
>

-- 
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/7e5f2424-992c-4777-a0f9-738511d1bf43%40googlegroups.com.


Re: [ansible-project] Simple Loop

2020-01-27 Thread Anand Solomon
This works now. Thanks.

On Monday, January 27, 2020 at 11:03:57 AM UTC-5, Dick Visser wrote:
>
> If you supply the list as: 
>
> vars: 
>   schemaname: 
> - user1 
> - user2 
> - user3 
>
> then it's as easy as: 
>
> loop: "{{ schemaname }}" 
>
>
> If you get that comma delimited string from somewhere else (which I 
> asked but got no response to), then you'd have to manually split and 
> trim: 
>
> loop: "{{ schemaname.split(',') | map('trim') | list }}" 
>
>
>
>
>
>
> On Mon, 27 Jan 2020 at 16:53, Anand Solomon  > wrote: 
> > 
> > Yes, All I want to create is the user from the list (vars). This will be 
> hard coded value from the vars and the password will be the same for all 
> the users. 
> > 
> > 
> > 
> > On Monday, January 27, 2020 at 10:34:25 AM UTC-5, Dick Visser wrote: 
> >> 
> >> On Mon, 27 Jan 2020 at 15:57, Anand Solomon  
> wrote: 
> >> > 
> >> > Hi, 
> >> > I want to create users in the database using Ansible. I need ansible 
> to run the task (creating user) for all the users mentioned in the vars: 
> schemaname. How do I do that in loop ? 
> >> 
> >> That list of users only has the usernames. 
> >> If you loop over them, and that is all the information you have, they 
> >> will all have the same password. 
> >> Are you sure that is what you want? 
> >> 
> >> 
> >> 
> >> > var: 
> >> >schemaname: user1, user2, user3 
> >> > 
> >> >   tasks: 
> >> > - name: This playbook will create the user. 
> >> >   oracle_user: 
> >> > oracle_home: /home/ansible/instantclient_12_2 
> >> > user: "{{user}}" 
> >> > password: "{{password}}" 
> >> > service_name: "{{sname}}" 
> >> > port: "{{prt}}" 
> >> > hostname: "{{hostname}}" 
> >> > schema: "{{schemaname}}" 
> >> > schema_password: 
> >> > default_tablespace: USERS 
> >> > state: present 
> >> > update_password: on_create 
> >> > grants: "DBA" 
> >> >   environment: "{{oracle_env}}" 
> >> >   register: user_create 
> >> >   delegate_to: localhost 
> >> > 
> >> > 
> >> > -- 
> >> > 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...@googlegroups.com. 
> >> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/d8a7aad1-7272-44b7-b982-3673ec88190b%40googlegroups.com.
>  
>
> >> 
> >> 
> >> 
> >> -- 
> >> Dick Visser 
> >> Trust & Identity Service Operations Manager 
> >> GÉANT 
> > 
> > -- 
> > 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...@googlegroups.com . 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/a0d681bc-20c1-41f1-bc77-5e9903acf8b3%40googlegroups.com.
>  
>
>
>
>
> -- 
> Dick Visser 
> Trust & Identity Service Operations Manager 
> GÉANT 
>

-- 
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/c2501668-38bd-45be-953a-8a9ead5ff581%40googlegroups.com.


Re: [ansible-project] Simple Loop

2020-01-27 Thread Anand Solomon
Yes, All I want to create is the user from the list (vars). This will be 
hard coded value from the vars and the password will be the same for all 
the users. 



On Monday, January 27, 2020 at 10:34:25 AM UTC-5, Dick Visser wrote:
>
> On Mon, 27 Jan 2020 at 15:57, Anand Solomon  > wrote: 
> > 
> > Hi, 
> > I want to create users in the database using Ansible. I need ansible to 
> run the task (creating user) for all the users mentioned in the vars: 
> schemaname. How do I do that in loop ? 
>
> That list of users only has the usernames. 
> If you loop over them, and that is all the information you have, they 
> will all have the same password. 
> Are you sure that is what you want? 
>
>
>
> > var: 
> >schemaname: user1, user2, user3 
> > 
> >   tasks: 
> > - name: This playbook will create the user. 
> >   oracle_user: 
> > oracle_home: /home/ansible/instantclient_12_2 
> > user: "{{user}}" 
> > password: "{{password}}" 
> > service_name: "{{sname}}" 
> > port: "{{prt}}" 
> > hostname: "{{hostname}}" 
> > schema: "{{schemaname}}" 
> > schema_password: 
> > default_tablespace: USERS 
> > state: present 
> > update_password: on_create 
> > grants: "DBA" 
> >   environment: "{{oracle_env}}" 
> >   register: user_create 
> >   delegate_to: localhost 
> > 
> > 
> > -- 
> > 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...@googlegroups.com . 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/d8a7aad1-7272-44b7-b982-3673ec88190b%40googlegroups.com.
>  
>
>
>
>
> -- 
> Dick Visser 
> Trust & Identity Service Operations Manager 
> GÉANT 
>

-- 
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/a0d681bc-20c1-41f1-bc77-5e9903acf8b3%40googlegroups.com.


[ansible-project] Simple Loop

2020-01-27 Thread Anand Solomon
Hi,
I want to create users in the database using Ansible. I need ansible to run 
the task (creating user) for all the users mentioned in the vars: 
schemaname. How do I do that in loop ?

var:
   schemaname: user1, user2, user3

  tasks:
- name: This playbook will create the user.
  oracle_user:
oracle_home: /home/ansible/instantclient_12_2
user: "{{user}}"
password: "{{password}}"
service_name: "{{sname}}"
port: "{{prt}}"
hostname: "{{hostname}}"
schema: "{{schemaname}}"
schema_password: 
default_tablespace: USERS
state: present
update_password: on_create
grants: "DBA"
  environment: "{{oracle_env}}"
  register: user_create
  delegate_to: localhost


-- 
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/d8a7aad1-7272-44b7-b982-3673ec88190b%40googlegroups.com.


[ansible-project] oracle_user module error expecting cx_oracle in DB server

2020-01-25 Thread Anand Solomon
I am trying to create oracle user using oracle_user module in a RDS server. 
Here is my playbook

- hosts: all
  vars:
oracle_home: /home/ansible/instantclient_12_2
user: SYSDBA
password: **
prt: "1521"
hostname: "RDS Instance"
sname: TESTDB
oracle_env:
  ORACLE_HOME: "{{oracle_home}}"
  LD_LIBRARY_PATH: "{{oracle_home}}"
  PATH: "{{oracle_home}}"

  vars_files:
- vault-pass.yml

  tasks:
- name: This playbook will create the user.
  oracle_user:
oracle_home: /home/ansible/instantclient_12_2
user: "{{user}}"
password: "{{password}}"
service_name: "{{sname}}"
port: "{{prt}}"
hostname: "{{hostname}}"
schema: *
schema_password: 
default_tablespace: USERS
#state: present
grants: "'create session', create any table'"
  environment: "{{oracle_env}}"

This fails with below error
FAILED! => {"changed": false, "msg": "The cx_Oracle module is required. 
'pip install cx_Oracle' should do the trick. If cx_Oracle is installed, 
make sure ORACLE_HOME & LD_LIBRARY_PATH is set"}

DO we need to have cx_oracle installed in the target server too? I had this 
same issue with oracle_sql module too, but I used "connection: local" to 
enforced the playbook to look at the local cx_oracle install. This is not 
working in oracle_user module.

-- 
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/c1c30471-934e-42e2-9e2b-991c1e57db87%40googlegroups.com.


[ansible-project] Running a select statement as script using oracle_sql module

2020-01-25 Thread Anand Solomon
Hi,
I am trying to run a sql script which has simple select statement. (select 
username from dba_users). Will oracle_sql module run a "Select" statement 
and returns the results ?

My playbook is 

- name: Script will creates Oracle DBA IDs and Profiles on AWS RDS.
  oracle_sql:
username: "{{user}}"
password: "{{password}}"
service_name: "{{sname}}"
port: "{{prt}}"
host: "{{host}}"
script: "/home/ansible/Compliance.sql"
  environment: "{{oracle_env}}"
  register: query_result
  connection: local

If I run the sql statement as sql: "select username from dba_users", it 
works. The same sql statement if I run script: 
/home/ansible/Compliance.sql. It is not working.


I am getting "{"changed": false, "msg": "Something went wrong while 
executing sql - ORA-00972: identifier is too long sql: \"Finished running 
script /home/ansible/Compliance.sql \\nContents: \\nselect username\\\n  \\ 
from dba_users\""}

The debug output is as below:

TASK [Display the query results] 

ok: [22.174.101.30] => (item=msg.stdout) => {
"msg": {
"changed": true,
"failed": false,
"msg": "Finished running script /home/ansible/Compliance.sql 
\nContents: \nselect username from dba_users"
}
}

-- 
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/d4403538-8111-4e52-87af-390efa2dd5cd%40googlegroups.com.


Re: [ansible-project] How to skip the playbook based on a condition

2020-01-24 Thread Anand Solomon
Thanks I got this working.

On Friday, January 24, 2020 at 3:37:43 PM UTC-5, Dick Visser wrote:
>
> meta: end_play 
> is what you want 
>
> https://docs.ansible.com/ansible/latest/modules/meta_module.html
>
>
> On Fri, 24 Jan 2020 at 21:01, Anand Solomon  > wrote:
>
>> Hi,
>> I basically wanted to skip the remaining of the playbook if a file exists
>>
>>
>> - name: Check if the file exists
>>   stat:
>> path: /home/ansible/dbname/sql/file.sql
>>   register: optional_file
>>
>> - debug:
>> msg: "File Exists"
>>   when: optional_file.stat.exists == True
>>
>> Also, Is there a way I read the same file, and based on a string I stop 
>> the remaining playbook?
>>
>> -- 
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/fcc2839d-c216-4a2c-a79b-c124856c6ccc%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/fcc2839d-c216-4a2c-a79b-c124856c6ccc%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
> -- 
> Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation.
>

-- 
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/e721cdba-d562-4ec5-922a-f46c5ba25b6e%40googlegroups.com.


[ansible-project] How to skip the playbook based on a condition

2020-01-24 Thread Anand Solomon
Hi,
I basically wanted to skip the remaining of the playbook if a file exists


- name: Check if the file exists
  stat:
path: /home/ansible/dbname/sql/file.sql
  register: optional_file

- debug:
msg: "File Exists"
  when: optional_file.stat.exists == True

Also, Is there a way I read the same file, and based on a string I stop the 
remaining playbook?

-- 
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/fcc2839d-c216-4a2c-a79b-c124856c6ccc%40googlegroups.com.