The only trickiness that I'm aware of is in the file
resource type.
Backup for replaced files behaves differently, using the server's filebucket by default instead of the local filebucket.
The more significant thing to be aware of is the source
parameter.
source => '/tmp/somepath/sshd_config',
With a raw file path, it'll always try the local path.
source => 'puppet://puppetmaster1/modules/sshd/sshd_config',
With a puppet://server/
path, it'll always try the remote path.
source => 'puppet:///modules/sshd/sshd_config',
With an empty server specification, then it gets interesting.
Applied locally, the local puppet module path is used to find the file.
When reporting to a puppetmaster, the server that gave it the manifest is treated as the server.
Additionally, if you need to get creative about the source of a file, you can give the source
parameter a list:
source => [ '/tmp/somepath/sshd_config', 'puppet:///modules/sshd/sshd_config'],
The first location where something's found will be used.
Specific answer: Immediately speaking, you're calling sysctl::value, but value isn't declared in your sysctl class. See this example that uses a sysctl::conf declaration. Without the define value
, there is no sysctl::value subclass for you to call.
General answer and guidance: The Augeas construct (see also its type reference documentation) that is part of current versions of Puppet allows maintaining lines in a configuration file and even respects context, so it can manage files such as a git configuration. The example below is both to demonstrate functionality and to point you to a great reference collection of Puppet configs -- the live configuration store for Wikipedia servers.
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = https://gerrit.wikimedia.org/r/p/operations/puppet
[branch "production"]
remote = origin
merge = refs/heads/production
One simple example from the above configuration documentation would be this:
augeas { "sshd_config":
context => "/files/etc/ssh/sshd_config",
changes => [
"set PermitRootLogin no",
],
}
So, if you want to manage your /etc/sysctl.conf, enter the following:
augeas { "sysctl":
context => "/files/etc/sysctl.conf",
changes => [
"set kernel.sysrq = 0",
#and whatever other lines are interesting to you
],
}
The Augeas example also has a construct for a sysctl class based on Augeus that is similar to what you posted in your question, so that may also shed some light.
Best Answer
I would use a template. Set your file resource to use content instead of source:
Then have the template substitute the hostname. The template would be located in the templates subdirectory of your module:
You can also use fqdn or something else.
Official documentation: https://puppet.com/docs/puppet/latest/lang_template.html