# Delay or force rending of template

**URL:** <https://discourse.chef.io/t/delay-or-force-rending-of-template/1831>\
**Category:** Chef Infra (archive)\
**Created:** [May 16, 2011, 3:41pm UTC](https://discourse.chef.io/t/delay-or-force-rending-of-template/1831 "2011-05-16T15:41:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adam\_Durana](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@Adam\_Durana](https://discourse.chef.io/u/Adam_Durana)\
**Post date:** [May 16, 2011, 3:41pm UTC](https://discourse.chef.io/t/delay-or-force-rending-of-template/1831/1 "2011-05-16T15:41:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Seth\_Chisamore](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/seth_chisamore/32/488_2.png) [@Seth\_Chisamore](https://discourse.chef.io/u/Seth_Chisamore)\
**Post date:** [May 16, 2011, 3:51pm UTC](https://discourse.chef.io/t/delay-or-force-rending-of-template/1831/2 "2011-05-16T15:51:14Z")

</div>

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](mailto: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

---

<div class="post-metadata">

**Author:** ![Adam\_Durana](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@Adam\_Durana](https://discourse.chef.io/u/Adam_Durana)\
**Post date:** [May 16, 2011, 7:54pm UTC](https://discourse.chef.io/t/delay-or-force-rending-of-template/1831/3 "2011-05-16T19:54:44Z")

</div>

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.com](mailto:schisamo@opscode.com)wrote:

> 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](mailto: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)  
> [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
