Group vars lookup pipe

67 views
Skip to first unread message

Meher Garda

unread,
May 24, 2016, 10:12:43 AM5/24/16
to Ansible Project
In my group_vars folder , I have a file which has the following

scheduletime: 2016-09-01 08:41:15 

stime: "{{lookup('pipe','date +%Y-%m-%dT%H:%M:%SZ -d '+{{ scheduletime }}+'')}}"

I want to provide human readable time via scheduletime and then convert it into iso 8601 format

the following works on linux: date +%Y-%m-%dT%H:%M:%SZ -d "2016-09-01 08:41:15"

tryin to represent the same in ansible group_vars.

fatal: [localhost] => Failed to template {{stime}}: Failed to template {{lookup('pipe','date +%Y-%m-%dT%H:%M:%SZ -d '+{{ scheduletime }}+'')}}: template error while templating string: expected token ':', got '}'


I have tried many combinations of quotes, double quotes, but cannot seem to get it to work.


Johannes Kastl

unread,
May 25, 2016, 9:42:48 AM5/25/16
to ansible...@googlegroups.com
On 24.05.16 16:12 Meher Garda wrote:

> fatal: [localhost] => Failed to template {{stime}}: Failed to template
> {{lookup('pipe','date +%Y-%m-%dT%H:%M:%SZ -d '+{{ scheduletime }}+'')}}:
> template error while templating string: expected token ':', got '}'

Try escaping the single quotes and the colons.

Maybe run the task without using the variable, and just put a sample
value after the ...-d '+... Maybe you might need to quote that value
or escape it somehow. Finding out is easier without using a variable.

Johannes


signature.asc
Reply all
Reply to author
Forward
0 new messages