TASK [Check DB connection] ********************************************************************************************************************************************* fatal: [localhost]: FAILED! => {"changed": false, "msg": "unable to connect, chec

327 views
Skip to first unread message

Narmada Karthika

unread,
Jul 3, 2023, 4:07:45 PM7/3/23
to Ansible Project
Any idea about this error, the username and password are correct those are dbo creds. I am able to connect through ssms with the same creds but not working through ansible 
also I don't see @sysconfdir@/freetds.conf / ${HOME}/.freetds.conf" on my linux node...


TASK [Check DB connection] *********************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "unable to connect, check login_user and login_password are correct, or alternatively check your @sysconfdir@/freetds.conf / ${HOME}/.freetds.conf"}

Abhijeet Kasurde

unread,
Jul 3, 2023, 4:18:28 PM7/3/23
to ansible...@googlegroups.com
Hi Narmada,

Could you please provide more context like playbooks used, collections used, modules used, ultimate aim to achieve etc? Without this information, it is really difficult to debug.

--
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-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/450d5ff6-1aba-45e3-ab89-555225d3db46n%40googlegroups.com.


--
Thanks,
Abhijeet Kasurde

Narmada Karthika

unread,
Jul 3, 2023, 4:56:09 PM7/3/23
to Ansible Project
pymssql-2.2.7
I am just trying to make a sql connection by checking the connectivity to sql server, if this is successfully I have to get some select and update statements working 
this is my playbook
---
 - name: Execute sql commands
   hosts: localhost
   gather_facts: false
   become: true
   user: root
   vars_files:
     - group_vars/mssqlpass.yml
   tasks:
     - name: Check DB connection
       community.general.mssql_script:
         login_user: "{{ mssql_login_user }}"
         login_password: "{{ mssql_login_password }}"
         login_host: "{{ mssql_server }}"
         login_port: "{{ mssql_port }}"
         db: dbname
         script: "SELECT *"

Narmada Karthika

unread,
Jul 5, 2023, 12:30:23 PM7/5/23
to Ansible Project
any other details needed?

Narmada Karthika

unread,
Jul 6, 2023, 2:40:27 PM7/6/23
to Ansible Project
can some one shower some light here 

Abhijeet Kasurde

unread,
Jul 6, 2023, 3:11:09 PM7/6/23
to ansible...@googlegroups.com
Hi Narmada,

Seems like you have an exception in the mssql_script module. Can you please try this Python script https://gist.github.com/Akasurde/b848017c027c71e6e5fd80d5f0f01a8b since module is swallowing the exception?



--
Thanks,
Abhijeet Kasurde

Will McDonald

unread,
Jul 6, 2023, 3:12:41 PM7/6/23
to ansible...@googlegroups.com
Is {{ mssql_server }} pointing at:

1. your local machine localhost running SQL Server on Linux directly
2. or a remote machine running SQL Server on Linux
3. or a remote machine running SQL Server on Windows?

If your scenario is #2, have you installed pymssql on the target machine as well as your Ansible control node? (See: https://docs.ansible.com/ansible/latest/collections/community/general/mssql_script_module.html#notes)

If your scenarios is #3, see: https://github.com/ansible/ansible/issues/39612#issuecomment-597451375 (This is a different Ansible module but it's using the same Python under the covers.)

You might get more help if you can provide proper output (with passwords redacted) of an actual run with -v[vv], the inventory and as much more information as you possibly can.

Narmada Karthika

unread,
Jul 26, 2023, 1:03:54 PM7/26/23
to Ansible Project
Thank you so much, I am able to fix the issue..   If your scenarios is #3, see: https://github.com/ansible/ansible/issues/39612#issuecomment-597451375 (This is a different Ansible module but it's using the same Python under the covers.)  this helped me
Reply all
Reply to author
Forward
0 new messages