FAQ
Dear all,

I'm trying to figure out how to do this - first copy a "common" file to
every node and then modify the file according to the node type. I've tried
this:


if $node_type == 'wn' {
$port = '8649'
$desc = 'Worker Nodes'
}

exec {
'n_desc':
command => "sed -ic '/cluster {/,/}/s/name = \"[^\"]*\"/name =
\"\'\"$desc\"\'\"/' '$fname'",
subscribe => File["$fname"],
refreshonly => false;

'n_port':
command => "sed -ic '/port\ =\ /{s:[0-9]*$:$port:g}' '$fname'",
subscribe => File["$fname"],
refreshonly => false;
}

file {
'gmond.conf':
name => "$fname",
source => 'puppet:///modules/ganglia/gmond.conf',
require => Exec['n_desc','n_port'],
notify => Service['gmond'];
}

The problem is the *Exec['n_desc','n_port'] *is being executed but then it
changing back to the original one as supplied by: *source =>
'puppet:///modules/ganglia/gmond.conf'*, which is definitely not what I
want. How can I make sure it copy the file first and then make the changes?
Or, simply how do I do that? Cheers!!

--
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/-/9XQhRACkvOEJ.
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

  • Denmat at May 22, 2012 at 8:03 am
    Hi,

    I think templates would be easier to manage in this setup.

    http://docs.puppetlabs.com/learning/templates.html

    It will give good flexibility. It the way I have managed my ganglia setup.

    Cheers,
    Den
    On 22/05/2012, at 7:33, Sans wrote:

    Dear all,

    I'm trying to figure out how to do this - first copy a "common" file to every node and then modify the file according to the node type. I've tried this:


    if $node_type == 'wn' {
    $port = '8649'
    $desc = 'Worker Nodes'
    }

    exec {
    'n_desc':
    command => "sed -ic '/cluster {/,/}/s/name = \"[^\"]*\"/name = \"\'\"$desc\"\'\"/' '$fname'",
    subscribe => File["$fname"],
    refreshonly => false;

    'n_port':
    command => "sed -ic '/port\ =\ /{s:[0-9]*$:$port:g}' '$fname'",
    subscribe => File["$fname"],
    refreshonly => false;
    }

    file {
    'gmond.conf':
    name => "$fname",
    source => 'puppet:///modules/ganglia/gmond.conf',
    require => Exec['n_desc','n_port'],
    notify => Service['gmond'];
    }


    The problem is the Exec['n_desc','n_port'] is being executed but then it changing back to the original one as supplied by: source => 'puppet:///modules/ganglia/gmond.conf', which is definitely not what I want. How can I make sure it copy the file first and then make the changes? Or, simply how do I do that? Cheers!!
    --
    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/-/9XQhRACkvOEJ.
    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.
    --
    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.
  • Sans at May 22, 2012 at 8:45 am
    Yes, I did think about using template one point.
    So, do you generate the entire file using "template"? For us, it's just a
    few lines to change in the default gmod.conf file.

    cheers,
    San

    On Tuesday, May 22, 2012 9:02:59 AM UTC+1, denmat wrote:

    Hi,

    I think templates would be easier to manage in this setup.

    http://docs.puppetlabs.com/learning/templates.html

    It will give good flexibility. It the way I have managed my ganglia setup.

    Cheers,
    Den

    On 22/05/2012, at 7:33, Sans wrote:

    Dear all,

    I'm trying to figure out how to do this - first copy a "common" file to
    every node and then modify the file according to the node type. I've
    tried this:


    if $node_type == 'wn' {
    $port = '8649'
    $desc = 'Worker Nodes'
    }

    exec {
    'n_desc':
    command => "sed -ic '/cluster {/,/}/s/name = \"[^\"]*\"/name =
    \"\'\"$desc\"\'\"/' '$fname'",
    subscribe => File["$fname"],
    refreshonly => false;

    'n_port':
    command => "sed -ic '/port\ =\ /{s:[0-9]*$:$port:g}' '$fname'",
    subscribe => File["$fname"],
    refreshonly => false;
    }

    file {
    'gmond.conf':
    name => "$fname",
    source => 'puppet:///modules/ganglia/gmond.conf',
    require => Exec['n_desc','n_port'],
    notify => Service['gmond'];
    }

    The problem is the *Exec['n_desc','n_port'] *is being executed but then
    it changing back to the original one as supplied by: *source =>
    'puppet:///modules/ganglia/gmond.conf'*, which is definitely not what I
    want. How can I make sure it copy the file first and then make the changes?
    Or, simply how do I do that? Cheers!!

    --
    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/-/9XQhRACkvOEJ.
    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.
    --
    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/-/YE5OjdOlY3oJ.
    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.
  • Denmat at May 22, 2012 at 9:48 am
    Yep. Templates are just normal files that go through the ERB parser so you can make adjustments on the fly. And it appears you are trying to push out the file anyway (using the source => param) so it seems like a good fit to me.

    Cheers
    Den
    On 22/05/2012, at 18:45, Sans wrote:

    Yes, I did think about using template one point.
    So, do you generate the entire file using "template"? For us, it's just a few lines to change in the default gmod.conf file.

    cheers,
    San


    On Tuesday, May 22, 2012 9:02:59 AM UTC+1, denmat wrote:
    Hi,

    I think templates would be easier to manage in this setup.

    http://docs.puppetlabs.com/learning/templates.html

    It will give good flexibility. It the way I have managed my ganglia setup.

    Cheers,
    Den
    On 22/05/2012, at 7:33, Sans wrote:

    Dear all,

    I'm trying to figure out how to do this - first copy a "common" file to every node and then modify the file according to the node type. I've tried this:


    if $node_type == 'wn' {
    $port = '8649'
    $desc = 'Worker Nodes'
    }

    exec {
    'n_desc':
    command => "sed -ic '/cluster {/,/}/s/name = \"[^\"]*\"/name = \"\'\"$desc\"\'\"/' '$fname'",
    subscribe => File["$fname"],
    refreshonly => false;

    'n_port':
    command => "sed -ic '/port\ =\ /{s:[0-9]*$:$port:g}' '$fname'",
    subscribe => File["$fname"],
    refreshonly => false;
    }

    file {
    'gmond.conf':
    name => "$fname",
    source => 'puppet:///modules/ganglia/gmond.conf',
    require => Exec['n_desc','n_port'],
    notify => Service['gmond'];
    }


    The problem is the Exec['n_desc','n_port'] is being executed but then it changing back to the original one as supplied by: source => 'puppet:///modules/ganglia/gmond.conf', which is definitely not what I want. How can I make sure it copy the file first and then make the changes? Or, simply how do I do that? Cheers!!
    --
    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/-/9XQhRACkvOEJ.
    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.
    --
    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/-/YE5OjdOlY3oJ.
    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.
    --
    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.
  • Jo Rhett at May 22, 2012 at 10:10 am
    Use a template instead. Then you can install the file already modified for the host.
    On May 21, 2012, at 2:33 PM, Sans wrote:
    I'm trying to figure out how to do this - first copy a "common" file to every node and then modify the file according to the node type. I've tried this:


    if $node_type == 'wn' {
    $port = '8649'
    $desc = 'Worker Nodes'
    }

    exec {
    'n_desc':
    command => "sed -ic '/cluster {/,/}/s/name = \"[^\"]*\"/name = \"\'\"$desc\"\'\"/' '$fname'",
    subscribe => File["$fname"],
    refreshonly => false;

    'n_port':
    command => "sed -ic '/port\ =\ /{s:[0-9]*$:$port:g}' '$fname'",
    subscribe => File["$fname"],
    refreshonly => false;
    }

    file {
    'gmond.conf':
    name => "$fname",
    source => 'puppet:///modules/ganglia/gmond.conf',
    require => Exec['n_desc','n_port'],
    notify => Service['gmond'];
    }


    The problem is the Exec['n_desc','n_port'] is being executed but then it changing back to the original one as supplied by: source => 'puppet:///modules/ganglia/gmond.conf', which is definitely not what I want. How can I make sure it copy the file first and then make the changes? Or, simply how do I do that? Cheers!!

    --
    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/-/9XQhRACkvOEJ.
    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.
    --
    Jo Rhett
    Net Consonance : net philanthropy to improve open source and internet projects.



    --
    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.
  • Sans at May 22, 2012 at 12:01 pm
    Thanks Den, Jo! I did it using template() now.

    Cheers,
    San

    On Tuesday, May 22, 2012 11:10:39 AM UTC+1, Jo wrote:

    Use a template instead. Then you can install the file already modified
    for the host.

    On May 21, 2012, at 2:33 PM, Sans wrote:

    I'm trying to figure out how to do this - first copy a "common" file to
    every node and then modify the file according to the node type. I've
    tried this:


    if $node_type == 'wn' {
    $port = '8649'
    $desc = 'Worker Nodes'
    }

    exec {
    'n_desc':
    command => "sed -ic '/cluster {/,/}/s/name = \"[^\"]*\"/name =
    \"\'\"$desc\"\'\"/' '$fname'",
    subscribe => File["$fname"],
    refreshonly => false;

    'n_port':
    command => "sed -ic '/port\ =\ /{s:[0-9]*$:$port:g}' '$fname'",
    subscribe => File["$fname"],
    refreshonly => false;
    }

    file {
    'gmond.conf':
    name => "$fname",
    source => 'puppet:///modules/ganglia/gmond.conf',
    require => Exec['n_desc','n_port'],
    notify => Service['gmond'];
    }

    The problem is the *Exec['n_desc','n_port'] *is being executed but then
    it changing back to the original one as supplied by: *source => '
    puppet:///modules/ganglia/gmond.conf'*, which is definitely not what I
    want. How can I make sure it copy the file first and then make the changes?
    Or, simply how do I do that? Cheers!!

    --
    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/-/9XQhRACkvOEJ.
    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.


    --
    Jo Rhett
    Net Consonance : net philanthropy to improve open source and internet
    projects.




    On Tuesday, May 22, 2012 11:10:39 AM UTC+1, Jo wrote:

    Use a template instead. Then you can install the file already modified
    for the host.

    On May 21, 2012, at 2:33 PM, Sans wrote:

    I'm trying to figure out how to do this - first copy a "common" file to
    every node and then modify the file according to the node type. I've
    tried this:


    if $node_type == 'wn' {
    $port = '8649'
    $desc = 'Worker Nodes'
    }

    exec {
    'n_desc':
    command => "sed -ic '/cluster {/,/}/s/name = \"[^\"]*\"/name =
    \"\'\"$desc\"\'\"/' '$fname'",
    subscribe => File["$fname"],
    refreshonly => false;

    'n_port':
    command => "sed -ic '/port\ =\ /{s:[0-9]*$:$port:g}' '$fname'",
    subscribe => File["$fname"],
    refreshonly => false;
    }

    file {
    'gmond.conf':
    name => "$fname",
    source => 'puppet:///modules/ganglia/gmond.conf',
    require => Exec['n_desc','n_port'],
    notify => Service['gmond'];
    }

    The problem is the *Exec['n_desc','n_port'] *is being executed but then
    it changing back to the original one as supplied by: *source => '
    puppet:///modules/ganglia/gmond.conf'*, which is definitely not what I
    want. How can I make sure it copy the file first and then make the changes?
    Or, simply how do I do that? Cheers!!

    --
    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/-/9XQhRACkvOEJ.
    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.


    --
    Jo Rhett
    Net Consonance : net philanthropy to improve open source and internet
    projects.




    On Tuesday, May 22, 2012 11:10:39 AM UTC+1, Jo wrote:

    Use a template instead. Then you can install the file already modified
    for the host.

    On May 21, 2012, at 2:33 PM, Sans wrote:

    I'm trying to figure out how to do this - first copy a "common" file to
    every node and then modify the file according to the node type. I've
    tried this:


    if $node_type == 'wn' {
    $port = '8649'
    $desc = 'Worker Nodes'
    }

    exec {
    'n_desc':
    command => "sed -ic '/cluster {/,/}/s/name = \"[^\"]*\"/name =
    \"\'\"$desc\"\'\"/' '$fname'",
    subscribe => File["$fname"],
    refreshonly => false;

    'n_port':
    command => "sed -ic '/port\ =\ /{s:[0-9]*$:$port:g}' '$fname'",
    subscribe => File["$fname"],
    refreshonly => false;
    }

    file {
    'gmond.conf':
    name => "$fname",
    source => 'puppet:///modules/ganglia/gmond.conf',
    require => Exec['n_desc','n_port'],
    notify => Service['gmond'];
    }

    The problem is the *Exec['n_desc','n_port'] *is being executed but then
    it changing back to the original one as supplied by: *source => '
    puppet:///modules/ganglia/gmond.conf'*, which is definitely not what I
    want. How can I make sure it copy the file first and then make the changes?
    Or, simply how do I do that? Cheers!!

    --
    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/-/9XQhRACkvOEJ.
    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.


    --
    Jo Rhett
    Net Consonance : net philanthropy to improve open source and internet
    projects.




    On Tuesday, May 22, 2012 11:10:39 AM UTC+1, Jo wrote:

    Use a template instead. Then you can install the file already modified
    for the host.

    On May 21, 2012, at 2:33 PM, Sans wrote:

    I'm trying to figure out how to do this - first copy a "common" file to
    every node and then modify the file according to the node type. I've
    tried this:


    if $node_type == 'wn' {
    $port = '8649'
    $desc = 'Worker Nodes'
    }

    exec {
    'n_desc':
    command => "sed -ic '/cluster {/,/}/s/name = \"[^\"]*\"/name =
    \"\'\"$desc\"\'\"/' '$fname'",
    subscribe => File["$fname"],
    refreshonly => false;

    'n_port':
    command => "sed -ic '/port\ =\ /{s:[0-9]*$:$port:g}' '$fname'",
    subscribe => File["$fname"],
    refreshonly => false;
    }

    file {
    'gmond.conf':
    name => "$fname",
    source => 'puppet:///modules/ganglia/gmond.conf',
    require => Exec['n_desc','n_port'],
    notify => Service['gmond'];
    }

    The problem is the *Exec['n_desc','n_port'] *is being executed but then
    it changing back to the original one as supplied by: *source => '
    puppet:///modules/ganglia/gmond.conf'*, which is definitely not what I
    want. How can I make sure it copy the file first and then make the changes?
    Or, simply how do I do that? Cheers!!

    --
    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/-/9XQhRACkvOEJ.
    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.


    --
    Jo Rhett
    Net Consonance : net philanthropy to improve open source and internet
    projects.


    --
    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/-/b-8CWQ3AQmcJ.
    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
postedMay 21, '12 at 9:33p
activeMay 22, '12 at 12:01p
posts6
users3
websitepuppetlabs.com

3 users in discussion

Sans: 3 posts Denmat: 2 posts Jo Rhett: 1 post

People

Translate

site design / logo © 2022 Grokbase