>> On Jun 17, 2016, at 9:50 AM, Edward Ned Harvey (puppet)
>> <[email protected]> wrote:
>>
>> From: [email protected] [mailto:puppet-
>> [email protected]] On Behalf Of Peter Bukowinski
>>
>> Hi Edward,
>>
>> With puppet 3.7, all facts are "stringified" by default, meaning hashes are
>> flattened to strings. If you've got facter 2.0 or greater, you can change
>> this
>> behavior do you can access hash keys individually.
>
> Thanks very much for the help. Unfortunately, I'm learning, and working, in
> an environment with several hundred machines in production using puppet. I
> can't really expect to upgrade or reconfigure the environment. All I'm trying
> to do is ensure some ssh files exist in a particular user's home directory,
> so I thought I would use $facts to determine if the user exists, and get
> their home directory path, and create the files in there.
>
> Is there a way to parse the $os string into a hash, so I can access its
> members? (Besides wanting to access users' home directories, it would also be
> useful to just get the OS major number, for a different purpose.) I tried
> parsejson(), but it doesn't like the => instead of :, and it didn't seem
> right to substitute : for =>. I figured there *should* be a way to parse the
> string the right way.
>
> If not via $facts, how else would puppet put some files into a user's home
> directory?
Fortunately, facter has separate facts for most items in the os fact hash. Keep
in mind you can see all the facts available to your client by running ‘sudo
facter -p’. Here are the facts you can use to directly access some of the facts
in the os hash.
# facter os
{"name"=>"Ubuntu", "family"=>"Debian", "release"=>{"major"=>"13.10",
"full"=>"13.10"}, "lsb"=>{"distcodename"=>"saucy", "distid"=>"Ubuntu",
"distdescription"=>"Ubuntu 13.10", "distrelease"=>"13.10",
"majdistrelease"=>"13.10”}}
# facter osfamily
Debian
# facter lsbmajdistrelease
13.10
# facter lsbdistcodename
saucy
The easiest way to install files into a particular user’s home directory (if
the path to that directory is consistent across all your machines) is to create
a package that does it for you. Then you can use puppet to ensure that the
package is installed without it having to worry about the particulars.
--
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/55109213-7A87-4BA1-8705-137BA3F0D072%40gmail.com.
For more options, visit https://groups.google.com/d/optout.