Add a file to /etc/profile.d/
with the suffix .sh
. It will be sourced as part of /etc/profile in Red Hat and Debian and derivatives, can't say on other distros. Generally speaking, if at all possible, it's better to add snippets rather than replace distributed files as it tends to be more future safe.
So in puppet, the following would do:
file { "/etc/profile.d/set_java_home.sh":
ensure => present,
source => ...[whatever's appropriate for your setup]...,
...
}
This what you're looking for or do you need more detail?
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
If you want to set the shell of an existing user, simply do:
If you want to set the shell of whatever user Puppet is happening to run as, you can make use of the
$id
fact which returns the name of the current user. This feels a little bit magical to me, and may result in undesired outcomes, like if you're running as thepuppet
user with apuppet agent
run and you end up setting a shell for a user that shouldn't have interactive logins.That would be done like:
Note: the "ensure => present" is optional.