0

I am using puppet, what I am trying to write script that create file related to the user who run it. lets say I want to create the file/soft link if not exist so other application can edit it, then move it to archive.

file { '/some/path/myuser.file':
    ensure => 'link',     -- ensure => 'file', if I want to create file
    target => '/orignal/path/file',
     }

Note: myuser should be edited by the actual user who ran the script
If I make the script fixed like below it will work without any issue:

file { '/some/path/aabuhasna.file':
        ensure => 'link',  -- ensure => 'file', if I want to create file
        target => '/orignal/path/file',
         }
1

There is core fact within puppet called id, which "return the user identifier (UID) of the user running facter.": https://docs.puppet.com/facter/latest/core_facts.html#id

So it should be possible to simply use:

file { "/some/path/${id}":
  ensure => 'link',
  target => '/original/path/file',
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.