Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Well i was using the info on this:

Puppet - Any way to copy predefined custom configuration files for software on clients from the puppet master (host)?

But i need some more elaborated, because i have several Desktops and are in use by 2 or 3 users each one, so i want to make a class for copy a shortcut in his desktops.

The computers are joined to a domain, so any user can log in any desktop, and his profile is created in every desktop.

I've tryed with this:

class applink {

  file { "/home/installer/Escritorio/Workdesktop.desktop":
       owner => installer,
       group => root,
       mode => 770,
       source => "puppet://$server/files/Workdesktop.desktop"            
 }

This is only for one user called "installer", how can do this for several users?

Can i use $USER for do this? Any Thoughts?

Thank You!

share|improve this question

2 Answers 2

There are really two ways to do this: a definition or a virtual resource. I know more about definitions so that's the approach I'll describe. Read about virtual resources here, but be ready to get confused before you gain understanding.

To do this in a definition, create a manifest in your module structure to contain it; in your example it'd be in _modulepath_/applink/manifests/desktoplinks.pp

define applink::desktoplinks {
  file { "/home/$title/Escritorio/Workdesktop.desktop":
    owner => $title,
    group => root,
    source => "puppet://$server/files/Workdesktop.desktop",
  }
  # you could have others here if you wanted
}

Then to use it, you would call it with each user's name, perhaps all at once in an array:

applink::desktoplinks { [ "user1", "user2", "user3" ]: }

The trick is that the username is the "title" of the defined resource, so it is available inside the definition as $title. Read more about defined types here.

HTH

share|improve this answer

I just learned another way to do this. It's more of a syntax quirk than anything, but here you go:

file { ["/home/installer/Escritorio/Workdesktop.desktop",
        "/home/user/Escritorio/Workdesktop.desktop"]:
  owner => installer,
  group => root,
  mode => 770,
  source => "puppet://$server/files/Workdesktop.desktop"            
}

The key is specifying the title as an array instead of a string; Puppet will parse this as though you'd written the following:

file { "/home/installer/Escritorio/Workdesktop.desktop":
  owner => installer,
  group => root,
  mode => 770,
  source => "puppet://$server/files/Workdesktop.desktop"            
}
file { "/home/user/Escritorio/Workdesktop.desktop":
  owner => installer,
  group => root,
  mode => 770,
  source => "puppet://$server/files/Workdesktop.desktop"            
}

i.e., you get both File["/home/installer/Escritorio/Workdesktop.desktop"] and File["/home/user/Escritorio/Workdesktop.desktop"] bound in your configuration.

I suspect that this would work for many types of resources, but I haven't tested any other than file.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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