Re: [ansible-project] TASK [Check DB connection] ********************************************************************************************************************************************* fatal: [l

2023-07-06 Thread Will McDonald
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.

On Thu, 6 Jul 2023 at 19:40, Narmada Karthika  wrote:

> can some one shower some light here
>
> On Wednesday, July 5, 2023 at 9:30:23 AM UTC-7 Narmada Karthika wrote:
>
>> any other details needed?
>>
>> On Monday, July 3, 2023 at 1:56:09 PM UTC-7 Narmada Karthika wrote:
>>
>>> 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 *"
>>>
>>> On Monday, July 3, 2023 at 1:18:28 PM UTC-7 Abhijeet Kasurde wrote:
>>>
 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.

 On Mon, Jul 3, 2023 at 1:07 PM Narmada Karthika 
 wrote:

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

>>> --
> 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/5d81367f-380c-41c1-ae4d-092e27fd820cn%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/CAKtKohQDDJNqm3Up5Mnrq8cnRXr94sNYdKQ1ftD-joW6HucwSA%40mail.gmail.com.


Re: [ansible-project] TASK [Check DB connection] ********************************************************************************************************************************************* fatal: [l

2023-07-06 Thread Abhijeet Kasurde
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?

On Thu, Jul 6, 2023 at 11:40 AM Narmada Karthika 
wrote:

> can some one shower some light here
>
> On Wednesday, July 5, 2023 at 9:30:23 AM UTC-7 Narmada Karthika wrote:
>
>> any other details needed?
>>
>> On Monday, July 3, 2023 at 1:56:09 PM UTC-7 Narmada Karthika wrote:
>>
>>> 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 *"
>>>
>>> On Monday, July 3, 2023 at 1:18:28 PM UTC-7 Abhijeet Kasurde wrote:
>>>
 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.

 On Mon, Jul 3, 2023 at 1:07 PM Narmada Karthika 
 wrote:

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

>>> --
> 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/5d81367f-380c-41c1-ae4d-092e27fd820cn%40googlegroups.com
> 
> .
>


-- 
Thanks,
Abhijeet Kasurde

-- 
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/CAFwWkHrYJc%2BB_u7C5TAQFbAheNwvFN1nR7Pd5GnTXBAQofc1Pw%40mail.gmail.com.


Re: [ansible-project] TASK [Check DB connection] ********************************************************************************************************************************************* fatal: [l

2023-07-06 Thread Narmada Karthika
can some one shower some light here 

On Wednesday, July 5, 2023 at 9:30:23 AM UTC-7 Narmada Karthika wrote:

> any other details needed?
>
> On Monday, July 3, 2023 at 1:56:09 PM UTC-7 Narmada Karthika wrote:
>
>> 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 *"
>>
>> On Monday, July 3, 2023 at 1:18:28 PM UTC-7 Abhijeet Kasurde wrote:
>>
>>> 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.
>>>
>>> On Mon, Jul 3, 2023 at 1:07 PM Narmada Karthika  
>>> wrote:
>>>
 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"}

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

-- 
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/5d81367f-380c-41c1-ae4d-092e27fd820cn%40googlegroups.com.


Re: [ansible-project] splitting the output of {{ ansible_play_name }}

2023-07-06 Thread dulhaver via Ansible Project
thanks. I guess that is pretty much the same thing as ...

{{ ansible_play_name.split('_')[0] }}

... (which I figured out in the meantime).

> On 07/06/2023 9:43 AM CEST Vladimir Botka  wrote:
> 
>  
> On Thu, 6 Jul 2023 09:10:48 +0200 (CEST)
> dulhaver via Ansible Project  wrote:
> 
> > ansible_play_name is i.e. POSTGRES_get_utf8.
> > How can I only get POSTGRES
> 
> Try this
> 
>   {{ ansible_play_name|split('_')|first }}
> 
> -- 
> Vladimir Botka

-- 
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/1957915435.911218.1688631288036%40office.mailbox.org.


Re: [ansible-project] splitting the output of {{ ansible_play_name }}

2023-07-06 Thread Vladimir Botka
On Thu, 6 Jul 2023 09:10:48 +0200 (CEST)
dulhaver via Ansible Project  wrote:

> ansible_play_name is i.e. POSTGRES_get_utf8.
> How can I only get POSTGRES

Try this

  {{ ansible_play_name|split('_')|first }}

-- 
Vladimir Botka

-- 
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/20230706094301.00c46681%40gmail.com.


pgp4nlx0m_SHv.pgp
Description: OpenPGP digital signature


[ansible-project] splitting the output of {{ ansible_play_name }}

2023-07-06 Thread dulhaver via Ansible Project
I have a tasks that writes information gathered from remotes to a csv file on 
localhost
 
 

- name: write result to output.csv
  delegate_to: localhost
  lineinfile:
dest: "./temp/{{ ansible_play_name }}.csv"
line: >
{{ ansible_fqdn }};{{ ansible_eth0.ipv4.address }};{{ ansible_distribution 
}} {{ ansible_distribution_version }};{{ ansible_play_name }};{{ 
pg_encoding.stdout }}
insertafter: EOF
 

 
 
now ... the ansible_play_name is i.e. POSTGRES_get_utf8.
How can I only get POSTGRES to be written out to the csv. I guess 'split' being 
part of the solution, but how exactly?

-- 
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/758425179.902050.1688627448111%40office.mailbox.org.