On 28.08.2019 08:50, Mohtashim S wrote:
Below is my playbook:

   - name: "Collecting File details"
shell: "ls -ltr {{ item }} | awk '{$2=$4=$5=""; print $0}' | tr '\n'
'\t' | tr -s " ";

     with_fileglob:

       - "{{ playbook_dir }}/tmpfiles/*"


I get syntax error due to the awk command as below.

ERROR! Syntax Error while loading YAML.
  did not find expected key
shell: "ls -ltr {{ item }} | awk '{$2=$4=$5=""; print $0}' | tr '\n'
'\t' | tr -s " ";
^
here
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:


Can you please suggest how can I incorporate such a awk in ansible shell
module ?

As the error message say you have a missing quote.
So lets start on the first qoute and that is the double quote in front of ls. And if you them look at every other quotes you'll see that it's not closed anywhere.

Since you don't need a quote at the start of the shell command anyway just remove it.



--
Kai Stian Olstad

--
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/9ebe6812487943d3f0afd4cd236ae0ee%40olstad.com.

Reply via email to