我如何让p为虚拟用户部署ssh密钥?


8

我试图让人偶为虚拟用户分配授权的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

我相信我的配置是正确的(在下面列出),但是我缺少语法错误或范围界定问题吗?我只想将用户分配给节点,并让这些用户自动安装其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" }

Answers:



7

这是我一年前编写的一个人偶模块,用于管理前雇主的用户。


这看起来太复杂了……
SamK 2011年

3
这是我想到的最简单的方法。我到处寻求帮助或其他方法的地方都被告知“使用LDAP”,这仅适用于10个用户,因为我们没有在其他任何地方使用LDAP,因此必须支持3个物理站点。
jtimberman

3

是的,有更好的方法,这正是定义的目的。您将创建一个称为“ ssh_user”的定义,使该类型的虚拟用户生效,然后实现这些定义。Josh的代码使用了我正在谈论的定义,但是您还将在定义中添加ssh_authorized_key,并使用该定义中的变量对其进行参数化。


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.