Ask Your Question
0

create_resources get hash from lookup for the users data

asked 2017-06-06 11:07:25 -0600

pabolitox gravatar image

Hi, I am trying to create a module where users should be defined in hiera, and code users create_resource

init.pp

class ipxusers (
  $users = lookup({ name => 'ipxusers:users', value_type => Hash, default_value => 'undef' }),
)
{
  unless $users == 'undef' {
    notify { 'test':
      message => "users: ${users}"
    }
    create_resources(user, $users)
  }
}

I have the hiera file correctly set up I think

#nfs declare home server
nfs::nfs_home_server: 'stagelog'
ipxusers::users:
  pab:
    ensure: absent
    uid: 500
    comment: Pa Gar

but the puppet agent output is not god. User is not created altough the message I added into the class print the users values

[root@stagejenkins01 ~]# puppet agent -tv --environment=temp
Info: Using configured environment 'temp'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for stagejenkins01.ipx.com
Info: Applying configuration version '1496765082'
Notice: users: {pab => {ensure => absent, uid => 500, comment => Pa Gar}}
Notice: /Stage[main]/Ipxusers/Notify[test]/message: defined 'message' as 'users: {pab => {ensure => absent, uid => 500, comment => Pa Gar}}'
Notice: Applied catalog in 5.54 seconds

anyone can help me please to see what is wrong in here?

Regards

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-06-06 15:51:34 -0600

DarylW gravatar image

In the configuration above, you have ensure => absent, It may not be doing anything because the user doesn't exist, and it's not removing a non-existent user. If you set ensure to present, it should work.

You can also always put on the --debug flag to see it either verify that the user doesn't exist, or anything else related to it

edit flag offensive delete link more

Comments

shame on me! as I am learning I got so much into debugging the hiera lookup I just added that I forgot to check the basics. ensure => absent Thanks fo the help. and for the --debug tips I did not know . next time it could safe me 3 hours breaking my head against a wall :)

pabolitox gravatar imagepabolitox ( 2017-06-07 03:18:39 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-06-06 11:07:25 -0600

Seen: 109 times

Last updated: Jun 06