"Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."
Bill Waterson (Calvin & Hobbes)
--
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 puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/7fe782a1-fba4-4cef-aeab-4cf85ed170d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi
You should not define it twice. You use it twice.
As in your example the apache uses the firewall define. It does not define the file resource again.
Define managed_preference in a class that you'll use as a library and use that in the modules that need it.
Note the resources using the define
each have their own name
Neil
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/f0f84a30-7fd5-4cef-a74e-6735b6f70734%40googlegroups.com.
Thanks Neil,I am not sure I understand exactly what you mean, so I will post the code I have done for testing (I am using different paths, but the concept is the same as the original post).Here is the class with the define. It is in a module called copy_directory.class copy_directory {}define managed_preferences ($source = undef) {file {"/tmp/":source => "puppet:///modules/${source}/tmp",recurse => true,owner => "root",group => "root",mode => 600,}}Here is the module that calls it.include copy_directoryclass test_module {managed_preferences { 'title':source => "$module_name",}}I also created a module called test_module2 with the same code. I know that file {"/tmp/": is causing the problem, but the entire point is different modules copy files into that directory. To me I'm defining it once, and using it twice. As I defined it in the copy_directory module, and I am using it in the test_module and test_module2. What am I doing wrong?
--
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 puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/99ac011e-153b-4675-825f-575fd81bf911%40googlegroups.com.
Thanks Neil,
In yours and Johns example you both have ${title} at the end of Preferences. When I tried this (after his post, I haven't tried your code yet), I ended up with a folder called Preferences/office_2011 which defeats the purpose of what I am trying to do. Am I misunderstanding that line?
I understand why two modules can't manage the same folder (from a Puppet perspective) but was thinking that all of my modules would send a list of files to the one module that had the ability to write to that folder and it would work.
I really appreciate everyone trying to help me, but I guess there is something that I am not understanding, or perhaps I am not explaining myself properly. If I have a variable after Preferences (which I need to prevent the duplicate resource) then how do I get all of my files into the root of that Preference folder?
I apologize if your code works the way I am asking, but if it does, then I don't understand what the variable is doing after the word Preference and could use some clarification on that. Also, what is the $components variable mean? Is that a type of function or feature that I can read up on in the documentation?
I did the following to see if it would work, and I got (for me anyway) a surprising result. It may be the source of some of my confusion and reason why I'm finding this so difficult. Note, I don't want to do this this way. I just did it as an experiment.define mac_managed_preferences ($source) {include managed_preferencesfile { "/System/Library/User Template/English.lproj/Library/Preferences/${source}" :source => "puppet:///modules/${source}/Preferences/",owner => "root",group => "wheel",mode => "600",recurse => "true",}exec { "Move Preferences":command => "mv $source/* ../Preferences/",path => "/bin",cwd => "/System/Library/User Template/English.lproj/Library/Preferences/",require => File["/System/Library/User Template/English.lproj/Library/Preferences/${source}"],}exec { "Delete Folder":command => "rm -rf $source",path => "/bin/",cwd => "/System/Library/User Template/English.lproj/Library/Preferences/",require => Exec["Move Preferences"],}}Here is the relevant portion of the module that installs the application.mac_managed_preferences { "$module_name":source => "$module_name",}I got an error: Duplicate declaration [Move Preferences] is already declared in file (path to managed_preferences file) cannot redeclare at (path to same file). In my previous posts I said that I though that I accessed the module multiple times, but declared it once, but this message is making me understand that puppet says I was declaring it multiple times, but I am unsure how.
file { "/System/Library/User Template/English.lproj/Library/Preferences/${source}" : # the source is the file from the line directly below, this seems true as the correct files copy when I have only
No its just not like that
$source would need to be defined in or passed to the scope your file resource is in.
It does not refer to the source parameter to the file resource itself.
To try and get back on the right track i suggest you try just putting two files in place one from each calling class.
I really don't think a recursive directory is what you want. And I don't think having two of them will ever work.
You should be specifying the names of the individual files.
Please post your complete code
Neil
--
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 puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/3cc68ae9-046b-4c7c-b039-ec4234fb95dd%40googlegroups.com.
file { "/System/Library/User Template/English.lproj/Library/Preferences/${source}" : # the source is the file from the line directly below, this seems true as the correct files copy when I have only
No its just not like that
$source would need to be defined in or passed to the scope your file resource is in.
It does not refer to the source parameter to the file resource itself.
To try and get back on the right track i suggest you try just putting two files in place one from each calling class.
I really don't think a recursive directory is what you want. And I don't think having two of them will ever work.
You should be specifying the names of the individual files.
Neil and John,You guys both agree on using individual files and I was thinking of how I could do this. If I have one file or three, it may not be a big deal to do individually, but some applications could need dozens or more.I don't know if it is possible, some searching makes me believe it isn't, but I'll share my thought.Can you do something like a for loop in a bash script. So it would be something like...
for files in .../module_name/Preferences/ # get a list of files and folders in the Preferences subfolder on the Puppet Masterfile { '/System/Library/User Template/English.lproj/Library/Preferences/${files}': #Directory on Puppet agent, the variable would make this a unique resource and it would work for a file and foldersource => "puppet:///modules/${module_name}/Preferences/${files}", # Since it is looping every file on the Puppet Master would match perfectly to the same exact file/folder on the agent. No duplicate declaration.doneJohn,I think I understand what your code is trying to do, but am not sure I understand how to implement. I think that $preference_sources is making a list of paths (puppet paths) to the Preferences folder of each module,
and I know that sourceselect all means that it will use all sources instead of stopping at the first match. I also see that the preferences_sources is being created from a regex expression that I don't completely understand, though that shouldn't matter in getting this to work.Is this still a defined type?
Should class mac_managed_preferences be defined
or are we making a new class for each applications preferences (assuming that's the $applications variable in the class name)?