On Tuesday, March 10, 2015 at 10:30:48 PM UTC-5, Amos Shapira wrote:
>
> Hi,
>
> I'm running into the common issue of having to force an "apt-get update" 
> before installing packages (in my case - because the base EC2 AMI is old 
> and I need it to pick newer package versions).
>
> I ended up doing the usual:
>
>  exec { 'apt-get update':
>    path => '/usr/bin/',
>  }
>  ->
>  Package <| |>
>
>

If you are using PuppetLabs's Apt module, then I think setting the 
'always_apt_update => true' on class 'apt' and declaring

Class['Apt'] -> Package <| |>


should take care of it for you.  That module's 'apt::update' class is not 
really suited to be public, given the way the module uses it.

 

> (I can't use "apt::update" because it creates dependency cycles) and it 
> works.
>
> But what baffles me is that I really only need "apt-get update" to execute 
> before "apt" packages get installed, like this:
>
> Package <| provider = "apt" |>
>
> But this doesn't trigger the "apt-get update".
>
> Just as an example, I also have a Gem-provider related exec which works as 
> expected:
>
>   exec { 'Add Ruby Gems repo mirror':
>     command => 'gem source --config-file /etc/gemrc -a 
> http://production.cf.rubygems.org/',
>     unless  => 'gem source --config-file /etc/gemrc | fgrep -xq 
> http://production.cf.rubygems.org/',
>     path    => '/usr/bin:/bin',
>   }
>   ->
>   Package<| provider == 'gem' |>
>
> So why doesn't it work for the "apt" provider?
>
>
 
Resource collectors operate during catalog building.  Their selection 
predicates can see only parameter and property values *explicitly* declared 
in your manifests.  It does not know what values will be effective at 
catalog application time for any other parameters.  In particular, it does 
not know what provider will be selected during catalog application unless 
one is specified in the manifest, which is not usual when the system's 
default provider is expected.

To the best of my knowledge, the "gem" provider is not the default for any 
system, so you get it only when you specifically ask for it.  That's why 
you can reliably select gem Packages by provider.  'Apt' is normally the 
default Package provider on systems that support it at all.  Your selection 
predicate will not match Package resources that rely 'apt' being selected 
by default.


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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/3db8500f-db7f-4343-9054-a6abcd5209ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to