当我的 Puppet 代理尝试从 Puppet 服务器 (v8) 检索配置时,我看到以下错误,所有服务器均在 Redhat OS 上运行:
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Unknown variable: 'ssh_user'
该错误指的是“用户”模块中定义的自定义资源类型。
class users::virtual {
define ssh_user( $user=$name, $uid, $password, $key, $home_dir = 'home' ) {
user { $user:
ensure => present,
managehome => true,
uid => $uid,
password => $password,
home => "/${home_dir}/${user}"
}
ssh_authorized_key { "${user}_key":
key => $key,
type => "ssh-rsa",
user => $user,
}
}
define ssh_home ($home_dir = 'home') {
file { "/${home_base_dir}/${name}/.ssh":
ensure => directory,
owner => $name,
group => $name,
mode => 0700,
} ->
file { "/${home_dir}/${name}/.ssh/id_rsa":
source => "puppet:///modules/users/${name}/ssh/id_rsa",
owner => $name,
group => $name,
mode => 0600,
} ->
file { "/${home_dir}/${name}/.ssh/id_rsa.pub":
source => "puppet:///modules/users/${name}/ssh/id_rsa.pub",
owner => $name,
group => $name,
mode => 0644,
}
}
ssh_user { "myuser":
uid => 1010,
password => 'hidden',
key => "hidden",
}
}
知道为什么会发生这种情况吗?我删除了@ssh_user并尝试了$ssh_user,但看到同样的错误。