Changing the token delimiters inside the templates


#1

Hi all -

Is there a way to change the token delimiters chef uses inside the
templates to some other format?

Just curious - this would make my life 300% easier if this were true…


#2

Chef is using standard Ruby ERB for templates - http://ruby-doc.org/stdlib-1.8.7/libdoc/erb/rdoc/ERB.html

On Dec 21, 2012, at 10:41 PM, Maven User wrote:

Hi all -

Is there a way to change the token delimiters chef uses inside the templates to some other format?

Just curious - this would make my life 300% easier if this were true…


#3

On Friday, December 21, 2012 at 12:53 PM, Vladimir Girnet wrote:

Chef is using standard Ruby ERB for templates - http://ruby-doc.org/stdlib-1.8.7/libdoc/erb/rdoc/ERB.html

On Dec 21, 2012, at 10:41 PM, Maven User wrote:

Hi all -

Is there a way to change the token delimiters chef uses inside the templates to some other format?

Just curious - this would make my life 300% easier if this were true…

Chef actually uses erubis which is mostly compatible but has some extra features:
http://www.kuwata-lab.com/erubis/users-guide.html

If you’re looking to, say, include a literal <% in your output, according to the docs this can be done with <%%.

The docs also explain how to change the “embedding pattern” but chef doesn’t expose any way to change it:

http://www.kuwata-lab.com/erubis/users-guide.02.html#tut-pattern


Daniel DeLeo


#4

Yeah, I’d REALLY like to teach chef how to use ${}'s instead of <%>'s

Daniel - thank you!

On Fri, Dec 21, 2012 at 4:09 PM, Daniel DeLeo dan@kallistec.com wrote:

On Friday, December 21, 2012 at 12:53 PM, Vladimir Girnet wrote:

Chef is using standard Ruby ERB for templates -
http://ruby-doc.org/stdlib-1.8.7/libdoc/erb/rdoc/ERB.html

On Dec 21, 2012, at 10:41 PM, Maven User wrote:

Hi all -

Is there a way to change the token delimiters chef uses inside the
templates to some other format?

Just curious - this would make my life 300% easier if this were true…

Chef actually uses erubis which is mostly compatible but has some extra
features:
http://www.kuwata-lab.com/erubis/users-guide.html

If you’re looking to, say, include a literal <% in your output,
according to the docs this can be done with <%%.

The docs also explain how to change the “embedding pattern” but chef
doesn’t expose any way to change it:

http://www.kuwata-lab.com/erubis/users-guide.02.html#tut-pattern


Daniel DeLeo


#5

NVM - I’m going to make maven understand erb syntax instead (for one
module).

http://maven.apache.org/plugins/maven-resources-plugin/copy-resources-mojo.html

${*} @

(I think :slight_smile:

On Fri, Dec 21, 2012 at 5:10 PM, Maven User maven.2.user@gmail.com wrote:

Yeah, I’d REALLY like to teach chef how to use ${}'s instead of <%>'s

Daniel - thank you!

On Fri, Dec 21, 2012 at 4:09 PM, Daniel DeLeo dan@kallistec.com wrote:

On Friday, December 21, 2012 at 12:53 PM, Vladimir Girnet wrote:

Chef is using standard Ruby ERB for templates -
http://ruby-doc.org/stdlib-1.8.7/libdoc/erb/rdoc/ERB.html

On Dec 21, 2012, at 10:41 PM, Maven User wrote:

Hi all -

Is there a way to change the token delimiters chef uses inside the
templates to some other format?

Just curious - this would make my life 300% easier if this were true…

Chef actually uses erubis which is mostly compatible but has some extra
features:
http://www.kuwata-lab.com/erubis/users-guide.html

If you’re looking to, say, include a literal <% in your output,
according to the docs this can be done with <%%.

The docs also explain how to change the “embedding pattern” but chef
doesn’t expose any way to change it:

http://www.kuwata-lab.com/erubis/users-guide.02.html#tut-pattern


Daniel DeLeo


#6

Can Chef use the tilt library for handling templates, or does it
exclusively use ERB?

Jeremy

On Fri, Dec 21, 2012 at 2:11 PM, Maven User maven.2.user@gmail.com wrote:

NVM - I’m going to make maven understand erb syntax instead (for one
module).

http://maven.apache.org/plugins/maven-resources-plugin/copy-resources-mojo.html

${*} @

(I think :slight_smile:

On Fri, Dec 21, 2012 at 5:10 PM, Maven User maven.2.user@gmail.comwrote:

Yeah, I’d REALLY like to teach chef how to use ${}'s instead of <%>'s

Daniel - thank you!

On Fri, Dec 21, 2012 at 4:09 PM, Daniel DeLeo dan@kallistec.com wrote:

On Friday, December 21, 2012 at 12:53 PM, Vladimir Girnet wrote:

Chef is using standard Ruby ERB for templates -
http://ruby-doc.org/stdlib-1.8.7/libdoc/erb/rdoc/ERB.html

On Dec 21, 2012, at 10:41 PM, Maven User wrote:

Hi all -

Is there a way to change the token delimiters chef uses inside the
templates to some other format?

Just curious - this would make my life 300% easier if this were true…

Chef actually uses erubis which is mostly compatible but has some
extra features:
http://www.kuwata-lab.com/erubis/users-guide.html

If you’re looking to, say, include a literal <% in your output,
according to the docs this can be done with <%%.

The docs also explain how to change the “embedding pattern” but chef
doesn’t expose any way to change it:

http://www.kuwata-lab.com/erubis/users-guide.02.html#tut-pattern


Daniel DeLeo


#7

It’s easy. Simply create your own resource like bundled Chef template.

Implementation may be copied from Chef’s template. It can be placed ever in
cookbook.

2012/12/22 Jeremy Voorhis jvoorhis@gmail.com

Can Chef use the tilt library for handling templates, or does it
exclusively use ERB?

Jeremy

On Fri, Dec 21, 2012 at 2:11 PM, Maven User maven.2.user@gmail.comwrote:

NVM - I’m going to make maven understand erb syntax instead (for one
module).

http://maven.apache.org/plugins/maven-resources-plugin/copy-resources-mojo.html

${*} @

(I think :slight_smile:

On Fri, Dec 21, 2012 at 5:10 PM, Maven User maven.2.user@gmail.comwrote:

Yeah, I’d REALLY like to teach chef how to use ${}'s instead of <%>'s

Daniel - thank you!

On Fri, Dec 21, 2012 at 4:09 PM, Daniel DeLeo dan@kallistec.com wrote:

On Friday, December 21, 2012 at 12:53 PM, Vladimir Girnet wrote:

Chef is using standard Ruby ERB for templates -
http://ruby-doc.org/stdlib-1.8.7/libdoc/erb/rdoc/ERB.html

On Dec 21, 2012, at 10:41 PM, Maven User wrote:

Hi all -

Is there a way to change the token delimiters chef uses inside the
templates to some other format?

Just curious - this would make my life 300% easier if this were true…

Chef actually uses erubis which is mostly compatible but has some
extra features:
http://www.kuwata-lab.com/erubis/users-guide.html

If you’re looking to, say, include a literal <% in your output,
according to the docs this can be done with <%%.

The docs also explain how to change the “embedding pattern” but chef
doesn’t expose any way to change it:

http://www.kuwata-lab.com/erubis/users-guide.02.html#tut-pattern


Daniel DeLeo


#8

Hi All,

I have started to learn about the new AWS tool called CloudFormation.
All seems good and pretty working, however some points are still unclear, here is the one for instance:

  • while I see a lot of examples which make use of Chef-Solo (or download cookbook from Chef server) to bootstrap the instance as part of launching the new “Stack” from AWS console ,
    I wonder if its possible to use it opposite way: bootstrap the instance of an appropriate “Role” and, as the role dependency, launch the CloudFormation Stack (or a relevant part of it, say for security group or/and the keys ) via Chef, using knife or similar.
    … Assuming there should be a Chef helper to interact with AWS CloudFormation API
    Does anyone have such usage example ?

#9

Michael,

The correct workflow here would be to use CloudFormation to launch Chef
Server/chef-solo to bootstrap with a role.

The other way around is not possible to do with knife as per my knowledge,
and I would be glad to be proven wrong here. Knife has a ec2 plugin which
lets you create instances etc, but not call cloudformation api directly.

What is possible though it calling Cloudformation API directly from the
role you create http://aws.amazon.com/documentation/cloudformation/

Thanks
Gourav
Initcron | www.initcron.com

On Sun, Dec 23, 2012 at 10:13 PM, Michael Leikind bigmyx@gmail.com wrote:

… Assuming there should be a Chef helper to interact with AWS
CloudFormation API


#10

CloudFormation expects to control all of the resources that you launch with
it, so what you’re asking for is an ordering of events that it doesn’t
accommodate.

The specific workflow that you’re talking about when you say “bootstrap the
instance of an appropriate “Role” and, as the role dependency, launch the
CloudFormation Stack (or a relevant part of it, say for security group
or/and the keys )” is problematic anyway. Specifically in AWS your ec2
instance is assigned to a group or list of groups when you request it’s
creation and before it is allocated. The assigned group/groups can’t be
changed once the instance is launched.

-Peter

On Sun, Dec 23, 2012 at 11:43 AM, Michael Leikind bigmyx@gmail.com wrote:

Hi All,

I have started to learn about the new AWS tool called CloudFormation.
All seems good and pretty working, however some points are still unclear,
here is the one for instance:

  • while I see a lot of examples which make use of Chef-Solo (or download
    cookbook from Chef server) to bootstrap the instance as part of launching
    the new “Stack” from AWS console ,
    I wonder if its possible to use it opposite way: bootstrap the instance of
    an appropriate “Role” and, as the role dependency, launch the
    CloudFormation Stack (or a relevant part of it, say for security group
    or/and the keys ) via Chef, using knife or similar.
    … Assuming there should be a Chef helper to interact with AWS
    CloudFormation API
    Does anyone have such usage example ?