How can I have puppet deploy ssh keys for virtual users?

Posted by Pheezy on Server Fault See other posts from Server Fault or by Pheezy
Published on 2009-08-26T02:47:03Z Indexed on 2010/04/20 16:54 UTC
Read the original article Hit count: 448

Filed under:

I am trying to get puppet to assign authorized ssh keys for virtual users but I keep getting the following error:

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

I believe my configuration are correct (listed below) but is there a syntax error or scoping issue I am missing? I would simply like to assign users to nodes and have those users automagically have their ssh keys installed. Is there maybe a better way to do this and I'm just overthinking it?

# /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" }

© Server Fault or respective owner

Related posts about puppet