I know the basics of ordering in puppet to run apt-get update before a specific package but would like to specify to just run apt-get update only once and then execute the rest of the puppet file. Is that possible?
All of the ways listed Here need to either run apt-get before every package or use arrows or requires to specify each package.
This would be my recommendation from that list:
exec { "apt-update":
command => "/usr/bin/apt-get update"
}
Exec["apt-update"] -> Package <| |>
This will ensure that the exec is run before any package, not that the exec is run before each package. In fact, any resource in puppet will only ever be executed at most once per puppet run.
But if you're wanting the exec to occur before ANY type of resource I guess you could do something like:
exec { "apt-update":
command => "/usr/bin/apt-get update",
before => Stage["main"],
}
The "main" Stage is the default stage for each resource, so this would make the exec occur before anything else.
I hope that this helps.
With puppetlabs-apt module, it should be enough to define dependency on the module for any package that will be installed:
Class['apt::update'] -> Package <| provider == 'apt' |>
This assumes basic configuration of apt
, e.g.:
class { 'apt':
update => {
frequency => 'daily',
},
purge => {
'sources.list' => false,
'sources.list.d' => true,
},
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With