Short hack: As seen in m a n y Dockerfiles, the apt cache is located at /var/lib/apt/lists.
Therefore, we can use it's existence to create an idempotent exec-Ressouce!
exec { 'apt update': # Only if the update files dont exist unless => '[ "$(ls -A /var/lib/apt/lists)" ]', # /bin is needed for bash # /usr/bin is needed for [ path => '/bin:/usr/bin', } Now whenever you need to have the apt cache first, just do something like
package { 'your-package': ensure => 'present', require => Exec['apt update'] } Easy as 🥧
Top comments (0)