How to use template inside of shell creates conditional check?

43 views
Skip to first unread message

hce h

unread,
Nov 2, 2014, 7:00:16 PM11/2/14
to ansible...@googlegroups.com
Hi,

The following examples gave me a syntax error, appreciate clues to use template inside creates statement.

shell: "cp /tmp/{{ my_server }}.crt /etc/{{ my_server }}.crt"
args:
  creates: /etc/{{ my_server }}.crt

Thank you.

Kind regards,

- j

Matt Martz

unread,
Nov 2, 2014, 8:44:38 PM11/2/14
to ansible...@googlegroups.com
It might help to actually state what the "syntax error" is.

Also what version of ansible are you using?
--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/587031e4-c442-4f9d-9ab9-d03ad86227f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Matt Martz
@sivel
sivel.net

hce h

unread,
Nov 2, 2014, 10:59:51 PM11/2/14
to ansible...@googlegroups.com
Thanks Matt, please see following comments:


On Monday, November 3, 2014 12:44:38 PM UTC+11, Matt Martz wrote:
It might help to actually state what the "syntax error" is.

ERROR: Syntax Error while loading YAML script copyCert.yml

creates: /etc/{{ my_server }}.crt
                                          ^

Also what version of ansible are you using?

 ansible-1.7-1.el6.noarch

On Sunday, November 2, 2014, hce h <jupit...@gmail.com> wrote:
Hi,

The following examples gave me a syntax error, appreciate clues to use template inside creates statement.

shell: "cp /tmp/{{ my_server }}.crt /etc/{{ my_server }}.crt"
args:
  creates: /etc/{{ my_server }}.crt

Thank you.

Kind regards,

- j

--
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 ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.

Michael DeHaan

unread,
Nov 3, 2014, 9:34:39 AM11/3/14
to ansible...@googlegroups.com
If you share the whole exception you should find it's giving you helper text telling you what to do with it.

Let us know if not.

meanwhile, it seems you are doing a local copy, which is a little curious compared to doing a remote copy (copy module).

All being said, this is the simplest possible representation:

shell: cp /tmp/{{my_server}}.crt /etc/{{my_server}}.crt creates=/etc/{{my_server}}.crt



To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/125b4c27-db91-46df-8936-56cbc846be29%40googlegroups.com.

hce h

unread,
Nov 3, 2014, 7:20:13 PM11/3/14
to ansible...@googlegroups.com
Thanks Michael, that does the trick.

Much appreciate it.
Reply all
Reply to author
Forward
0 new messages