The problem is that you seem to be using templating that the `oc` command
will use that overlaps with template syntax of jinja.

You will likely need to wrap your command in {% raw %}command with {{ here
}}{% endraw %}

See http://jinja.pocoo.org/docs/dev/templates/#escaping

On Fri, Oct 27, 2017 at 11:26 AM, <[email protected]> wrote:

> The shell command that I want to execute is
>
> oc get sa/jenkins -n infra --template='{{range .secrets}}{{ .name }}
> {{end}}' | xargs -n 1 oc get secret --template='{{ if .data.token }}{{
> .data.token }}{{end}}' | head -n 1 | base64 -D -
>
> and I will get as response a token
>
> So the {{ }} characters that you see within my command are used to extract
> info using openshift oc template
>
> I will change my syntax to use jsonpath
>
>
>
> On Friday, October 27, 2017 at 5:56:24 PM UTC+2, [email protected] wrote:
>>
>> Hi
>>
>> How can I avoid that the template engine throws this error ?
>>
>> Task
>>
>> - name: Get Service Account Token
>>   shell: |
>>     /usr/local/bin/oc get sa/jenkins -n {{ namespace }} --template='{{range 
>> .secrets}}{{ .name }} {{end}}' | xargs -n 1 oc get secret --template='{{ if 
>> .data.token }}{{ .data.token }}{{end}}' | head -n 1 | base64 -D -
>>   register: sa_jenkins_token
>>
>>
>> Error
>>
>>   fatal: [10.8.244.145]: FAILED! => {"failed": true, "msg": "template error 
>> while templating string:
>>
>>   unexpected '.'. String: /usr/local/bin/oc get sa/jenkins -n {{ namespace 
>> }} --template='{{range .secrets}}{{ .name }} {{end}}' | xargs -n 1 oc get 
>> secret --template='{{ if .data.token }}{{ .data.token }}{{end}}' | head -n 1 
>> | base64 -D -"}
>>
>>
>> Regards
>>
>> Charles
>>
> --
> 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/de427462-21a7-4a8c-8000-3479de745ecb%40googlegroups.
> com
> <https://groups.google.com/d/msgid/ansible-project/de427462-21a7-4a8c-8000-3479de745ecb%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Matt Martz
@sivel
sivel.net

-- 
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/CAD8N0v83W7J4JMvm1W-Y%2Bd39tm0MCkp8DjWMU4axBa_9-y8uFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to