Ansible version: ansible 1.9.2

I am unable to execute following command from shell module neither through
playbook. It could be any command at the run time. While reading found $,%
need the escape string. Tried but not working. Is there any way/module
through which i can run any command on the remote host and no need to
explicitly define any escape string.


netstat -tanpu | awk '{{print $5}}' | sort -n | uniq -cd | sort -n | awk
'$1 > 3{{printf ("%5s\t%s\n", $1, $2)}}'

With shell module:

/usr/bin/ansible remote_host -m shell -a 'netstat -tanpu | awk '{{print
$5}}' | sort -n | uniq -cd | sort -n | awk '$1 > 3{{printf ("%5s\t%s\n",
$1, $2)}}''
-bash: syntax error near unexpected token `('


With playbook.

- hosts: "{{ip}}"
  gather_facts: no
  remote_user: remote
  connection: local

  tasks:
   - name: Running command
     shell: netstat -tanpu | awk '{{print $5}}' | sort -n | uniq -cd | sort
-n | awk '$1 > 3{{printf ("%5s\t%s\n", $1, $2)}}'

fatal: [192.168.4.7] => Failed to template netstat -tanpu | awk '{{print
$5}}' | sort -n | uniq -cd | sort -n | awk '$1 > 3{{printf ("%5s\t%s\n",
$1, $2)}}': template error while templating string: unexpected char u'$' at
30

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAH5ShBiDOStckyhbZNihw4HyC2-VcTp364y2SfhgTzgBmcSPDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to