{"id":1894,"date":"2023-12-27T14:07:26","date_gmt":"2023-12-27T19:07:26","guid":{"rendered":"https:\/\/enterpriseadmins.org\/blog\/?p=1894"},"modified":"2023-12-27T14:07:26","modified_gmt":"2023-12-27T19:07:26","slug":"keeping-pihole-up-to-date-with-aria-automation-config","status":"publish","type":"post","link":"https:\/\/enterpriseadmins.org\/blog\/scripting\/keeping-pihole-up-to-date-with-aria-automation-config\/","title":{"rendered":"Keeping pihole up to date with Aria Automation Config"},"content":{"rendered":"\n<p>I&#8217;ve recently begun keeping components of my lab up to date using Aria Automation Config.  I&#8217;ve scheduled a daily job to inventory Linux packages that need updated and a weekly task to update Linux VMs and reboot if necessary.  Both of these tasks leave a paper trail showing what updates were made, so I can refer back to them if needed.  <\/p>\n\n\n\n<p>I recently was checking the pihole admin interface and noticed some text at the bottom of the page that said &#8216;Update available!&#8217;  This is an easy process to complete, just SSH into the appliance and run <code>pihole -up<\/code>.  However, since I&#8217;m keeping other systems up to date automatically, I wanted to add this service into the mix.<\/p>\n\n\n\n<p>I debated on whether or not I should tack this process on to the end of the current OS update state file, or create a new state.  I opted for option 2, but wrote the state in a way that it could run on any system and only run the commands if present.  I created a new state file named <code>\/updates\/pihole.sls<\/code> with the following contents:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{%- if salt&#91;'file.file_exists']('\/usr\/local\/bin\/pihole') %}\nUpdate-pihole:\n  cmd.run:\n    - name: \/usr\/local\/bin\/pihole updatePihole\n{%- endif %}<\/code><\/pre>\n\n\n\n<p>This is a pretty basic state, it checks for the presence of the pihole script file, and if found, tries to run the <code>updatePihole<\/code> argument. <\/p>\n\n\n\n<p>Before running the state on a test system, the footer looked like:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Pi-hole\u00a0<a href=\"https:\/\/github.com\/pi-hole\/pi-hole\/releases\/v5.17.2\" target=\"_blank\" rel=\"noreferrer noopener\">v5.17.2<\/a>\u00a0FTL\u00a0<a href=\"https:\/\/github.com\/pi-hole\/FTL\/releases\/v5.23\" target=\"_blank\" rel=\"noreferrer noopener\">v5.23<\/a>\u00a0Web Interface\u00a0<a href=\"https:\/\/github.com\/pi-hole\/AdminLTE\/releases\/v5.20.2\" target=\"_blank\" rel=\"noreferrer noopener\">v5.20.2<\/a>\u00a0\u00b7\u00a0<a href=\"https:\/\/github.com\/pi-hole\/AdminLTE\/releases\/latest\" target=\"_blank\" rel=\"noreferrer noopener\">Update available!<\/a><\/p>\n<\/blockquote>\n\n\n\n<p>The stdout of the minion return stated:<br> <code>[i] Update local cache of available packages\u2026\\r\\u001b[K [\u2713] Update local cache of available packages\\n [i] Existing PHP installation detected : PHP version 7.3.31-1~deb10u5\\n [i] Checking for git\u2026\\r\\u001b[K [\u2713] Checking for git\\n [i] Checking for iproute2\u2026\\r\\u001b[K [\u2713] Checking for iproute2\\n [i] Checking for dialog\u2026\\r\\u001b[K [\u2713] Checking for dialog\\n [i] Checking for ca-certificates\u2026\\r\\u001b[K [\u2713] Checking for ca-certificates\\n\\n [i] Checking for updates\u2026\\n [i] Pi-hole Core:\\tup to date\\n [i] Web Interface:\\tupdate available\\n [i] FTL:\\t\\tup to date\\n\\n [i] Pi-hole Web Admin files out of date, updating local repo.\\n [i] Check for existing repository in \/var\/www\/html\/admin\u2026\\r\\u001b[K [\u2713] Check for existing repository in \/var\/www\/html\/admin\\n [i] Update repo in \/var\/www\/html\/admin\u2026HEAD is now at be05b0f v5.21 (#2860)\\n\\r\\u001b[K [\u2713] Update repo in \/var\/www\/html\/admin\\n\\n [i] If you had made any changes in '\/var\/www\/html\/admin\/', they have been stashed using 'git stash'\\n [i] Local version file information updated.<\/code><\/p>\n\n\n\n<p>After the state.apply operation completed, refreshing the web interface the footer changed to:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Pi-hole\u00a0<a href=\"https:\/\/github.com\/pi-hole\/pi-hole\/releases\/v5.17.2\" target=\"_blank\" rel=\"noreferrer noopener\">v5.17.2<\/a>\u00a0FTL\u00a0<a href=\"https:\/\/github.com\/pi-hole\/FTL\/releases\/v5.23\" target=\"_blank\" rel=\"noreferrer noopener\">v5.23<\/a>\u00a0Web Interface\u00a0<a href=\"https:\/\/github.com\/pi-hole\/AdminLTE\/releases\/v5.21\" target=\"_blank\" rel=\"noreferrer noopener\">v5.21<\/a><\/p>\n<\/blockquote>\n\n\n\n<p>We can see that the web interface was updated from v5.20.2 to v5.21.  <\/p>\n\n\n\n<p>I created a job to apply this state file, then created two schedules to stagger the patching to different minions on different days.  This was a pretty quick solution to keeping the pihole software up to date on a schedule, using the centralized scheduling &amp; reporting of Aria Automation Config.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve recently begun keeping components of my lab up to date using Aria Automation Config. I&#8217;ve scheduled a daily job to inventory Linux packages that need updated and a weekly task to update Linux VMs and reboot if necessary. Both &hellip; <a href=\"https:\/\/enterpriseadmins.org\/blog\/scripting\/keeping-pihole-up-to-date-with-aria-automation-config\/\">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-1894","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\/1894","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=1894"}],"version-history":[{"count":2,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/1894\/revisions"}],"predecessor-version":[{"id":1896,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/1894\/revisions\/1896"}],"wp:attachment":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/media?parent=1894"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/categories?post=1894"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/tags?post=1894"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}