Thanks for the response Paul, I took a look at ensure_packages and it seems
useful, but it of course has the same drawback as using defined, in that
it'll only work if all modules use it.
I've reduced my problem to the following. I created two modules, module1
and module2 as follows:
*modules/**module1/manifests/init.pp*:
define module1::before { package { 'mod_ssl': ensure => present } }
*modules/**module2/manifests/init.pp*:
define module2::after { if ! defined(Package['mod_ssl']) { package {
'mod_ssl': ensure => present } } }
and in my main manifest, I have the following which works:
module1::before {'test': }
module2::after {'test': }
but if I change around the order, I receive an error:
module2::after {'test': }
module1::before {'test': }
Error: Duplicate declaration: Package[mod_ssl] is already declared in file
/tmp/vagrant-puppet/modules-0/mod2/manifests/init.pp at line 7; cannot
redeclare on node vagrant
of course this happens because module 2 performs a check to only require
the mod_ssl package if it isn't defined, but module 1 has no such check, so
if module 1 is included after module 2, it ends up duplicating the mod_ssl
resource.
I've tried resolving this by using the *require* directive, but it doesn't
seem to work:
module2::after {'test': require => Module1::Before['test'] }
module1::before {'test': }
Can anyone tell me how I can fix this, and have the code in module1
included before module2, regardless of the order they appear in the file?
I thought that's what the *require *directive would enforce, but I must be
using it incorrectly, since it doesn't seem to work for me in this
instance. if I can solve this small issue, I can fix my larger problem
without needing to modify the code in either module, which is what I'd
prefer. Thanks for any help
Adam
On Saturday, July 20, 2013 1:48:20 AM UTC+10, Paul Tötterman wrote:
>
> Hi,
>
> It seems there are a few ways to remedy this, such as defining a new
>> class for the mod_ssl
>> package<https://groups.google.com/d/msg/puppet-users/julAujaVsVk/EQAk3HrpwAIJ>and
>> including that class in both modules. However, I'd like to figure out
>> if it's possible to rectify this situation without modifying either
>> module. I've tried in vain to use many different permutations of require
>> and -> for resource ordering to ensure that the puppetlabs-apache module
>> gets loaded first, but I just can't manage to get it to work. it seems no
>> matter what I do, the rvm module is loaded first, which causes the
>> puppetlabs-apache module to fail.
>>
>> So can anyone tell me how I can get around this problem? I'd very much
>> like to modify the puppetlabs-apache module, but since they use an array to
>> define the required mod packages, it makes it a little tricky to check if
>> each one is defined before using it, since as far as I know it's not very
>> straight forward to iterate over an array in the puppet DSL. Thanks for
>> any suggestions!
>>
>
> https://forge.puppetlabs.com/puppetlabs/stdlib -- check out
> ensure_packages().
>
> Cheers,
> Paul
>
--
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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.