Distribution upgrade and subsequent reboot of machine

289 views
Skip to first unread message

Mike Reed

unread,
Jun 27, 2012, 1:12:05 AM6/27/12
to puppet...@googlegroups.com
Hello all,

In building out an initial workstation configuration (Ubuntu 10.04 lucid) via Puppet, I have the need to do two things in order.  The first is to do a dist-upgrade on the workstation and reboot, followed by an install of a Nvida driver.  Upon doing a dist-upgrade, I have to reboot the machine in order for the workstation to start using the new linux-headers because if I install the Nvidia drivers without doing a reboot after a dist-upgrade, the drivers will compile against the old headers and my gui no longer works and X won't start because of a modprobe issue.

With that said, I've written the dist-upgrade manifest as so:

class dist_upgrade {
        exec { "dist_upgrade" :
                command => "/usr/bin/apt-get -y dist-upgrade" ,
        }

        exec { "purge_linux-headers-2.6.32-38" :
                command => "/usr/bin/apt-get -y purge linux-headers-2.6.32-38" ,
                require => Exec['dist_upgrade'] ,
        }

        exec { "purge_linux-image-2.6.32-38-server" :
                command => "/usr/bin/apt-get -y purge linux-image-2.6.32-38-server" ,
                require => Exec['purge_linux-headers-2.6.32-38'] ,
        }

        #This is done so the system starts using the new headers/image
        exec { "reboot_after_dist_upgrade" :
                command => "/sbin/reboot" ,
                subscribe => Exec["purge_linux-image-2.6.32-38-server"] ,
                refreshonly => true ,
        }
}

This seems to be doing the job but I feel it's a bit of a hack and I was wondering if anybody had an opinion as to if this can be done in a cleaner fashion.  I'm still very new to Puppet so please excuse my novice example.

Thanks in advance for the help and support.

Cheers,

Mike

Mike Reed

unread,
Jun 27, 2012, 1:37:18 AM6/27/12
to puppet...@googlegroups.com
As an update, after running this a few times after this initial post, I'm seeing the machine reboot after new classes have been added which is not desired.  I might have to rethink the reboot approach.

Thanks again,

Mike

Peter Brown

unread,
Jun 27, 2012, 1:37:52 AM6/27/12
to puppet...@googlegroups.com
Hi Mike,

Just as a side not I would be rather hesitant to set this up with puppet.
This may be a job for some other tool like mcollective but I have not
ventured into the land yet.

This may work but I haven't done any testing so please test this on a
non production server before rolling it out.

I would try a notify in your exec {
"purge_linux-image-2.6.32-38-server" : resource and take the subscribe
out of the reboot.

Something like this.

exec { "purge_linux-image-2.6.32-38-server" :
command => "/usr/bin/apt-get -y purge
linux-image-2.6.32-38-server" ,
require => Exec['purge_linux-headers-2.6.32-38'] ,
notify => Exec["reboot_after_dist_upgrade"]
}
#This is done so the system starts using the new headers/image
exec { "reboot_after_dist_upgrade" :
command => "/sbin/reboot" ,
refreshonly => true ,
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-users/-/R5BQkgRvyt4J.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.

jcbollinger

unread,
Jun 27, 2012, 3:02:16 PM6/27/12
to puppet...@googlegroups.com


On Tuesday, June 26, 2012 8:12:05 PM UTC-5, Mike Reed wrote:
        exec { "purge_linux-image-2.6.32-38-server" :
                command => "/usr/bin/apt-get -y purge linux-image-2.6.32-38-server" ,
                require => Exec['purge_linux-headers-2.6.32-38'] ,
        }

        #This is done so the system starts using the new headers/image
        exec { "reboot_after_dist_upgrade" :
                command => "/sbin/reboot" ,
                subscribe => Exec["purge_linux-image-2.6.32-38-server"] ,
                refreshonly => true ,
        }

That combination is wrong if you do not in fact intend for Puppet to reboot the machine on every run.  The problem is that Exec["purge_linux-image-2.6.32-38-server"] runs its command every time, and any time an Exec runs its command is considered a change (thus triggering subscribers to refresh).  You can avoid that by setting an appropriate command in the 'onlyif' or 'unless' parameter of that Exec; these plus 'creates' are how an Exec determines whether it is already in sync.

John

Mike Reed

unread,
Jun 27, 2012, 5:20:34 PM6/27/12
to puppet...@googlegroups.com
Hey John,

Thanks for the reply.  I'll look up the 'onlyif' and 'unless' usage and see which might best suit my needs.  Thank you for pointing me in the right direction.

Cheers,

Mike

Mike Reed

unread,
Jun 27, 2012, 5:24:07 PM6/27/12
to puppet...@googlegroups.com
Hey Pete,

I haven't had a chance to venture into mcollective yet but that's a great thought and I'll put that on my list of things to "investigate".  I'm only running puppet against one machine and it's a box I don't care about so I'll give this a run and see how it goes.  I wanted to thank you for the suggestion and help.

Cheers,

Mike

Peter Brown

unread,
Jun 28, 2012, 12:25:35 AM6/28/12
to puppet...@googlegroups.com
Much better idea that mine.
I was thinking that at the time but got distracted by fixing something urgent.
onlyif and creates are very handy for this sort of thing (or creating
and ensuring virtual machines are built and running which is what use
them for)

> John
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-users/-/ORPq_sllUnYJ.
>
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users...@googlegroups.com.

Peter Brown

unread,
Jun 28, 2012, 12:26:25 AM6/28/12
to puppet...@googlegroups.com
No worries.

Hope it helps.

I have been looking for an excuse to venture into mcollective but
haven't needed it yet.
>> > puppet-users...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/puppet-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-users/-/sc_uIsXu_wEJ.
>
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages