OS X Home Directory path - username substitution

16 views
Skip to first unread message

Luis Zuniga

unread,
Jun 7, 2016, 1:16:06 PM6/7/16
to Puppet Users
Hi,

Wondering how to substitute the OS X username into the manifest document.

Here are the details:

On the OS X client:

Username is user1

on the puppet server:

sites.pp file:

file { "/Users/$identity['user']/Applications/mpbar/myscript.sh":
        ensure => 'file',
        owner => 'user1',
        group => 'staff',
        mode => '0755',
        source => "puppet:///modules/mymodule/myscript.sh",
        backup => 'false',
}

If I hard code 'user1' everything works but when I try to substitute the username from the agent I get all the key pairs from identity and not just the user name (user1):

/Users/{gid => 20, group => staff, uid => 504, user => user1}['user']/Applications/mpbar/myscript.sh

I've tried $identity.user as well with no luck.

Any advice on how I can get the local OS X username passed into the sites.pp file so this works properly?

Appreciate any help.

Luis
 

Luis Zuniga

unread,
Jun 7, 2016, 1:50:29 PM6/7/16
to Puppet Users
Got it to work like this:

$myuser = $identity['user']
$mygroup = $identity['group']

file { "/Users/${myuser}/Applications/mpbar/mpdbar.sh":
        ensure => 'file',
        owner => $myuser,
        group => $mygroup,
        mode => '0755',
        source => "puppet:///modules/mybarmodule/mpdbar.sh",
        backup => 'false',
}
Reply all
Reply to author
Forward
0 new messages