What''s the right/best way to indicate that a particular entry in a manifest (a file in this case) depends on successful installation of over 30 packages, all indicated in the same manifest? I could do this, but it seems cumbersome: package { ''pkg1'': } Package[''pkg1''] -> File[''file1''] package { ''pkg2'': } Package[''pkg2''] -> File[''file2''] : : file { ''file2'': path => ''/path/to/file2'', : } There must be a better way that I''m just not seeing. Thanks! Bret Wortman -- 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+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
On Wednesday, May 8, 2013 5:52:44 AM UTC-5, Bret Wortman wrote:> > What''s the right/best way to indicate that a particular entry in a > manifest (a file in this case) depends on successful installation of over > 30 packages, all indicated in the same manifest?What is the significance to you of the packages being in the same manifest? To Puppet, it matters very little. Do you mean they are in the same class? Or could they be made to be?> I could do this, but it seems cumbersome: > > package { ''pkg1'': } > Package[''pkg1''] -> File[''file1''] > > package { ''pkg2'': } > Package[''pkg2''] -> File[''file2''] > : > : > file { ''file2'': > path => ''/path/to/file2'', > : > } > >You''ve confused me a bit there. Your question suggests that you want a single file depending on all the packages, but the example looks like you may mean multiple files, each depending on one package. Or maybe not. I am proceeding based on the question rather than on the ambiguous example.> There must be a better way that I''m just not seeing. Thanks! > >There is a variety of ways. If the packages are all in the same class, and File[''file2''] is in a different one, then you can declare the file this way: file { ''/path/to/file2'': require => Class[''mymodule::manypackages''] } Alternatively, you can use tags to recognize the packages in question, and write the relationship like this: Package<| tag == ''<some-tag>'' |> -> File[''/path/to/file2''] Tag ''some-tag'' could be explicitly declared on the Packages, or under some circumstances it would work to just use the class name (which is automatically included in resources'' tags). With explicitly declared tags, this can work even when the packages are in different classes or even not in classes at all. Or you can perhaps use resource defaults for this. That''s more brittle and more susceptible to unintended relationships, but it''s easy to set up. To do that, put this at the top of the body of the class(es) that declare the packages: include <class-of-file2-if-different> Package { before => File[''/path/to/file2''] } There are other alternatives, too. 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 puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Bret Wortman
2013-May-08 13:47 UTC
[Puppet Users] Re: How to indicate multiple dependency?
On Wednesday, May 8, 2013 9:09:34 AM UTC-4, jcbollinger wrote:> > > > On Wednesday, May 8, 2013 5:52:44 AM UTC-5, Bret Wortman wrote: >> >> What''s the right/best way to indicate that a particular entry in a >> manifest (a file in this case) depends on successful installation of over >> 30 packages, all indicated in the same manifest? > > > > What is the significance to you of the packages being in the same > manifest? To Puppet, it matters very little. Do you mean they are in the > same class? Or could they be made to be? >They are in the same class, actually. I wasn''t clear enough -- wrote this before my coffee kicked in.> > > >> I could do this, but it seems cumbersome: >> >> package { ''pkg1'': } >> Package[''pkg1''] -> File[''file1''] >> >> package { ''pkg2'': } >> Package[''pkg2''] -> File[''file2''] >> : >> : >> file { ''file2'': >> path => ''/path/to/file2'', >> : >> } >> >> > > You''ve confused me a bit there. Your question suggests that you want a > single file depending on all the packages, but the example looks like you > may mean multiple files, each depending on one package. Or maybe not. I > am proceeding based on the question rather than on the ambiguous example. >Blaming coffee again. The "file2" is a typo. All the right-hand sides should read '' -> File["file1"]''.> > > >> There must be a better way that I''m just not seeing. Thanks! >> >> > There is a variety of ways. If the packages are all in the same class, > and File[''file2''] is in a different one, then you can declare the file this > way: > > file { ''/path/to/file2'': > require => Class[''mymodule::manypackages''] > } > > Alternatively, you can use tags to recognize the packages in question, and > write the relationship like this: > > Package<| tag == ''<some-tag>'' |> -> File[''/path/to/file2''] > > Tag ''some-tag'' could be explicitly declared on the Packages, or under some > circumstances it would work to just use the class name (which is > automatically included in resources'' tags). With explicitly declared tags, > this can work even when the packages are in different classes or even not > in classes at all. > > Or you can perhaps use resource defaults for this. That''s more brittle > and more susceptible to unintended relationships, but it''s easy to set up. > To do that, put this at the top of the body of the class(es) that declare > the packages: > > include <class-of-file2-if-different> > > Package { > before => File[''/path/to/file2''] > } > > There are other alternatives, too. >Okay, so if the class actually looks like this, say: class blacklisted () { Package { ensure => absent, tag => "blacklisted", } package { ''pkg1'': } package { ''pkg2'': } package { ''pkg3'': } : package { ''pkg30'': } file { ''/path/to/file1'': ensure => present, } Package<| tag == ''blacklisted'' |> -> File[''/path/to/file1''] } Should do it, right? I''ve never done anything with tags before, but this may cause me to rework a few modules I''ve written....> > > 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 puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Peter Bukowinski
2013-May-08 13:57 UTC
Re: [Puppet Users] How to indicate multiple dependency?
On May 8, 2013, at 6:52 AM, Bret Wortman <bret.wortman@damascusgrp.com> wrote:> What''s the right/best way to indicate that a particular entry in a manifest (a file in this case) depends on successful installation of over 30 packages, all indicated in the same manifest? I could do this, but it seems cumbersome: > > package { ''pkg1'': } > Package[''pkg1''] -> File[''file1''] > > package { ''pkg2'': } > Package[''pkg2''] -> File[''file2''] > : > : > file { ''file2'': > path => ''/path/to/file2'', > : > } > > There must be a better way that I''m just not seeing. Thanks! > > > Bret WortmanBret, Puppet lets you use arrays to make your manifests more concise. In this case, if these 30 package resources differ only in name, i.e. all their parameters are the same except for the package name, then you can use this following to make the dependency declaration less cumbersome: package { [ "pkg1", "pkg2", . . "pkg30" ]: ensure => installed, before => File[''file2''], } file { ''file2'': ensure => file, path => "/path/to/file2", content => "I exist only after all 30 packages are installed.", } -- Peter -- 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+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Bret Wortman
2013-May-08 14:14 UTC
Re: [Puppet Users] How to indicate multiple dependency?
I wasn''t sure how the "before" would work in that instance -- and my experimental facilities are limited. But if the before really won''t trigger until all the members of the array complete, then that sounds like the perfect solution for me. Thanks! On Wednesday, May 8, 2013 9:57:19 AM UTC-4, pmbuko wrote:> > On May 8, 2013, at 6:52 AM, Bret Wortman <bret.w...@damascusgrp.com<javascript:>> > wrote: > > What''s the right/best way to indicate that a particular entry in a > manifest (a file in this case) depends on successful installation of over > 30 packages, all indicated in the same manifest? I could do this, but it > seems cumbersome: > > package { ''pkg1'': } > Package[''pkg1''] -> File[''file1''] > > package { ''pkg2'': } > Package[''pkg2''] -> File[''file2''] > : > : > file { ''file2'': > path => ''/path/to/file2'', > : > } > > There must be a better way that I''m just not seeing. Thanks! > > > Bret Wortman > > > Bret, > > Puppet lets you use arrays to make your manifests more concise. In this > case, if these 30 package resources differ only in name, i.e. all their > parameters are the same except for the package name, then you can use this > following to make the dependency declaration less cumbersome: > > package { [ "pkg1", > "pkg2", > . > . > "pkg30" ]: > ensure => installed, > before => File[''file2''], > } > file { ''file2'': > ensure => file, > path => "/path/to/file2", > content => "I exist only after all 30 packages are installed.", > } > > -- > Peter >-- 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+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Peter Bukowinski
2013-May-08 14:33 UTC
Re: [Puppet Users] How to indicate multiple dependency?
The ''before'' metaparameter is an inverse version of the ''require'' metaparameter. Where the ''require'' parameter forces the parent resource to sync *after* the indicated resource, the ''before'' parameter acts as a pause button on the indicated resource (in this case, file2), preventing it from syncing until the parent resource(s) have synced. -- Peter On May 8, 2013, at 10:14 AM, Bret Wortman <bret.wortman@damascusgrp.com> wrote:> I wasn''t sure how the "before" would work in that instance -- and my experimental facilities are limited. But if the before really won''t trigger until all the members of the array complete, then that sounds like the perfect solution for me. Thanks! > > On Wednesday, May 8, 2013 9:57:19 AM UTC-4, pmbuko wrote: > On May 8, 2013, at 6:52 AM, Bret Wortman <bret.w...@damascusgrp.com> wrote: > >> What''s the right/best way to indicate that a particular entry in a manifest (a file in this case) depends on successful installation of over 30 packages, all indicated in the same manifest? I could do this, but it seems cumbersome: >> >> package { ''pkg1'': } >> Package[''pkg1''] -> File[''file1''] >> >> package { ''pkg2'': } >> Package[''pkg2''] -> File[''file2''] >> : >> : >> file { ''file2'': >> path => ''/path/to/file2'', >> : >> } >> >> There must be a better way that I''m just not seeing. Thanks! >> >> >> Bret Wortman > > Bret, > > Puppet lets you use arrays to make your manifests more concise. In this case, if these 30 package resources differ only in name, i.e. all their parameters are the same except for the package name, then you can use this following to make the dependency declaration less cumbersome: > > package { [ "pkg1", > "pkg2", > . > . > "pkg30" ]: > ensure => installed, > before => File[''file2''], > } > file { ''file2'': > ensure => file, > path => "/path/to/file2", > content => "I exist only after all 30 packages are installed.", > } > > -- > Peter > > -- > 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+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
On Wednesday, May 8, 2013 8:47:59 AM UTC-5, Bret Wortman wrote:> > > Okay, so if the class actually looks like this, say: > > class blacklisted () { > > Package { > ensure => absent, > tag => "blacklisted", > } > > package { ''pkg1'': } > package { ''pkg2'': } > package { ''pkg3'': } > : > package { ''pkg30'': } > > file { ''/path/to/file1'': > ensure => present, > } > > Package<| tag == ''blacklisted'' |> -> File[''/path/to/file1''] > > } > > Should do it, right? I''ve never done anything with tags before, but this > may cause me to rework a few modules I''ve written.... > >> >>Yes, that should work, but if you''re going to use resource defaults then I don''t see why you would want to go the long way around through tags. Instead, just use ''before'' as in my last suggestion, and skip the collector and chain expression. 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 puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Nikola Petrov
2013-May-09 07:26 UTC
Re: [Puppet Users] How to indicate multiple dependency?
Are those packages defined in different files? If they are in the same file you can just do the following package {[''pgk1'', ''pkg2'']: ensure => ''installed'', } -> file { ''file1'': ... } If they are in different files you maybe will be able to hack something with the "spaceship operator" but it will hard and might brake in the future because of circular dependencies :( -- Nikola On Wed, May 08, 2013 at 03:52:44AM -0700, Bret Wortman wrote:> What''s the right/best way to indicate that a particular entry in a manifest > (a file in this case) depends on successful installation of over 30 > packages, all indicated in the same manifest? I could do this, but it seems > cumbersome: > > package { ''pkg1'': } > Package[''pkg1''] -> File[''file1''] > > package { ''pkg2'': } > Package[''pkg2''] -> File[''file2''] > : > : > file { ''file2'': > path => ''/path/to/file2'', > : > } > > There must be a better way that I''m just not seeing. Thanks! > > > Bret Wortman > > -- > 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+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.