override values in puppet account creation

35 views
Skip to first unread message

Tim Dunphy

unread,
Jan 23, 2016, 12:22:27 PM1/23/16
to puppet...@googlegroups.com
Hey guys,

 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?

--
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B

Lowe Schmidt

unread,
Jan 23, 2016, 1:15:17 PM1/23/16
to puppet...@googlegroups.com
you probably need to lift up the parameters to the define. 

something like 

´´´´
define accounts::virtual ($uid, $realname, $pass, $shell='/bin/bash') {... }
´´´´

It's been awhile since I did program in puppet, but that should be a start.


--
Lowe Schmidt | +46 723 867 157

--
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 puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CAOZy0ekGSusExu6fP03HA-%2BY2iPmCaMgv%2B7%3Dkr6V%2BCBOHS%3DH9Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Martin Alfke

unread,
Jan 23, 2016, 2:28:03 PM1/23/16
to puppet...@googlegroups.com

You need to specify all attributes of the resource type usage as parameters at the define:

accounts::virtual { ‘mysql’:
uid => ‘…’,
shell => ‘…'
home => ‘…’,
realname => ‘…’,
pass => ‘…’,
}

define accounts::virtual (
$uid,
$shell => ‘…’,
$home => ‘…’,
$realname => ‘…’,
$pass => ‘…',
){
…
}

Parameters within the define will be attributes on define declaration.

Best,
Martin
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CAC-wWcSzshwerCyVLSJMYP3_kS%2BxftCjRkERc-mwd0O2JEiwZg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages