{"id":1892,"date":"2023-12-21T14:55:43","date_gmt":"2023-12-21T19:55:43","guid":{"rendered":"https:\/\/enterpriseadmins.org\/blog\/?p=1892"},"modified":"2023-12-21T14:55:43","modified_gmt":"2023-12-21T19:55:43","slug":"keeping-linux-up-to-date-with-aria-automation-config-part-2","status":"publish","type":"post","link":"https:\/\/enterpriseadmins.org\/blog\/scripting\/keeping-linux-up-to-date-with-aria-automation-config-part-2\/","title":{"rendered":"Keeping Linux up to date with Aria Automation Config &#8212; part 2"},"content":{"rendered":"\n<p>In a recent post (<a href=\"https:\/\/enterpriseadmins.org\/blog\/virtualization\/keeping-linux-up-to-date-with-aria-automation-config\/\" data-type=\"link\" data-id=\"https:\/\/enterpriseadmins.org\/blog\/virtualization\/keeping-linux-up-to-date-with-aria-automation-config\/\">available here<\/a>), we created a simple Aria Automation Config (formerly SaltStack Config) state file which reported on and applied available Linux OS updates.  In this post we&#8217;ll revisit a minor change to this state file.<\/p>\n\n\n\n<p>After creating the previous state which applies available updates every Saturday morning, I noticed sometimes logging into Linux VMs would return a message of <code>*** System restart required ***<\/code>.  I found that this text was coming from the file <code>\/var\/run\/reboot-required<\/code> which was created when a package required a system restart.<\/p>\n\n\n\n<p>I&#8217;ve modified the state file applied by my scheduled job to accommodate this reboot as shown below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>update_pkg:\r\n{% if grains&#91;'os'] == 'VMware Photon OS' %}\r\n  pkg.uptodate:\r\n    - refresh: True\r\n{% else %}\r\n  pkg.uptodate:\r\n    - refresh: True\r\n    - dist_upgrade: True\r\n{% endif %}\r\n\r\n{# Check if the system requires a reboot, and if so schedule it to happen in the next 15 minutes, randomize to prevent boot storm #}\r\n{%- if salt&#91;'file.file_exists']('\/var\/run\/reboot-required') %}\r\nReboot-if-needed:\r\n  module.run:\r\n    - name: system.reboot\r\n    - tgt: {{ grains.id }}\r\n    - at_time: {{ range(1,15) | random }}\r\n{%- endif %}<\/code><\/pre>\n\n\n\n<p>In this version, we continue to use <code>pkg.uptodate<\/code> to apply updates, but after doing so we check for the presence of <code>\/var\/run\/reboot-required<\/code>.  If found, we schedule a system reboot to happen at least one minute in the future (to give the salt-minion time to report back).  In this case we are randomizing the time of these reboots to minimize a boot storm, with a maximum future time of 15 minutes.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a recent post (available here), we created a simple Aria Automation Config (formerly SaltStack Config) state file which reported on and applied available Linux OS updates. In this post we&#8217;ll revisit a minor change to this state file. After &hellip; <a href=\"https:\/\/enterpriseadmins.org\/blog\/scripting\/keeping-linux-up-to-date-with-aria-automation-config-part-2\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[9,3,4],"tags":[],"class_list":["post-1892","post","type-post","status-publish","format-standard","hentry","category-lab-infrastructure","category-scripting","category-virtualization"],"_links":{"self":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/1892","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/comments?post=1892"}],"version-history":[{"count":1,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/1892\/revisions"}],"predecessor-version":[{"id":1893,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/1892\/revisions\/1893"}],"wp:attachment":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/media?parent=1892"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/categories?post=1892"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/tags?post=1892"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}