Discussion:
[Puppet Users] Puppet and augeas - onlyif conditions; overwriting default values
Os
2010-12-29 08:07:20 UTC
Permalink
Hello,

I am still not getting warm with augeas and puppet, there are some
things I do not understand. At the moment I am trying the following:

- I want to set some kernel parameters in the /etc/sysctl.conf file
- in one puppet module, I have defined some default values for the
kernel parameters
- but for several servers I want to modify some of these values,
therefore I would like to overwrite the default value via the custom
module of these servers

Here is an fictitious example:
####################################################
1. puppet module with the default value:
####################################################
...
augeas {"default-sysctl.conf":
provider => "augeas",
context => "/files/etc/sysctl.conf",
changes => [
"set fs.aio-max-nr 1048576",
"set fs.file-max 9000",
],
notify => Exec["load-sysctl"],
onlyif => "match #comment[1] != 'MODIFY_FLAG'",
}
exec { "load-sysctl":
command => "/sbin/sysctl -p",
refreshonly => true,
}
...
####################################################
2. custom puppet module to adjust adjusted value:
####################################################
augeas {"custom-sysctl.conf":
provider => "augeas",
context => "/files/etc/sysctl.conf",
changes => [
"set fs.file-max 3000",
],
notify => Exec["load-sysctl"],
}


My problem is now the "match"-constraint. I would like to set a
comment in the /etc/sysctl.conf file to tell augeas/puppet that the
file will be configured via an other module.
So I want to match if this comment is present or not. I have tried
several combinations, at the moment I wrote the MODIFY_FLAG comment on
top of the file. But none of these worked.
When I rebuild this in augtool, it works fine:
augtool> match /files/etc/sysctl.conf/#comment[1] MODIFY_FLAG

I am using the following software:
- puppet 0.25.5
- augeas 0.7.4
- augeas-libs 0.7.4
- ruby-augeas 0.3.0

But perhaps I am doing the whole thing wrong, is there an other way to
solve this default-custom thing?
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet-***@googlegroups.com.
To unsubscribe from this group, send email to puppet-users+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Rob McBroom
2010-12-29 14:41:19 UTC
Permalink
Post by Os
But perhaps I am doing the whole thing wrong, is there an other way to
solve this default-custom thing?
Depending on how conceptually “close together” they are, you could just define the defaults in one class and have another class that inherits from it and overrides with custom changes as needed.

I've done exactly that for `sysctl.conf`, but the defaults in my case only apply to a specific group of systems. To put it another way, I don't use modules at all but if I did, the default and custom values would probably be in the same one in my particular case. Sounds like you've got them separated.

Something else I don't use is virtual resources, but maybe that would apply here? If I understood them well enough to say for sure, I'd probably use them. :)
--
Rob McBroom
<http://www.skurfer.com/>
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet-***@googlegroups.com.
To unsubscribe from this group, send email to puppet-users+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Loading...