On Mon, Jun 6, 2016 at 9:46 AM, Simon Weald <simon.we...@gmail.com> wrote:
> Hi everyone
>
> I've got a little bit of an issue which I'm currently fighting with. At the
> moment, we pass an array of packages to be installed to the package
> resource, however I need to call an apt-get update prior to the package
> installation (in case we add a new repo etc). My snippet below should
> probably give you a good idea of what I want to achieve:
>
> $installpackages = hiera_array('installed-packages')
>
> exec { "apt-update":
>  command => "/usr/bin/apt-get update",
>  refreshonly => true,
> }
>
> package { $installpackages:
>  ensure => 'present',
>  require => Exec['apt-update'],
> }
>
> Obviously my goal is to have the update only run if any packages are
> actually going to be installed - I can't use empty() against the array as it
> will always contain content.
>
> Can anyone suggest how I can achieve this?

We're using the puppetlabs apt resource and a line like:

Apt::Source <| |> -> Package <| |>

to ensure that any Apt::Source is processed before any package installation.

I know this doesn't quite do the updating - we do that daily via cron,
but it does demonstrate the global dependency ordering of sources and
packages.

Hope that helps!

-m

-- 
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/CAOLfK3We9%3DYap2uT93vLzfN5k0VyS%3DJ%2BshC1KnTXDNBFP6xr_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to