ansible looking for templates in previous role

47 views
Skip to first unread message

Kathy L

unread,
Oct 26, 2023, 7:22:21 AM10/26/23
to Ansible Project
Good morning.  I have two roles in a multi-role playbook, for yum, then chrony. The yum module works fine, but the chrony playbook fails on copying a template.  The odd thing is, the error I get indicates ansible is looking in the yum module for chrony's template.  here is the specific error message;

Could not find or access chrony.conf.j2
Searched in:
     /work/roles/yum/templates/chrony.conf.j2
     /work/roles/yum/chrony.conf.j2
    /work/roles/yum/tasks/chrony.conf.j2
   /work/templates/etc.chrony.conf.j2

Why is it searching in the yum role for a chrony template?  The template is in /work/roles/chrony/templates/chrony.conf.j2. 

Rowe, Walter P. (Fed)

unread,
Oct 26, 2023, 7:45:45 AM10/26/23
to 'Rowe, Walter P. (Fed)' via Ansible Project
Please provide the code that is executing the roles.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/299d557e-58a9-4807-a9e1-a874db4bd387n%40googlegroups.com.

Todd Lewis

unread,
Oct 26, 2023, 9:32:36 AM10/26/23
to ansible...@googlegroups.com, uto...@gmail.com
Hi Kathy,

Files, templates, plugins, etc. that live in various local roles aren't available to your playbook tasks until those roles are accessed, for example through the roles: playbook keyword or import_role or include_role.

From your description, it appears that you've accessed your yum role but not your chrony role at the point you tried to use your etc.chrony.conf.j2 template.
--
Todd

Kathy L

unread,
Oct 26, 2023, 3:31:06 PM10/26/23
to Ansible Project
Walter - Unfortunately I can't provide the code as this is on a client's off-line network.  Todd, I'll look again at when I use the chrony tasks. 

Rowe, Walter P. (Fed)

unread,
Oct 26, 2023, 3:35:09 PM10/26/23
to ansible...@googlegroups.com
You would only call the chrony role. Something like this.

- include_role:
    name: yum_role.yaml

- include_role:
    name: chrony_role.yaml

The role would use the template module which should find the template in the chrony role's templates folder.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123
--
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.

Brian Coca

unread,
Oct 27, 2023, 11:15:45 AM10/27/23
to ansible...@googlegroups.com
You can just post a simple reproducer, from what you posted I can only
vaguely guess that you are using the 2nd role tasks as tasks and not
as a role.

On Thu, Oct 26, 2023 at 3:31 PM Kathy L <lyon...@gmail.com> wrote:
>
> Walter - Unfortunately I can't provide the code as this is on a client's off-line network. Todd, I'll look again at when I use the chrony tasks.
>


--
----------
Brian Coca

Kathy L

unread,
Oct 30, 2023, 10:48:05 AM10/30/23
to Ansible Project
What I did today was to remove mitogen and run it with "normal" ssh and it did not have that problem.  That makes it a mitogen problem I think. I'll find a bug report with them. I should have thought of this earlier.  Thanks for all the help.

Vladimir Botka

unread,
Oct 30, 2023, 11:17:40 AM10/30/23
to Kathy L, ansible...@googlegroups.com
> On Friday, October 27, 2023 at 11:15:45 AM UTC-4 Brian Coca wrote:
>
> > You can just post a simple reproducer, from what you posted I can only
> > vaguely guess that you are using the 2nd role tasks as tasks and not
> > as a role.

On Mon, 30 Oct 2023 07:48:05 -0700 (PDT)
Kathy L <lyon...@gmail.com> wrote:

> What I did today was to remove mitogen and run it with "normal" ssh and it
> did not have that problem. That makes it a mitogen problem I think. I'll
> find a bug report with them.

Post a simple reproducer here before you file the issue. Included or
depending role might be causing the problem. This might be an issue
with Ansible. See https://stackoverflow.com/a/76994183/6482561


--
Vladimir Botka

Terry Bowling

unread,
Oct 30, 2023, 12:04:57 PM10/30/23
to ansible...@googlegroups.com, Lyon...@gmail.com
Hello Kathy,
I cannot answer the template question, but for configuring Chrony, have you considered using the RHEL System Roles.timesync role (or it's upstream project linux-system-roles)?

Here is a bunch of really good info on how it helps to abstract and simply RHEL/linux management.


--
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.

Brian Coca

unread,
Oct 30, 2023, 12:34:38 PM10/30/23
to ansible...@googlegroups.com
This is how resolution should work in Ansible
https://docs.ansible.com/ansible/latest/playbook_guide/playbook_pathing.html#resolving-local-relative-paths,
if this is not what you are seeing, then file a bug with a simple
reproducer w/o mitogen. We do not support mitogen patch as it does
alter some base functionality in backwards incompatible ways, any
issues with mitogen can be address at it's own issue site.



--
----------
Brian Coca

Reply all
Reply to author
Forward
0 new messages