On Tuesday, May 5, 2015 at 5:06:15 PM UTC-7, Allen Myers wrote:

> 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?
>

 The generate() function always returns a string that represents the stdout 
of the command that was run. To turn this into structured data, you could 
have your command output JSON or YAML and then use the parsejson() or 
parseyaml() functions from the puppetlabs/stdlib module:

    $myusers = parsejson(generate('/bin/sh', '-c', '/path/to/my/script.sh'))

Ref:

  https://forge.puppetlabs.com/puppetlabs/stdlib#parsejson

Hope that helps!

-Charlie

-- 
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/be92372d-600a-47cc-a92a-479ebad107ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to