我有一个在Linux机器上创build用户帐户的puppet模块。
我想重写我的configuration中的用户的shell和主目录的几个设置。 我得到这个错误:
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
我在帐户模块的init.pp中以这种方式设置了用户虚拟帐户定义:
@accounts::virtual { 'mysql': uid => 1007, shell => '/bin/false', home => '/var/lib/mysql', realname => 'mysql', pass => 'secret_hash', }
这就是如何设置虚拟帐户定义:
# 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] ] } }
我哪里错了? 为什么我不能重写这些值?
您定义的types没有$ shell或$ home参数。
目前只能设置$ uid,$ realname和$ pass。
您需要调整它,例如像这样(未经testing):
# 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] ] } }
这应该将这些参数的默认值设置为以前的值。
但也可以让你在宣布时设置它们。