Hi, okay?
I'm new to ansible, so understand my rookie mistakes, rsrsrs. I'm having an
error interpreting my query. From what I realized the problem is in the
comma, when you get into it the Ansible gives the error below.
After adjusting this, I want to work with Jinja2 in the query.
What do I need to do to execute this query correctly?
ansible-playbook test.yml
---
- name: Dump Users
hosts: ansible
tasks:
- set_fact:
sqlscript1: "{{ lookup('template', 'sql.j2') }}"
- name: Dumps Users
command: sqlcmd -S 192.168.10.2 -d DATABASE1 -U sa -P "password" -Q
"{{ sqlscript1 }}"
register: result_login
- debug:
msg: "{{ result_login.stdout }}"
sql.j2:
SELECT DISTINCT PPOA.CODUSU
FROM SMATRICPL,
SAL,
PPOA
WHERE SMATRICPL.CODCOL = 1
AND SMATRICPL.CODSTATUS = 5
(SELECT DISTINCT PPOA.CODUSU
FROM PPOA,
PFUNC
WHERE PFUNC.CODPOA = PPOA.COD AND
PFUNC.CODR IN ('P','M','D') AND ... etc
Result:
PLAY [Dump Users]
********************************************************************************************************************
TASK [Gathering Facts]
************************************************************************************************************************************
ok: [192.168.10.15]
TASK [set_fact]
*******************************************************************************************************************************************
ok: [192.168.10.15]
TASK [Dump users]
******************************************************************************************************************************
changed: [192.168.10.15]
TASK [debug]
**********************************************************************************************************************************************
ok: [192.168.10.15] => {
"msg": "Msg 102, Level 15, State 1, Server SRVBD2, Line 26\nIncorrect
syntax near 'SMATRICP'."
}
PLAY RECAP
************************************************************************************************************************************************
192.168.10.15 : ok=4 changed=1 unreachable=0 failed=0
Thanks
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/42782b94-d25b-4e09-8f63-3cf3a996d428%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.