6

I understand how puppet helps setup servers etc., but would you use puppet for something like:

apt-get update && apt-get upgrade

I get the feeling the answer is no, if that is the case, what sort of automated process would you suggest to do these kinds of tasks?

So say I am setting up a new instance (agent) to connect to puppet, how could I wrap together multiple commands that I want to run on the server just to prep it before connecting to the puppet master? I'm hoping I can just write out all the commands in a file, and then somehow run this file.

For things like:

  1. apt-get update && apt-get upgrade
  2. install ruby, other libs
  3. basic server lockdowns etc.

3 Answers 3

6

Well, for APT in particular, you can configure many daily jobs, such as update. Just look at /etc/cron.daily/apt for a list of variables you can configure, and check the man page for apt.conf for how to do it. The ones of most interest to you are these:

#  APT::Periodic::Update-Package-Lists "0";
#  - Do "apt-get update" automatically every n-days (0=disable)
#    
#  APT::Periodic::Download-Upgradeable-Packages "0";
#  - Do "apt-get upgrade --download-only" every n-days (0=disable)
#
#  APT::Periodic::Download-Upgradeable-Packages-Debdelta "1";
#  - Use debdelta-upgrade to download updates if available (0=disable)
#
#  APT::Periodic::Unattended-Upgrade "0";
#  - Run the "unattended-upgrade" security upgrade script 
#    every n-days (0=disabled)
#    Requires the package "unattended-upgrades" and will write
#    a log in /var/log/unattended-upgrades

As for upgrading the system, use the package unattended-upgrades.

Having said all that, I prefer to use Puppet to control what packages must be kept at ensure => latest, or ensure => version, as well as controlling pin numbers for various source list and packages.

And, I suppose, one could use a configuration like this:

cron { 'upgrade': command => 'apt-get update && apt-get upgrade' }

Now, you mention doing stuff before calling puppet agent. Do you mean before running puppet agent for the first time? If so, then a solution such as Foreman might do the trick for you.

Here, where I manage my virtual hosts through Ganeti, we have puppet being installed by Ganeti's instance-debootstrap. We also have a small script we use to install puppet on older servers.

In the end, it is not possible to use an automated solution to install Puppet on existing servers unless said automated solution has been already installed. Our own preference is to install puppet first, and distribute anything else through it.

2

I have always used cron-apt for unattended automated updates. It is a bit clunky to configure, but once setup it works well. If you pair it with sSMTP you can get automated updates and/or notification via email.

In your situation you could use Puppet to control the cron-apt, sSMTP and crontab configuration files.

Here's my standard setup... tweak as appropriate.

1
  • 1
    apticron is another good option for automated download and notification. This wouldn't be in the range of puppet, but I'd love to see something along the lines of what WSUS does for windows, or what Landscape does for paying Canonical customers. Touching each system to run an upgrade, or building and modifying a puppet resource for each new security update in some random package, are not my idea of a good time. May 18, 2011 at 21:44
1

Puppet uses a declarative language in which you specify how things ought to be according to your desired configuration, and you leave the method used to achieve that up to puppet to sort out. As such, it's not incredibly well-suited for running arbitrary commands from time to time.

It's easy enough to ask puppet to ensure that a package is installed, but for regular updates, I'd recommend you have puppet add a line to root's cron to do $ apt-get update && apt-get upgrade periodically. If you want to have fine-grained control over which packages get applied, then you could look into running your own apt repository.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .