On Monday, September 22, 2014 4:51:38 PM UTC-5, [email protected] wrote:
>
> 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_preferences
>
> file { "/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.
>
Multiple declaration is not about how many times a resource appears in your
manifests files; it is about how many times it appears in the *catalog*
built from the manifests. Every instance of a defined type added to the
catalog carries a declaration of each resource declared in the type
definition's body. Each declaration of a defined type creates a separate
instance. E.g.
# two instances of defined type
# my_module::my_type:
my_module::my_type { 'foo': }
my_module::my_type { 'bar': }
That's why I said earlier that "defined type instances must declare only
resources that wholly belong to them; they must not not declare shared
resources". Let me now augment that by pointing out that any resource that
is not specific to a defined-type instance cannot wholly belong to that
instance, at least when multiple instances of the type are declared.
John
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/664df567-413f-480d-a4de-f01a8d53effe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.