Delay or force rending of template

Hi,

I’m attempting to render a template with a variable based on a node
attribute. The attribute is an array that’s built up across different
recipes. What I’m finding is that the rendered template doesn’t include all
the values in the attribute. It appears that the rendered template only
includes the the values that are in the attribute when the template is
rendered. So it seems like some values go into the attribute, the template
gets rendered, and then the rest of the values get put into the attribute
but the template isn’t re-rendered. I know all the correct values are
making it into the attribute because I see what I’d expect for the attribute
when editing the node with knife.

Is there some way to ensure that a template isn’t rendered until the end of
a Chef client run or to force a template to be re-rendered? I’ve tried
sending create notifications to the template resource, but that doesn’t seem
to work.

To be specific, I’m working with the sudo cookbook from
https://github.com/opscode/cookbooks/tree/master/sudo and the node attribute
I’m building up is the list of users used when rendering the template for
/etc/sudoers. So I’m ending up with a /etc/sudoers file that doesn’t
include all the usernames I’ve put into the attribute.

Thanks,
Adam

Have you tried putting the recipe that renders the template last in the run
list? Also be sure to set the action on the /etc/sudoers template to
:nothing so it doesn’t take action until the end of the chef run when all of
the :create notifications fire.

-Seth

Sent from my iPhone

On May 16, 2011, at 11:41, Adam Durana adurana@moodlerooms.com wrote:

Hi,

I’m attempting to render a template with a variable based on a node
attribute. The attribute is an array that’s built up across different
recipes. What I’m finding is that the rendered template doesn’t include all
the values in the attribute. It appears that the rendered template only
includes the the values that are in the attribute when the template is
rendered. So it seems like some values go into the attribute, the template
gets rendered, and then the rest of the values get put into the attribute
but the template isn’t re-rendered. I know all the correct values are
making it into the attribute because I see what I’d expect for the attribute
when editing the node with knife.

Is there some way to ensure that a template isn’t rendered until the end of
a Chef client run or to force a template to be re-rendered? I’ve tried
sending create notifications to the template resource, but that doesn’t seem
to work.

To be specific, I’m working with the sudo cookbook from
https://github.com/opscode/cookbooks/tree/master/sudo and the node attribute
I’m building up is the list of users used when rendering the template for
/etc/sudoers. So I’m ending up with a /etc/sudoers file that doesn’t
include all the usernames I’ve put into the attribute.

Thanks,
Adam

Thanks for the thoughts. I did originally try making sure the recipe was at
the end of the run list and that solved the problem, but it seemed a little
too fragile because someone could unknowingly break it by changing the order
or adding more to the run list. I didn't have the action defined as
:nothing for the template, so that was definitely causing a problem, but
delaying sending the create action until the end of the run didn't seem to
solve the problem either. I didn't dig too much into it, because I found
out that the problem I was trying to solve by building this attribute across
multiple recipes was a problem that I could solve with override_attributes
in multiple roles and just letting Chef merge the attributes, which it seems
to do by default.

On Mon, May 16, 2011 at 11:51 AM, Seth Chisamore schisamo@opscode.comwrote:

Have you tried putting the recipe that renders the template last in the run
list? Also be sure to set the action on the /etc/sudoers template to
:nothing so it doesn't take action until the end of the chef run when all of
the :create notifications fire.

-Seth

Sent from my iPhone

On May 16, 2011, at 11:41, Adam Durana adurana@moodlerooms.com wrote:

Hi,

I'm attempting to render a template with a variable based on a node
attribute. The attribute is an array that's built up across different
recipes. What I'm finding is that the rendered template doesn't include all
the values in the attribute. It appears that the rendered template only
includes the the values that are in the attribute when the template is
rendered. So it seems like some values go into the attribute, the template
gets rendered, and then the rest of the values get put into the attribute
but the template isn't re-rendered. I know all the correct values are
making it into the attribute because I see what I'd expect for the attribute
when editing the node with knife.

Is there some way to ensure that a template isn't rendered until the end of
a Chef client run or to force a template to be re-rendered? I've tried
sending create notifications to the template resource, but that doesn't seem
to work.

To be specific, I'm working with the sudo cookbook from https://github.com/opscode/cookbooks/tree/master/sudo
https://github.com/opscode/cookbooks/tree/master/sudo and the node
attribute I'm building up is the list of users used when rendering the
template for /etc/sudoers. So I'm ending up with a /etc/sudoers file that
doesn't include all the usernames I've put into the attribute.

Thanks,
Adam