template source file not getting from closest role

20 views
Skip to first unread message

Steve Kieu

unread,
Dec 18, 2014, 12:46:38 AM12/18/14
to ansible...@googlegroups.com
Hi All,

I have role A and then B (dependent on A).

I have sudoers.j2 in the templates folder for each role with different content.

When a host with role B applied ansible run the task on role A and apply the source file which is not the one in templates folder of role B. Is it expected behaviour?

Thanks,


Dan Vaida

unread,
Jan 4, 2015, 10:31:19 AM1/4/15
to ansible...@googlegroups.com
What is the role dependency in your case?
Depending on how your roles are written+called this can be expected (i.e. the file gets templated by role B and then overwritten by A).
Share your code if you need more help.

Steve Kieu

unread,
Jan 4, 2015, 6:12:21 PM1/4/15
to ansible...@googlegroups.com
Hi,

Thanks . As I wrote, B is dependent (a child) of role A. 

In B task there is no template module called with source is sudoer2.j2. A has one like this so when a host has role B - the first role A is called and that template module is called. But it does not use the source sudoer2.j2 located in role B templates folder. it uses the source file from the templates folder of role A.

At the moment I have to put the template module in role B tasks and that is called twice - role A with role A templates source and then role B with role B template source. The end result is OK but because each repeated run - role A sees that the file has changed (because the source of B templates is different from A) then it templates it again, and then B does the same.

So end result is also OK but the template module always run!

The expected behaviour are:

* We do not need to call the template task on role B.
* If in role B templates folder has the source file, then when the template task in role A is called it should use the source file from the template folder of role B because it is closer role to the target host.


cheers





--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/7hC3qZ1VwJU/unsubscribe.
To unsubscribe from this group and all its topics, 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/aec5625f-f348-4c04-bff1-1b9f778dc052%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Steve Kieu
Reply all
Reply to author
Forward
0 new messages