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

2018-04-09 Thread Sam Doran
If you need to execute complex shell command, a script file run by the script 
module is your best bet.

This particular examples look like you're analyzing running processes and 
getting a string back, not making changes to the system. This type of thing is 
better done by a facts plugin. Look at service_facts 

 for an example.

---

Sam

> On Apr 9, 2018, at 02:41, Akash Agarwal  wrote:
> 
> 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] 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.