[ansible-devel] Ansible Python API 2.0 - capture warnings

2018-04-11 Thread Suren Baskaran
Hello All
Been circling around the Callbackbase with all possible tries , but I could 
not find a way till now to capture these warnings from a playbook execution 
with the API output

[WARNING]:  * Failed to parse hosts/UAT/ dictionary, got: 

 [WARNING]:  * Failed to parse /hosts/UAT/ssh_keys/dbrun_46186_1_uat with 
ini plugin:: Expected key=value host variable assignment, got: RSA
 [WARNING]: Could not match supplied host pattern, ignoring: primary_host


Appreciate some help - on how to capture these warning messages when we run 
playbooks via the API?

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-devel] Need to execute complex unix commands

2018-04-09 Thread Suren Baskaran
How about
1) a creating a script with commands ,
2) execute
3) and remove

Thanks,
Suren VB

From: ansible-devel@googlegroups.com  on behalf 
of Akash Agarwal 
Sent: Monday, April 9, 2018 12:11:02 PM
To: Ansible Development
Subject: [ansible-devel] Need to execute complex unix commands

Hi All,

I need to execute complex shell commands on remote or local hosts. What is the 
best way to this?

I tried multiple ways. Either it is not passing Ansible syntax, or shell script 
syntax

Example:

Suppose I want to execute this command

echo "ps -ef|grep data"|sed 's~[^[:alnum:]/]\+~~g'|sed "s/$/$(date 
+"%d_%m_%Y_%H_%M_%S")/"

It gives following output on shell :
psefgrepdata09_04_2018_12_08_55

But somehow I am not able to execute. Urgent help please ?

Thanks,
Akash

--
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-devel] Re: complete ansible command line verbose like display using the python API

2018-04-03 Thread Suren Baskaran
Thanks for the reply Brian

Unfortunately I do have it , it gives me all valid Output for the verbose

But the one thing I seem to miss is the - ansible versions , task paths , 
module paths , and host tasks details , ran meta handlers that comes with a 
ansible command line verbose

Thanks,
Suren VB

From: ansible-devel@googlegroups.com  on behalf 
of Brian Coca 
Sent: Tuesday, April 3, 2018 10:36:21 PM
To: Ansible Development
Subject: Re: [ansible-devel] Re: complete ansible command line verbose like 
display using the python API

In this case you seem to be missing code to handle the
v2_runner_on_unreachable event.



--
--
Brian Coca

--
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-devel] complete ansible command line verbose like display using the python API

2018-04-02 Thread Suren Baskaran
Hi

So when we run a ansible playbook in command line with -vvv [ verbosity=3] 
we get all these below information like "Task path" , "using module" and 
the internals of how each hosts gets connectivity established.



TASK [SHOW THE LAST 10 ALERTS ] 
**
task path: 
Using module file 
/usr/lib/python2.7/site-packages/ansible/modules/commands/command.py
 ESTABLISH SSH CONNECTION FOR USER: 
 SSH: EXEC ssh -C -o ControlMaster=auto -o 
ControlPersist=60s -o KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey 
-o PasswordAuthentication=no -o User=tpeng -o ConnectTimeout=10 -o 
ControlPath=XX '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''
 (255, '', 'ssh: connect to host XX port 22: 
Connection timed out\r\n')
fatal: [gmcrou07.uk.db.com]: UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: ssh: connect to 
host  port 22: Connection timed out\r\n",
"unreachable": true
}


Whereas when I set the same verbosity using the python API , I just an 
detailed info why the SSH failed to connect  like below


Failed to connect to the host via ssh: OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  
26 Jan 2017\r\ndebug1: Reading configuration data 
/etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 1: Applying options 
for *\r\ndebug1: /etc/ssh/ssh_config line 4: Deprecated option 
\"rhostsauthentication\"\r\ndebug1: /etc/ssh/ssh_config line 8: Deprecated 
option \"fallbacktorsh\"\r\ndebug1: /etc/ssh/ssh_config line 9: Deprecated 
option \"usersh\"\r\ndebug1: auto-mux: Trying existing master\r\ndebug1: 
Control socket \"/home/eqops_dev/.ansible/cp/26dab4b3e8\" does not 
exist\r\ndebug2: resolving \"X\" port 22\r\ndebug2: 
ssh_connect_direct: needpriv 0\r\ndebug1: Connecting to gmcrou07.uk.db.com 
[10.236.110.107] port 22.\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug1: 
connect to address Xx port 22: Connection timed out\r\nssh: connect to 
host XX port 22: Connection timed out



but not the other details , not sure if am missing any callback settings.

Appreciate some help here.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.