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

Phe*_*ezy 8 puppet

我试图让 puppet 为虚拟用户分配授权的 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
Run Code Online (Sandbox Code Playgroud)

我相信我的配置是正确的(如下所列),但是否存在我遗漏的语法错误或范围问题?我只想将用户分配给节点,并让这些用户自动安装他们的 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" }
Run Code Online (Sandbox Code Playgroud)

wom*_*ble 15

你在virtual.pp.


jti*_*man 7

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

  • 这是我想出的最简单的方法。在我寻求帮助或其他方法的任何地方,我都被告知“使用 LDAP”,只有 10 个用户无法回答,因为我们没有在其他任何地方使用 LDAP,*而且*必须支持 3 个物理站点。 (3认同)