Use client-side file as input for Puppet

asked 2016-07-15 09:01:10 -0500

Eleix gravatar image

I am stuck on trying to figure out how to use files that exist on clients to use inside of a variable for navigating to the users home directory to check if a file exists.

This is currently what I have

#Grab username of the user at the console and use their home directory
exec { 'grab_user':
        command => '/usr/bin/stat -f "%Su" /dev/console > /tmp/puppetexec',

$username = undef,

exec { 'check_user':
        command => '/bin/echo "Some custom error message" > /tmp/puppeterror',
        onlyif => '/bin/test -e /Users/"${username}"/Google\ /Drive/',

I am trying to use the username stored in puppetexec on the client to fill in the blanks for the search since all the users for the clients come from AD however not every user will be created on each computer.

edit retag flag offensive close merge delete


Trying to understand what your end goal for this. Do you want to create users local account(non-AD)? And users will not be created on some computer?

lupin gravatar imagelupin ( 2016-07-15 13:17:05 -0500 )edit

No, the end goal is to be able to set up symlinks where OSX normally looks for Desktop, documents, music, videos, etc.. inside of the google drive folder as those would then be synced to the cloud, this helps when devices need to be replaced and the user doesn't have to change their habits.

Eleix gravatar imageEleix ( 2016-07-15 16:21:53 -0500 )edit

Like what I want is to be able to have Puppet to first look at the user's home, check if Google Drive exists, then check if this user had already had the links created and if not do that. I already know how I will perform the second part but this is the only one that I'm being hung up on.

Eleix gravatar imageEleix ( 2016-07-15 16:23:55 -0500 )edit

Is there a reason why you're not using a custom fact instead for this?

Alex Harvey gravatar imageAlex Harvey ( 2016-07-16 08:04:48 -0500 )edit

Mostly because I don't understand Ruby well enough, I was hoping puppet would have already had something that would have worked built into it. I'll take a try at creating a custom fact.

Eleix gravatar imageEleix ( 2016-07-16 08:16:29 -0500 )edit