0

I've got a puppet module that creates user accounts on linux machines.

I'm trying to override a couple settings in my config for the user's shell and home directory. And I'm getting this error:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Invalid parameter shell on Accounts::Virtual[mysql] at /etc/puppet/environments/production/modules/accounts/manifests/init.pp:70 on node solr1.jokefire.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

I have the user virtual account definitions setup this way in the account module's init.pp:

   @accounts::virtual { 'mysql':
     uid             =>  1007,
     shell           =>  '/bin/false',
     home            => '/var/lib/mysql',
     realname        =>  'mysql',
     pass            =>  'secret_hash',
    }

And this is how the virtual account definitions are setup:

# Defined type for creating virtual user accounts
#
define accounts::virtual ($uid,$realname,$pass) {

  user { $title:
    ensure            =>  'present',
    uid               =>  $uid,
    gid               =>  $title,
    shell             =>  '/bin/bash',
    home              =>  "/home/${title}",
    comment           =>  $realname,
    password          =>  $pass,
    managehome        =>  true,
    require           =>  Group[$title]
  }

  group { $title:
    gid               =>  $uid,
  }

  file { "/home/${title}":
    ensure            =>  directory,
    owner             =>  $title,
    group             =>  $title,
    mode              =>  0750,
    require           =>  [ User[$title], Group[$title] ]
  }
}

Where am I going wrong? Why can't I override these values?

1 Answers1

1

Your defined type does not have a $shell nor $home parameter.
Only $uid, $realname and $pass can currently be set.

You need to adjust it, for example like this (untested):

# Defined type for creating virtual user accounts
#
define accounts::virtual (
  $uid,
  $realname,
  $pass,
  $shell = '/bin/bash',
  $home  = "/home/${title}",
) {

  user { $title:
    ensure            =>  present,
    uid               =>  $uid,
    gid               =>  $title,
    shell             =>  $shell,
    home              =>  $home,
    comment           =>  $realname,
    password          =>  $pass,
    managehome        =>  true,
    require           =>  Group[$title]
  }

  group { $title:
    gid               =>  $uid,
  }

  file { $home:
    ensure            =>  directory,
    owner             =>  $title,
    group             =>  $title,
    mode              =>  0750,
    require           =>  [ User[$title], Group[$title] ]
  }
}

That should set the default of those parameters to the previous values.
But also allows them to be set when you declare it.

faker
  • 17,496
  • 2
  • 60
  • 70