How to use variable template in shell or command

29 views
Skip to first unread message

Steve Kieu

unread,
Nov 19, 2014, 1:47:50 AM11/19/14
to ansible...@googlegroups.com
Hi everyone,


I want to something like this


- name: Run the setup script
  shell: "{{ SITE_DIR }}"/setup_jibs.sh creates="{{ item }}/run_setup_jibs_DO_NOT_REMOVE.sh"

and yaml complain as it is not valid

The first after the shell: must be a value that is why. If I put something

- name: Run the setup script
  shell: cmd="{{ SITE_DIR }}"/setup_jibs.sh creates="{{ item }}/run_setup_jibs_DO_NOT_REMOVE.sh"

then yaml will be OK (noted the cmd=  ; But i guess it wont work - shell does not have that attributes cmd and takes that as a string for teh shell to execute.

How can I get that done?

Similar to the command module as well

Thanks


Michael Peters

unread,
Nov 19, 2014, 9:48:47 AM11/19/14
to ansible...@googlegroups.com
Instead of quoting each individual value, quote the whole line like this:

- name: Run the setup script
shell: "{{ SITE_DIR }}/setup_jibs.sh creates={{ item
}}/run_setup_jibs_DO_NOT_REMOVE.sh"



> --
> 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/b47ff0f9-6182-4bf4-aba3-af0bd6ab3350%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Steve Kieu

unread,
Nov 19, 2014, 7:00:16 PM11/19/14
to ansible...@googlegroups.com
Thanks will try.

Kind regards
Reply all
Reply to author
Forward
0 new messages