我试图让木偶为虚拟用户分配授权的SSH密钥,但我不断收到以下错误:
err: Could not retrieve catalog: Could not parse for environment production: Syntax error at 'user'; expected '}' at /etc/puppet/modules/users/manifests/ssh_authorized_keys.pp:9
我相信我的configuration是正确的(下面列出),但有一个语法错误或范围问题我缺less? 我只想将用户分配给节点,并让这些用户自动安装其ssh密钥。 有没有更好的方法来做到这一点,我只是在推翻它?
# /etc/puppet/modules/users/virtual.pp class user::virtual { @user { "user": home => "/home/user", ensure => "present", groups => ["root","wheel"], uid => "8001", password => "SCRAMBLED", comment => "User", shell => "/bin/bash", managehome => "true", } # /etc/puppet/modules/users/manifests/ssh_authorized_keys.pp ssh_authorized_key { "user": ensure => "present", type => "ssh-dss", key => "AAAAB....", user => "user", } # /etc/puppet/modules/users/init.pp import "users.pp" import "ssh_authorized_keys.pp" class user::ops inherits user::virtual { realize( User["user"], ) } # /etc/puppet/manifests/modules.pp import "sudo" import "users" # /etc/puppet/manifests/nodes.pp node basenode { include sudo } node 'testbox' inherits basenode { include user::ops } # /etc/puppet/manifests/site.pp import "modules" import "nodes" # The filebucket option allows for file backups to the server filebucket { main: server => 'puppet' } # Set global defaults - including backing up all files to the main filebucket and adds a global path File { backup => main } Exec { path => "/usr/bin:/usr/sbin/:/bin:/sbin" }
你在virtual.pp结尾缺less一个大括号。
这是我一年前为一位前雇主pipe理用户而编写的一个傀儡模块 。
是的,有更好的办法,这正是定义的目的。 你可以创build一个名为“ssh_user”的定义,制作该types的虚拟用户,然后实现这些定义。 Josh的代码使用了我正在讨论的定义,但是您也可以在定义中添加ssh_authorized_key,并使用define中的variables进行参数化。
我强烈build议使用Puppet语法突出显示来避免这种情况。