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 ?
Also, your YAML has quoting issues. It becomes hard to quote long line commands that has a mix of single and double quotes in YAML. You are better off using the script 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.