{"id":335,"date":"2023-03-30T06:26:23","date_gmt":"2023-03-30T06:26:23","guid":{"rendered":"https:\/\/www.hort.net\/techblog\/?p=335"},"modified":"2023-04-06T09:29:22","modified_gmt":"2023-04-06T09:29:22","slug":"scheduling-a-reboot-via-puppet-after-a-kernel-update-with-rhel-style-distributions","status":"publish","type":"post","link":"https:\/\/www.hort.net\/techblog\/2023\/03\/30\/scheduling-a-reboot-via-puppet-after-a-kernel-update-with-rhel-style-distributions\/","title":{"rendered":"Scheduling a reboot via puppet after a kernel update with RHEL style distributions"},"content":{"rendered":"<div class=\"share_buttons_simple_use_buttons\" style=\"padding: 10px 0; display: inline-block\"><div class=\"tweet_button\" style=\"float: left; vertical-align: top\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.hort.net\/techblog\/2023\/03\/30\/scheduling-a-reboot-via-puppet-after-a-kernel-update-with-rhel-style-distributions\/\" data-text=\"Scheduling a reboot via puppet after a kernel update with RHEL style distributions\" data-count=\"none\">Tweet<\/a><script type=\"text\/javascript\" src=\"https:\/\/platform.twitter.com\/widgets.js\"><\/script><\/div><div class=\"facebook_like_button\" style=\"float: left; vertical-align: top; margin-left: 10px; max-width: 255px\"><iframe src=\"https:\/\/www.facebook.com\/plugins\/like.php?href=https%3A%2F%2Fwww.hort.net%2Ftechblog%2F2023%2F03%2F30%2Fscheduling-a-reboot-via-puppet-after-a-kernel-update-with-rhel-style-distributions%2F&amp;layout=button_count&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=25\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:450px; height:25px;\" allowTransparency=\"true\"><\/iframe><\/div><\/div><p>I&#8217;ve had people ask me how to schedule a reboot of their system via puppet if a kernel upgrade was installed.  I like to use the &#8216;at&#8217; command<\/p>\n<div class=\"horttech-code\">\n<pre class=\"preserve-code-formatting\">\n\nclass yoursite::common::rebootforkernelchange {\n\n&nbsp;&nbsp; exec {&#039;schedule-kernel-reboot&#039;:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;command =&gt; &#039;\/bin\/echo &quot;\/usr\/sbin\/reboot&quot; | at -m 4:00&#039;,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;path =&gt; &#039;\/usr\/bin:\/bin&#039;,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unless =&gt; [&#039;test `atq | wc -l` != 0&#039;, &#039;test `uname -r` = `rpm -q kernel --queryformat &quot;%{RPMTAG_BUILDTIME} %{VERSION}-%{RELEASE}.%{ARCH}\\n&quot; | sort -nr | cut -d&quot; &quot; -f 2 | head -1`&#039;]\n&nbsp;&nbsp; }\n}\n\n<\/pre>\n<\/div>\n<p>This compares the current kernel against the latest built kernel that is installed, and if they don&#8217;t match it sets an at job to reboot the system at 4am.<\/p>\n<p>If you want to check the latest installed kernel instead of the latest built kernel, change RPMTAG_BUILDTIME to RPMTAG_INSTALLTIME.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"share_buttons_simple_use_buttons\" style=\"padding: 10px 0; display: inline-block\"><div class=\"tweet_button\" style=\"float: left; vertical-align: top\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.hort.net\/techblog\/2023\/03\/30\/scheduling-a-reboot-via-puppet-after-a-kernel-update-with-rhel-style-distributions\/\" data-text=\"Scheduling a reboot via puppet after a kernel update with RHEL style distributions\" data-count=\"none\">Tweet<\/a><script type=\"text\/javascript\" src=\"https:\/\/platform.twitter.com\/widgets.js\"><\/script><\/div><div class=\"facebook_like_button\" style=\"float: left; vertical-align: top; margin-left: 10px; max-width: 255px\"><iframe src=\"https:\/\/www.facebook.com\/plugins\/like.php?href=https%3A%2F%2Fwww.hort.net%2Ftechblog%2F2023%2F03%2F30%2Fscheduling-a-reboot-via-puppet-after-a-kernel-update-with-rhel-style-distributions%2F&amp;layout=button_count&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=25\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:450px; height:25px;\" allowTransparency=\"true\"><\/iframe><\/div><\/div><p>TweetI&#8217;ve had people ask me how to schedule a reboot of their system via puppet if a kernel upgrade was installed. I like to use the &#8216;at&#8217; command class yoursite::common::rebootforkernelchange { &nbsp;&nbsp; exec {&#039;schedule-kernel-reboot&#039;: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;command =&gt; &#039;\/bin\/echo &quot;\/usr\/sbin\/reboot&quot; | at -m 4:00&#039;, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;path =&gt; &#039;\/usr\/bin:\/bin&#039;, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unless =&gt; [&#039;test `atq | wc -l` != 0&#039;, &#039;test [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-335","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.hort.net\/techblog\/wp-json\/wp\/v2\/posts\/335","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hort.net\/techblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hort.net\/techblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hort.net\/techblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hort.net\/techblog\/wp-json\/wp\/v2\/comments?post=335"}],"version-history":[{"count":9,"href":"https:\/\/www.hort.net\/techblog\/wp-json\/wp\/v2\/posts\/335\/revisions"}],"predecessor-version":[{"id":344,"href":"https:\/\/www.hort.net\/techblog\/wp-json\/wp\/v2\/posts\/335\/revisions\/344"}],"wp:attachment":[{"href":"https:\/\/www.hort.net\/techblog\/wp-json\/wp\/v2\/media?parent=335"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hort.net\/techblog\/wp-json\/wp\/v2\/categories?post=335"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hort.net\/techblog\/wp-json\/wp\/v2\/tags?post=335"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}