Trying to use a case statement with a setup.pp file that uses hiera and
parameters. We have pulled a module from the forge and are trying to make
it fit our needs.
The issue I'm trying to resolve is to have the user's home directories
created on /home/$user on Red hat systems and /export/home/$user on Solaris
nodes. So far I've tried to use a case statement based on osfamily, but I'm
getting an error.
Code:
define sysusers::setup($hash) {
if(!defined(User[$name])) {
user { $name :
case $osfamily {
'RedHat': { home => "/home/$hash[$name]['name']"}
'Solaris': { home => "/export/home/$hash[$name]['name']"}
default: { home => "/home/$hash[$name]['name']"}
}
ensure => $hash[$name]['ensure'],
comment => $hash[$name]['comment'],
expiry => $hash[$name]['expiry'],
gid => $hash[$name]['gid'],
Error:
Error: Could not retrieve catalog from remote server: Error 400 on
SERVER: Syntax error at 'osfamily'; expected '}' at
/etc/puppetlabs/puppet/environments/theblack/modules/sysusers/manifests/setup.pp:5
Module:
https://forge.puppetlabs.com/mthibaut/users
Case statement reference:
https://docs.puppetlabs.com/puppet/latest/reference/lang_conditional.html#case-statements
On Tuesday, February 10, 2015 at 4:18:05 PM UTC-5, leam hall wrote:
>
> We have a mixed environment. I wrote a module that would only do stuff on
> Red Hat family boxes. Under the class definition I put:
>
> if $::osfamily == 'RedHat' {
>
> and did all the package and file definitions under that. Is there a better
> or cleaner way to do this?
>
> Leam
>
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/1baf92e6-a26b-41f5-b5e5-040cf5035241%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.