force dist-upgrade once on each puppet run and update on each package to be installed?

21 views
Skip to first unread message

Kristian Rink

unread,
Dec 5, 2017, 9:12:21 AM12/5/17
to Puppet Users
Folks;

using puppet with the apt module, I am looking for a way to do

- an apt-get update && apt-get dist-upgrade *once* on each puppet agent run, and

- an apt-get update before each package to be installed.

Right now I am playing with various exec[] approaches but none seems really to do what I want. 
Is there any "best" way to do this?

TIA and all the best,
Kristian

Christopher Wood

unread,
Dec 5, 2017, 9:34:12 AM12/5/17
to puppet...@googlegroups.com
I found that a single "apt-get update" exec before any packages were managed was useful enough. Out of interest, what is the use case that needs "apt-get update" before every package is installed?

Lately here the "yum upgrade" is a daily thing with some incremental canarying as the month goes on, but same general concept.

If you were using puppet to install apt repositories before packages, you could use some chained collectors to make sure you got the apt-get update after your repositories were installed, but before any packages were installed. To wit:

file { '/etc/apt/sources.list.d/myrepo.repo':
content => "deb etc. etc.\n",
tag => 'apt',
}

package { 'mypackage': }

exec { '/usr/bin/apt-get -y update':
refreshonly => true,
}

File <| tag == 'apt' |> ~> Exec['/usr/bin/apt-get -y update']

Exec['/usr/bin/apt-get -y update'] -> Package <| |>

(Of course the file resource could have a notify instead of a tag in this case.)

We are doing something broadly similar with yum for the last several years with no complaints. One trade-off is that all repositories are declared through resources rather than shipped with packages but that also means we have a single list of all our repos currently in use.
> --
> 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 [1]puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> [2]https://groups.google.com/d/msgid/puppet-users/31e6de73-5a60-43f1-9ead-c642bb5ade58%40googlegroups.com.
> For more options, visit [3]https://groups.google.com/d/optout.
>
> References
>
> Visible links
> 1. mailto:puppet-users...@googlegroups.com
> 2. https://groups.google.com/d/msgid/puppet-users/31e6de73-5a60-43f1-9ead-c642bb5ade58%40googlegroups.com?utm_medium=email&utm_source=footer
> 3. https://groups.google.com/d/optout

Reply all
Reply to author
Forward
0 new messages