alter PATH for all tasks running on a specific host group?

29 views
Skip to first unread message

Alex Peters

unread,
May 16, 2015, 10:55:03 PM5/16/15
to ansible...@googlegroups.com
I have a couple playbooks that apply to a number of host groups, one group having /sbin (among other things) missing from its hosts' PATHs.

This means that the playbooks run correctly on most hosts, but not the hosts in that particular group.

I realise that I can alter the playbooks' affected tasks to manually set the PATH using the environment parameter.  This solution is not ideal though because it's addressing an issue relevant to the group, not the playbooks themselves.

I'd prefer to somehow have this information in a group var only.  Is it possible to define a group var that causes the hosts in that group to have a modified PATH when running tasks?  Do other solutions exist to this problem?

Brian Coca

unread,
May 18, 2015, 8:21:42 AM5/18/15
to ansible...@googlegroups.com
try

environment: "{{mysettings}}"

where mysettings is a group var
> --
> 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/91f386a7-914f-4b57-9838-e99d4b7cb67e%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca

Alex Peters

unread,
Jul 5, 2015, 4:19:22 AM7/5/15
to ansible...@googlegroups.com
I appreciate the suggestion, but this would still require modifying every task in every role that applies to this particular host group.

Is there any way to influence the environment of a host or host group without resorting to such per-task modifications?

Brian Coca

unread,
Jul 5, 2015, 8:06:03 AM7/5/15
to ansible...@googlegroups.com

It can be set at play level.

Reply all
Reply to author
Forward
0 new messages