create_resources função e fantoche ENC

1

/etc/puppet/manifests/classes/users.pp

class users
{
define add_user($uname, $comment, $home, $shell, $uid, $gid, $password)
{


# Create the user. This is where most of the magic happens.
user { "$uname":
username => $uname,
ensure => present,
comment => "$comment",
home => "$home",
shell => "$shell",
uid => "$uid",
password => "$password",
gid => "$gid"
}


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

# And a place with the right permissions for the SSH related configs
file { "/home/$uname/.ssh":
ensure => directory,
owner => $uname,
group => $gid,
mode => 700,
require => file["/home/$uname/"]
}


# Now make sure that the ssh key authorized files is around

file { "/home/$uname/.ssh/authorized_keys":
ensure => present,
owner => $uname,
group => $gid,
mode => 600,
require => file["/home/$uname/.ssh"]
}

}
create_resources(users::add_user, $users)

}

/etc/puppet/manifests/site.pp

"classes/*.pp"
node default{}

saída yaml do ENC

---
classes:
  users:
    jeckman:
      comment: Jack
      gid: 100
      home: /home/jeckman
      name: jeckman
      password: $1$hash
      shell: /bin/bash
      uid: 10146
    saga:
      comment: Arun
      gid: 100
      home: /home/saga
      name: saga
      password: $1$hash
      shell: /bin/bash
      uid: 70960
    sandipb:
      comment: Sandip
      gid: 100
      home: /home/sandipb
      name: sandipb
      password: $1$hash
      shell: /bin/bash
      uid: 24838
    vartika:
      comment: Vartika
      gid: 100
      home: /home/vartika
      name: vartika
      password: $1$hash
      shell: /bin/bash
      uid: 38599

Ao tentar compilá-lo

saga@battleoffer-dr ~]$ sudo puppet master --compile=darkguard-dr.eglbp.corp.company.com --debug --verbose                    
    info: Not using expired node for darkguard-dr.eglbp.corp.company.com from cache; expired at Thu Jul 19 01:21:25 +0530 2012     
    debug: Executing '/etc/puppet/manifests/enc/puppet_enc.py darkguard-dr.eglbp.corp.company.com'                                 
    info: Caching node for darkguard-dr.eglbp.corp.company.com                                                                     
    debug: importing '/etc/puppet/manifests/classes/users.pp' in environment production                                          
    warning: Deprecation notice:  Resource references should now be capitalized on line 29 in file /etc/puppet/manifests/classes/
    users.pp                                                                                                                     
    warning: Deprecation notice:  Resource references should now be capitalized on line 38 in file /etc/puppet/manifests/classes/
    users.pp                                                                                                                     
    warning: Deprecation notice:  Resource references should now be capitalized on line 49 in file /etc/puppet/manifests/classes/
    users.pp                                                                                                                     
    err: Invalid parameter sandipb on node darkguard-dr.eglbp.corp.company.com
    Invalid parameter sandipb on node darkguard-dr.eglbp.corp.company.com

O que estou fazendo de errado?

    
por zer0c00l 18.07.2012 / 22:32

2 respostas

1

Cara, seu 'require = > recurso 'está errado.

requerem recursos são chamados com a primeira letra CAPS, como Arquivo, Usuário .. não arquivo, usuário.

    
por 19.07.2012 / 15:57
0

Eu imagino que o usuário variável $ contém hash incorreto fazer

  file {'/tmp/users.yaml':
         content => inline_template("<%= dbq %><%= YAML::dump(users) %>"),
    }

e examine a saída. Deveria se parecer com:

jeckman:
  comment: Jack
  gid: 100
  home: /home/jeckman
  name: jeckman
  password: $1$hash
  shell: /bin/bash
  uid: 10146
saga:
  comment: Arun
  gid: 100
  home: /home/saga
  name: saga
  password: $1$hash
  shell: /bin/bash
  uid: 70960    

se isso não acontecer, você está passando um mau hash

você pode querer tentar:

create_resources(users::add_user, $users['users'])
    
por 12.09.2013 / 18:16

Tags