# Create template from library method?

**URL:** <https://discourse.chef.io/t/create-template-from-library-method/3021>\
**Category:** Chef Infra (archive)\
**Created:** [August 1, 2012, 8:59pm UTC](https://discourse.chef.io/t/create-template-from-library-method/3021 "2012-08-01T20:59:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wes\_Morgan](https://avatars.discourse-cdn.com/v4/letter/w/3be4f8/32.png) [@Wes\_Morgan](https://discourse.chef.io/u/Wes_Morgan)\
**Post date:** [August 1, 2012, 8:59pm UTC](https://discourse.chef.io/t/create-template-from-library-method/3021/1 "2012-08-01T20:59:48Z")

</div>

Hey Chefs,

I have a method in a library (I know, I know, I need to convert it to an LWRP–one day) that creates a template. It looks like this:

> <https://gist.github.com/cap10morgan/3230347>

When it gets run, I see "Giving [user] root access to MySQL server in the Chef log, but the template file never gets created.

When I run the same template block with a normal template resource in a recipe, it works.

Anyone know why it’s not creating the template?

Wes

---

<div class="post-metadata">

**Author:** ![bbaugher](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@bbaugher](https://discourse.chef.io/u/bbaugher)\
**Post date:** [August 1, 2012, 9:10pm UTC](https://discourse.chef.io/t/create-template-from-library-method/3021/2 "2012-08-01T21:10:15Z")

</div>

Since you are not using the template dsl and instead are creating a  
template object I would imagine you would still need to tell it to run.

[http://wiki.opscode.com/display/chef/Evaluate+and+Run+Resources+at+Compile+Time](http://wiki.opscode.com/display/chef/Evaluate+and+Run+Resources+at+Compile+Time)

On Wed, Aug 1, 2012 at 3:59 PM, Wes Morgan [cap10morgan@gmail.com](mailto:cap10morgan@gmail.com) wrote:

> Hey Chefs,
> 
> I have a method in a library (I know, I know, I need to convert it to an  
> LWRP–one day) that creates a template. It looks like this:
> 
> [Template from library method · GitHub](https://gist.github.com/3230347)
> 
> When it gets run, I see "Giving [user] root access to MySQL server in the  
> Chef log, but the template file never gets created.
> 
> When I run the same template block with a normal template resource in a  
> recipe, it works.
> 
> Anyone know why it's not creating the template?
> 
> Wes

--  
-Bryan

---

<div class="post-metadata">

**Author:** ![Wes\_Morgan](https://avatars.discourse-cdn.com/v4/letter/w/3be4f8/32.png) [@Wes\_Morgan](https://discourse.chef.io/u/Wes_Morgan)\
**Post date:** [August 1, 2012, 9:20pm UTC](https://discourse.chef.io/t/create-template-from-library-method/3021/3 "2012-08-01T21:20:18Z")

</div>

That makes an enormous amount of sense. Thanks!

Wes

On Aug 1, 2012, at 3:10 PM, Bryan Baugher [bjbq4d@gmail.com](mailto:bjbq4d@gmail.com) wrote:

> Since you are not using the template dsl and instead are creating a template object I would imagine you would still need to tell it to run.
> 
> [http://wiki.opscode.com/display/chef/Evaluate+and+Run+Resources+at+Compile+Time](http://wiki.opscode.com/display/chef/Evaluate+and+Run+Resources+at+Compile+Time)
> 
> On Wed, Aug 1, 2012 at 3:59 PM, Wes Morgan [cap10morgan@gmail.com](mailto:cap10morgan@gmail.com) wrote:  
> Hey Chefs,
> 
> I have a method in a library (I know, I know, I need to convert it to an LWRP–one day) that creates a template. It looks like this:
> 
> [Template from library method · GitHub](https://gist.github.com/3230347)
> 
> When it gets run, I see "Giving [user] root access to MySQL server in the Chef log, but the template file never gets created.
> 
> When I run the same template block with a normal template resource in a recipe, it works.
> 
> Anyone know why it's not creating the template?
> 
> Wes
> 
> --  
> -Bryan
