[Puppet Users] Virtual Resources with variables

Douglas Brancaglion
Tue, 21 Aug 2012 19:01:19 -0000

Hi!

I am facing difficulties in using the virtual resource types in resorce
custom, I have a definition of user creation as shown below:

define add_user ( $email, $uid, $key, $groups ) {

            $username = $title

            user { $username:
                    comment    => "$email",
                    groups     => $groups,
                    managehome => true,
                    home       => "/home/$username",
                    shell      => "/bin/bash",
                    uid        => $uid
            }


            file { "/home/$username/":
                    ensure  => directory,
                    owner   => $username,
                    group   => $username,
                    mode    => 700,
                    require => [ user[$username] ]
            }

            file { "/home/$username/.ssh":
                    ensure  => directory,
                    owner   => $username,
                    group   => $username,
                    mode    => 700,
                    require => file["/home/$username/"]
            }


            # now make sure that the ssh key authorized files is around
            file { "/home/$username/.ssh/authorized_keys":
                    ensure  => present,
                    owner   => $username,
                    group   => $username,
                    mode    => 600,
                    require => file["/home/$username/"]
            }

            ssh_authorized_key{ "${username}":
                    ensure  => present,
                    type    => "ssh-rsa",
                    user    => $username,
                    key     => $key,

            }

    }

And in my users manifests I declare this way:

        @add_user { test:
                 email   => "user test",
                 uid     => 1040,
                 groups  => apache,
 key  =>
"AAAAB3NzaC1yc2EAAAADAQfTRr6mUam1rIiwWhseaRP9M83L2NXFBMix4d7q1xkO/bMqCvvRPjzVzQNGhEJFn8Pjz2pr+QcK2c2yqceSTpbVoxM8Gg5/dXwKv+ct4qKjLVtSty8s/VW8g+kI3N5R9Xv1SG7exJdutKfEnoCGY4lXjrU11fvCZq5Zrc5",
        }

and in my node i declare this way:

import "custom_resource"
import "users_manifests"

node "server01.domain" {

realize User[test]
}

but i receive that error message:
err: Could not retrieve catalog from remote server: Error 400 on SERVER:
Failed to realize virtual resources User[dbrancaglion]

Sorry duplicate message, my browser crashed!!

Can help me?

Tks!
--
Douglas Brancaglion
Security Analist