Hi,
I have shell script that generates a hash of user accounts that need to be
created/maintained
by puppet. In my manifest I'm calling it using the generate() function:
$myusers = generate ('/bin/sh', '-c', '/path/to/my/script.sh')
The output of the script looks like:
{ 'user1' => { name => 'user1', ensure => present, gid
=> xxxx, home => '/home/user1', managehome => true, purge_ssh_keys =>
true, shell => '/bin/bash',}, 'user2' => { name => 'user2', ensure =>
present, gid => xxxx, home => '/home/user2', managehome => true,
purge_ssh_keys => true, shell => '/bin/bash',},}
then I call create_resources as
create_resources (user, $myusers)
and when I run 'puppet agent --test' on the client I get
Error: Could not retrieve catalog from remote server: Error
400 on SERVER: create_resources(): second argument must be a hash at
/etc/puppet/environments/mgmt/manifests/01-all-nodes.pp:38 on node server1
If I comment out the create_resources and add the line
validate_hash ($myusers)
then it fails with
Error: Could not retrieve catalog from remote server:
Error 400 on SERVER: "{ 'user1' => { name => 'user1', ensure => present,
gid => xxxx, home => '/home/user1', managehome => true, purge_ssh_keys
=> true, shell => '/bin/bash',}, 'user2' => { name => 'user2', ensure =>
present, gid => xxxx, home => '/home/user2', managehome => true,
purge_ssh_keys => true, shell => '/bin/bash',},}" is not a Hash. It
looks to be a String at
/etc/puppet/environments/mgmt/manifests/01-all-nodes.pp:38 on node server1
Yet, if I take the output of the script and just put it directly into the
manifest, it works fine; ie,
$myusers = { 'user1' => { name => 'user1', ensure =>
present, gid => xxxx, home => '/home/user1', managehome => true,
purge_ssh_keys => true, shell => '/bin/bash',}, 'user2' => { name =>
'user2', ensure => present, gid => xxxx, home => '/home/user2',
managehome => true, purge_ssh_keys => true, shell => '/bin/bash',},}
create_resources (user, $myusers)
and it works.
So, based on the error messages, it's obvious that the generate() function
is returning the string data type. Can I force it to return the hash data
type?
Or is there a way to convert a string to a hash?
Thanks!
- Allen
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/97b582e9-7955-4865-897f-8900ca13cb12%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.