On 1/29/20 9:22 AM, Karther wrote: > Hello, > > Yes my task is this : > > - name: "Execut script python" > shell: ./myscript.py > delegate_to: localhost > > I want to get statut of my command line in my script for get message error.
Please try this (untested):
- name: "Execut script python"
shell: ./myscript.py
register: myscript
delegate_to: localhost
failed_when: false
- debug:
msg: "{{ myscript[stderr_lines] }}"
The failed_when condition is necessary to reach the debug task.
Regards
Racke
>
> Thanks very much Community Ansible :)
>
> Best Regards,
>
> Karther
>
> Le mardi 28 janvier 2020 17:54:58 UTC+1, Stefan Hornburg (Racke) a écrit :
>
> On 1/28/20 5:13 PM, Karther wrote:
> > Hello Varsha,
> >
> > For exemple if in my script sql "real.sql" there is commande line toto
> > I have this error :
> >
> > Traceback (most recent call last):
> > File "./script_sql_4.py", line 19, in <module>
> > cur.execute(f.read().decode('utf-8'))
> > File "/usr/lib/pymodules/python2.7/pymssql.py", line 196, in execute
> > raise OperationalError, e[0]
> > pymssql.OperationalError: SQL Server message 2812, severity 16, state
> 62, line 1:
> > Could not find stored procedure 'toto'.
> > DB-Lib error message 2812, severity 16:
> > General SQL Server error: Check messages from the SQL Server
> >
> >
> > I want get statut of my command
> "*cur.execute(f.read().decode('utf-8'))*" in python after this command is
> execute
> > for after get log message error with this value.
>
> So you want the error message from your script in your Ansible playbook?
> How does your task looks like right now?
>
> Regards
> Racke
>
>
> >
> > Someone have any idea please ?
> >
> > Thanks very much Community Ansible !! :)
> >
> > Best Regards,
> >
> >
> > Le mardi 28 janvier 2020 12:33:03 UTC+1, P. Varsha a écrit :
> >
> > can you please share what actually error log you are getting.
> >
> > On Tue, Jan 28, 2020 at 4:13 PM Karther <[email protected]
> <javascript:>> wrote:
> >
> > Hello,
> >
> > I have one script python script.py with this content :
> >
> > *#!/usr/bin/python*
> > *
> > *
> > *import pymssql*
> > *
> > *
> > *conn = pymssql.connect(host="ihospisql02", user="sa_ofs",
> password="#Adm!n0fS1", database="my_database")*
> > *cur = conn.cursor()*
> > *
> > *
> > *with open('real.sql') as f:*
> > * cur.execute(f.read().decode('utf-8'))*
> > * conn.commit()*
> > *
> > *
> > *cur.close()*
> >
> >
> >
> > i want that when i execut this script in ansible, i have log
> error in file or windows if there is error in
> this
> > script ?
> >
> > Can you help me please ?
> >
> > Thanks very much guy !!
> >
> > Best Regards,
> >
> > Karther
> >
> > --
> > 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]
> > <javascript:>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/f6435c57-b9f1-4f7b-9a7d-4209cbac5f0f%40googlegroups.com
>
> <https://groups.google.com/d/msgid/ansible-project/f6435c57-b9f1-4f7b-9a7d-4209cbac5f0f%40googlegroups.com>
> >
>
> <https://groups.google.com/d/msgid/ansible-project/f6435c57-b9f1-4f7b-9a7d-4209cbac5f0f%40googlegroups.com?utm_medium=email&utm_source=footer
>
> <https://groups.google.com/d/msgid/ansible-project/f6435c57-b9f1-4f7b-9a7d-4209cbac5f0f%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
> >
> > --
> > 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] <javascript:>
> <mailto:[email protected] <javascript:>>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/38aa9485-37df-4b9b-872c-9befad489b08%40googlegroups.com
>
> <https://groups.google.com/d/msgid/ansible-project/38aa9485-37df-4b9b-872c-9befad489b08%40googlegroups.com>
> >
>
> <https://groups.google.com/d/msgid/ansible-project/38aa9485-37df-4b9b-872c-9befad489b08%40googlegroups.com?utm_medium=email&utm_source=footer
>
> <https://groups.google.com/d/msgid/ansible-project/38aa9485-37df-4b9b-872c-9befad489b08%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration. Provisioning with Ansible.
>
> --
> 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]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/75211581-5901-45e1-823b-2de1ec25f80c%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/75211581-5901-45e1-823b-2de1ec25f80c%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/af35870d-797b-ef2c-f88b-4399367ac489%40linuxia.de.
signature.asc
Description: OpenPGP digital signature
