FAQ
Hi All,

I would like to use puppet for deploying Jboss application.

The property file of my Jboss app need to be evaluated before moving in the
conf dir as it's a template.

How could I make this kind of operation with native resources of puppet.


*Example :*

I have this file *myapp.properties.tmpl* :

ApplicationName=${MY_APP_NAME}
ApplicationVersion=${MY_APP_VERSION}
...


And I have the file *global.properties* :

${MY_APP_NAME}=helloworld
${MY_APP_VERSION}=1.0.0


I would like to replace variables in myapp.properties.tmpl with the right
value in global.properties and generate the new file *myapp.properties* with

ApplicationName=helloworld
ApplicationVersion=1.0.0

Is that possible, may be with tools like Augeas?

Suggestions ????
Thanks

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/gwkHUwM26QYJ.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Search Discussions

  • Dominic Cleal at Aug 14, 2012 at 8:21 pm

    On 14/08/12 18:18, Rost wrote:
    Hi All,

    I would like to use puppet for deploying Jboss application.

    The property file of my Jboss app need to be evaluated before moving in
    the conf dir as it's a template.

    How could I make this kind of operation with native resources of puppet.


    *Example :*

    I have this file *myapp.properties.tmpl* :

    ApplicationName=${MY_APP_NAME}
    ApplicationVersion=${MY_APP_VERSION}
    ...


    And I have the file *global.properties* :

    ${MY_APP_NAME}=helloworld
    ${MY_APP_VERSION}=1.0.0
    This here feels like you're not solving the actual problem, but working
    around a bug elsewhere in your design.
    I would like to replace variables in myapp.properties.tmpl with the
    right value in global.properties and generate the new file
    *myapp.properties* with

    ApplicationName=helloworld
    ApplicationVersion=1.0.0

    Is that possible, may be with tools like Augeas?
    The first thing you need is to get the data ("helloworld", "1.0.0") into
    Puppet. Ideally via an ENC or hiera or similar.

    If it only exists on the filesystem of the host at the start of a run
    and you really must, you could use a fact, but you're going into weird
    territory as your system build will then depend on the existing state of
    the system. Definitely an anti-pattern here, but possible.

    You can use Augeas in facts, but only the properties lens as it exists
    in master (rather than the 0.9.0 release) can parse that
    global.properties file. Something like this:

    http://pastie.org/4475806
    http://projects.puppetlabs.com/projects/facter/wiki/Facter_Augeas

    Or do something similar in Ruby to pull the value out of the file on the
    host and present it in a fact.

    Once you have the value in Puppet, then creating or editing
    myapp.properties with Augeas is trivial, or use a template:

    augeas { "myapp.properties":
    lens => "Properties.lns",
    incl => "/path/to/myapp.properties",
    changes => [
    "set ApplicationName ${appname}",
    "set ApplicationVersion ${appversion}",
    ],
    }

    (Where $appname and $appversion are Puppet variables, facts or a proper
    data source.)

    Cheers,

    --
    Dominic Cleal
    Red Hat Consulting
    m: +44 (0)7817 878113

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Rost at Aug 14, 2012 at 11:58 pm
    thks

    Le mardi 14 août 2012 22:21:04 UTC+2, Dominic Cleal a écrit :
    On 14/08/12 18:18, Rost wrote:
    Hi All,

    I would like to use puppet for deploying Jboss application.

    The property file of my Jboss app need to be evaluated before moving in
    the conf dir as it's a template.

    How could I make this kind of operation with native resources of puppet.


    *Example :*

    I have this file *myapp.properties.tmpl* :

    ApplicationName=${MY_APP_NAME}
    ApplicationVersion=${MY_APP_VERSION}
    ...


    And I have the file *global.properties* :

    ${MY_APP_NAME}=helloworld
    ${MY_APP_VERSION}=1.0.0
    This here feels like you're not solving the actual problem, but working
    around a bug elsewhere in your design.
    I would like to replace variables in myapp.properties.tmpl with the
    right value in global.properties and generate the new file
    *myapp.properties* with

    ApplicationName=helloworld
    ApplicationVersion=1.0.0

    Is that possible, may be with tools like Augeas?
    The first thing you need is to get the data ("helloworld", "1.0.0") into
    Puppet. Ideally via an ENC or hiera or similar.

    If it only exists on the filesystem of the host at the start of a run
    and you really must, you could use a fact, but you're going into weird
    territory as your system build will then depend on the existing state of
    the system. Definitely an anti-pattern here, but possible.

    You can use Augeas in facts, but only the properties lens as it exists
    in master (rather than the 0.9.0 release) can parse that
    global.properties file. Something like this:

    http://pastie.org/4475806
    http://projects.puppetlabs.com/projects/facter/wiki/Facter_Augeas

    Or do something similar in Ruby to pull the value out of the file on the
    host and present it in a fact.

    Once you have the value in Puppet, then creating or editing
    myapp.properties with Augeas is trivial, or use a template:

    augeas { "myapp.properties":
    lens => "Properties.lns",
    incl => "/path/to/myapp.properties",
    changes => [
    "set ApplicationName ${appname}",
    "set ApplicationVersion ${appversion}",
    ],
    }

    (Where $appname and $appversion are Puppet variables, facts or a proper
    data source.)

    Cheers,

    --
    Dominic Cleal
    Red Hat Consulting
    m: +44 (0)7817 878113
    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/j8t3iTOJjNoJ.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedAug 14, '12 at 5:18p
activeAug 14, '12 at 11:58p
posts3
users2
websitepuppetlabs.com

2 users in discussion

Rost: 2 posts Dominic Cleal: 1 post

People

Translate

site design / logo © 2022 Grokbase