<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>dword4</title><link href="https://dword4.github.io/" rel="alternate"/><link href="https://dword4.github.io/feeds/all.atom.xml" rel="self"/><id>https://dword4.github.io/</id><updated>2026-12-02T00:00:00-05:00</updated><subtitle>DevOps, Terraform, AWS and an over-engineered homelab run like production.</subtitle><entry><title>Identity &amp; SSO in the Homelab with Authentik</title><link href="https://dword4.github.io/homelab-authentik-sso.html" rel="alternate"/><published>2026-12-02T00:00:00-05:00</published><updated>2026-12-02T00:00:00-05:00</updated><author><name>dword4</name></author><id>tag:dword4.github.io,2026-12-02:/homelab-authentik-sso.html</id><summary type="html">&lt;p&gt;Every service in my homelab used to have its own login, its own password and its own idea of who the admin was. Here is how Authentik became the single front door, how &lt;span class="caps"&gt;OIDC&lt;/span&gt; and forward auth fit together, and why it only worked once the &lt;span class="caps"&gt;PKI&lt;/span&gt; was in&amp;nbsp;place.&lt;/p&gt;</summary><content type="html">&lt;p&gt;Before I had a proper identity layer, logging into my homelab looked a lot like logging into the internet circa 2005. Grafana had an admin account, Netbox had a different admin account, Proxmox had root plus whatever I created that week, and half of the remaining apps had a default password I had definitely meant to change. Every new service was another set of credentials going into the password manager, and taking access &lt;em&gt;away&lt;/em&gt; from something meant remembering every place it had been granted. This post is about how I fixed that with &lt;strong&gt;Authentik&lt;/strong&gt;, and the handful of things that tripped me up along the&amp;nbsp;way.&lt;/p&gt;
&lt;h2&gt;Why Run an IdP at&amp;nbsp;Home?&lt;/h2&gt;
&lt;p&gt;The obvious answer is convenience: one login, one &lt;span class="caps"&gt;MFA&lt;/span&gt; prompt, done. That is genuinely nice, but it is not really why I did&amp;nbsp;it.&lt;/p&gt;
&lt;p&gt;The real reason is the same reason I built the &lt;span class="caps"&gt;PKI&lt;/span&gt;. At work, identity is something that already exists. Someone wired up Okta or Entra years ago and you just click the tile. That makes it very easy to never actually learn how &lt;span class="caps"&gt;OIDC&lt;/span&gt; works, what a client secret is protecting, or why the redirect &lt;span class="caps"&gt;URI&lt;/span&gt; has to match exactly. Running my own identity provider forced me to learn all of that by breaking it&amp;nbsp;repeatedly.&lt;/p&gt;
&lt;p&gt;There is also a practical security angle. With one IdP in front of everything, I have one place to enforce &lt;span class="caps"&gt;MFA&lt;/span&gt;, one place to see who logged in where, and one place to turn somebody off. That is a much better story than &amp;#8220;I think I changed that&amp;nbsp;password.&amp;#8221;&lt;/p&gt;
&lt;h2&gt;Why&amp;nbsp;Authentik?&lt;/h2&gt;
&lt;p&gt;I looked at the usual suspects. &lt;strong&gt;Keycloak&lt;/strong&gt; is the heavyweight and very capable, but it felt like more Java than I wanted to babysit for a household. &lt;strong&gt;Authelia&lt;/strong&gt; is lean and great at forward auth, but I wanted a full IdP with a user portal and proper &lt;span class="caps"&gt;OIDC&lt;/span&gt;/&lt;span class="caps"&gt;SAML&lt;/span&gt; provider support. &lt;strong&gt;Authentik&lt;/strong&gt; landed in the middle: it speaks &lt;span class="caps"&gt;OIDC&lt;/span&gt;, &lt;span class="caps"&gt;SAML&lt;/span&gt;, &lt;span class="caps"&gt;LDAP&lt;/span&gt; and proxy auth, has a clean admin &lt;span class="caps"&gt;UI&lt;/span&gt;, and gives users an application portal that looks a lot like the Okta dashboard I stare at every day at&amp;nbsp;work.&lt;/p&gt;
&lt;p&gt;For deployment I opted to save a few headaches and simply rolled out a &lt;span class="caps"&gt;LXC&lt;/span&gt; container in Proxmox to proxmox, at some point I may go back and turn it into a docker container with a compose file but this works for&amp;nbsp;now.&lt;/p&gt;
&lt;h2&gt;How the Pieces Fit&amp;nbsp;Together&lt;/h2&gt;
&lt;p&gt;Authentik has its own vocabulary, and getting it straight early saves a lot of&amp;nbsp;confusion:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Concept&lt;/th&gt;
&lt;th&gt;What it actually is&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Provider&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;em&gt;How&lt;/em&gt; an app authenticates: OAuth2/&lt;span class="caps"&gt;OIDC&lt;/span&gt;, &lt;span class="caps"&gt;SAML&lt;/span&gt;, &lt;span class="caps"&gt;LDAP&lt;/span&gt; or Proxy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Application&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;em&gt;What&lt;/em&gt; the user sees in the portal, linked to exactly one provider&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Flow&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The sequence of steps a login (or enrollment, or recovery) goes through&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Stage&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A single step in a flow: identify the user, check a password, prompt for &lt;span class="caps"&gt;MFA&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Outpost&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A component that sits in front of apps that cannot do &lt;span class="caps"&gt;SSO&lt;/span&gt; themselves&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Policy&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Rules that decide whether a user can use an application or pass a stage&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Once that clicked, the setup for any new service became a predictable checklist: create the provider, create the application, bind a group policy so only the right people can see it, and plug the client details into the&amp;nbsp;app.&lt;/p&gt;
&lt;h2&gt;Apps That Speak &lt;span class="caps"&gt;OIDC&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;The best case is an application that supports &lt;span class="caps"&gt;OIDC&lt;/span&gt; natively. &lt;strong&gt;Grafana&lt;/strong&gt; and &lt;strong&gt;Netbox&lt;/strong&gt; both fall into this bucket, and they are where I&amp;nbsp;started.&lt;/p&gt;
&lt;p&gt;Grafana is a good example of how little config this actually takes.&amp;nbsp;Under &lt;code&gt;[auth.generic_oauth]&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;[auth.generic_oauth]&lt;/span&gt;
&lt;span class="na"&gt;enabled&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;true&lt;/span&gt;
&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;Authentik&lt;/span&gt;
&lt;span class="na"&gt;client_id&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;lt;from authentik&amp;gt;&lt;/span&gt;
&lt;span class="na"&gt;client_secret&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;lt;from infisical&amp;gt;&lt;/span&gt;
&lt;span class="na"&gt;scopes&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;openid email profile&lt;/span&gt;
&lt;span class="na"&gt;auth_url&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;https://auth.int.itsn.network/application/o/authorize/&lt;/span&gt;
&lt;span class="na"&gt;token_url&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;https://auth.int.itsn.network/application/o/token/&lt;/span&gt;
&lt;span class="na"&gt;api_url&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;https://auth.int.itsn.network/application/o/userinfo/&lt;/span&gt;
&lt;span class="na"&gt;role_attribute_path&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;contains(groups, &amp;#39;Grafana Admins&amp;#39;) &amp;amp;&amp;amp; &amp;#39;Admin&amp;#39; || &amp;#39;Viewer&amp;#39;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;That last line is the part I like the most. Grafana roles are driven entirely by Authentik group membership, so making someone an admin is a group change in one place rather than a setting buried inside Grafana. Netbox works the same way through its social auth backend, with groups mapped onto Netbox&amp;nbsp;permissions.&lt;/p&gt;
&lt;p&gt;Notice the client secret line. Those secrets live in &lt;strong&gt;Infisical&lt;/strong&gt; alongside everything else, not in a config file sitting in a repo. If I ever have to rotate one, it is a change in Infisical and a redeploy, not a scavenger&amp;nbsp;hunt.&lt;/p&gt;
&lt;h2&gt;Apps That&amp;nbsp;Don&amp;#8217;t&lt;/h2&gt;
&lt;p&gt;Not everything speaks &lt;span class="caps"&gt;OIDC&lt;/span&gt;. Plenty of self-hosted apps either have no authentication at all or have a single shared login that was clearly an afterthought. For those, Authentik&amp;#8217;s &lt;strong&gt;proxy provider&lt;/strong&gt; with an &lt;strong&gt;outpost&lt;/strong&gt; does the&amp;nbsp;work.&lt;/p&gt;
&lt;p&gt;The idea is simple: &lt;strong&gt;Nginx Proxy Manager&lt;/strong&gt; already sits in front of most of my web apps, so I configure it to check every request against the Authentik outpost (forward auth) before passing it through. If you do not have a valid session, you get bounced to the Authentik login page first. The app itself never knows anything&amp;nbsp;happened.&lt;/p&gt;
&lt;p&gt;It is not as elegant as native &lt;span class="caps"&gt;OIDC&lt;/span&gt;, since the app has no idea who you are and cannot do per-user permissions, but it turns &amp;#8220;anyone on the &lt;span class="caps"&gt;VLAN&lt;/span&gt; can open this&amp;#8221; into &amp;#8220;only people in the right group can open this,&amp;#8221; which is a big step up for very little&amp;nbsp;effort.&lt;/p&gt;
&lt;p&gt;At the moment only Grafana and Netbox are tied into Authentik however I am pondering more low-risk options to add into it as I am still somewhat wary of putting something like Forgejo behind it and risking breaking a lot of&amp;nbsp;things.&lt;/p&gt;
&lt;h2&gt;The &lt;span class="caps"&gt;PKI&lt;/span&gt;&amp;nbsp;Dependency&lt;/h2&gt;
&lt;p&gt;This is where the previous post comes back around. My first attempt at &lt;span class="caps"&gt;OIDC&lt;/span&gt; with Grafana failed with an error that, after a lot of squinting, boiled down to &amp;#8220;I do not trust the server you are sending me to.&amp;#8221; &lt;span class="caps"&gt;OIDC&lt;/span&gt; clients make back-channel calls to the IdP to exchange codes for tokens and fetch user info, and those calls verify &lt;span class="caps"&gt;TLS&lt;/span&gt;. A self-signed cert on Authentik meant every single integration was broken in a slightly different way, with a slightly different flag to ignore&amp;nbsp;it.&lt;/p&gt;
&lt;p&gt;Once Authentik had a real certificate issued from &lt;strong&gt;NestCA&lt;/strong&gt; via &lt;strong&gt;Certwarden&lt;/strong&gt;, and the NestCA root was in the trust store of every client, all of that went away. If you are planning to do &lt;span class="caps"&gt;SSO&lt;/span&gt; at home, do the &lt;span class="caps"&gt;PKI&lt;/span&gt; first. I did it in the wrong order and paid for&amp;nbsp;it.&lt;/p&gt;
&lt;h2&gt;Things That Bit&amp;nbsp;Me&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Redirect URIs are exact.&lt;/strong&gt; A trailing&amp;nbsp;slash, &lt;code&gt;http&lt;/code&gt; vs &lt;code&gt;https&lt;/code&gt;, or the wrong hostname and the login fails with an error that rarely tells you which one it&amp;nbsp;was.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Do not lock yourself out.&lt;/strong&gt; Keep a break-glass local admin account on Authentik itself and on anything critical like Proxmox. &lt;span class="caps"&gt;SSO&lt;/span&gt; is great right up until the IdP is the thing that is&amp;nbsp;down.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Logout is harder than login.&lt;/strong&gt; Logging out of an app does not log you out of Authentik, and vice versa. Set the end-session &lt;span class="caps"&gt;URL&lt;/span&gt; on clients that support it, and accept that some apps simply will not&amp;nbsp;cooperate.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Groups are the whole game.&lt;/strong&gt; It is tempting to assign apps to individual users when there are only a few of you. Do groups from the start; it costs nothing and you will want it&amp;nbsp;later.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Back it up.&lt;/strong&gt; Authentik is now a dependency for nearly everything. Its database belongs in the backup plan with the same priority as anything else that would ruin a&amp;nbsp;weekend.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Was It Worth&amp;nbsp;It?&lt;/h2&gt;
&lt;p&gt;Yes, and more than the &lt;span class="caps"&gt;PKI&lt;/span&gt; work, the payoff was immediate. Adding a new service now takes a few minutes in the Authentik &lt;span class="caps"&gt;UI&lt;/span&gt;, &lt;span class="caps"&gt;MFA&lt;/span&gt; happens in one place, and the password manager entry count stopped growing. Taking access away is a group change instead of a memory&amp;nbsp;test.&lt;/p&gt;
&lt;p&gt;More importantly, I finally understand what is happening when I click that &lt;span class="caps"&gt;SSO&lt;/span&gt; tile at work. Authorization codes, token endpoints, claims and scopes went from vocabulary I recognized to things I have debugged at 11pm. That is the whole point of the&amp;nbsp;homelab.&lt;/p&gt;
&lt;p&gt;Next up, I want to tie Forgejo and Infisical into Authentik as well so the last few holdouts finally get a single front&amp;nbsp;door.&lt;/p&gt;
&lt;p&gt;#Authentik #&lt;span class="caps"&gt;SSO&lt;/span&gt; #&lt;span class="caps"&gt;OIDC&lt;/span&gt; #Homelab&amp;nbsp;#Identity&lt;/p&gt;</content><category term="homelab"/></entry><entry><title>PKI in the Homelab</title><link href="https://dword4.github.io/homelab-pki.html" rel="alternate"/><published>2026-10-28T00:00:00-04:00</published><updated>2026-10-28T00:00:00-04:00</updated><author><name>dword4</name></author><id>tag:dword4.github.io,2026-10-28:/homelab-pki.html</id><summary type="html">&lt;p&gt;I got tired of clicking through certificate warnings and typing curl -k, so I built an internal &lt;span class="caps"&gt;CA&lt;/span&gt;. Here&amp;#8217;s how NestCA and Certwarden fit together, why distributing trust is the hard part, and what I&amp;#8217;d do&amp;nbsp;differently.&lt;/p&gt;</summary><content type="html">&lt;p&gt;For a long time my homelab had a dirty little secret: a browser full of &amp;#8220;Your connection is not private&amp;#8221; warnings that I had trained myself to click straight through, and a shell history littered&amp;nbsp;with &lt;code&gt;curl -k&lt;/code&gt;. I would never let that fly at work, so eventually I got tired of letting it fly at home. This is the story of how I ended up running my own certificate authority, and what I wish I had known before I&amp;nbsp;started.&lt;/p&gt;
&lt;h2&gt;Why&amp;nbsp;Bother?&lt;/h2&gt;
&lt;p&gt;The honest answer is that it started as annoyance and turned into a learning exercise. Once I had Authentik handing out &lt;span class="caps"&gt;SSO&lt;/span&gt; via &lt;span class="caps"&gt;OIDC&lt;/span&gt;, Forgejo running &lt;span class="caps"&gt;CI&lt;/span&gt;, Infisical holding secrets and a pile of other services all talking to each other over &lt;span class="caps"&gt;HTTPS&lt;/span&gt;, the self-signed cert shortcuts stopped being a minor nuisance and started being actual breakage. &lt;span class="caps"&gt;OIDC&lt;/span&gt; clients refuse to talk to an IdP they don&amp;#8217;t trust, &lt;span class="caps"&gt;CI&lt;/span&gt; runners fail builds on certificate errors, and every tool has its own special flag for ignoring them (none of which are the same flag,&amp;nbsp;naturally).&lt;/p&gt;
&lt;p&gt;The other reason is that &lt;span class="caps"&gt;PKI&lt;/span&gt; is one of those topics that is easy to hand-wave in a work environment because someone else set it up years ago. Building one from scratch forces you to actually understand what a trust chain is, who is vouching for whom, and what breaks when the answer is&amp;nbsp;nobody.&lt;/p&gt;
&lt;h2&gt;The&amp;nbsp;Setup&lt;/h2&gt;
&lt;p&gt;The short version of my current&amp;nbsp;layout:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;NestCA&lt;/strong&gt; is my internal certificate&amp;nbsp;authority&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Certwarden&lt;/strong&gt; sits in front of it and handles requesting, renewing and distributing certificates over &lt;span class="caps"&gt;ACME&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Technitium&lt;/strong&gt; serves&amp;nbsp;the &lt;code&gt;int.itsn.network&lt;/code&gt; zone so everything has a real&amp;nbsp;hostname&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Nginx Proxy Manager&lt;/strong&gt; terminates &lt;span class="caps"&gt;TLS&lt;/span&gt; for a lot of the web&amp;nbsp;apps&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Every service that lives&amp;nbsp;under &lt;code&gt;*.int.itsn.network&lt;/code&gt; gets a valid certificate, and I went with a wildcard to keep things simple. Is a wildcard the most security-minded choice? No, one stolen key opens up the whole domain. But for a network where I am the only admin and the alternative is a hundred individual certs to babysit, I was happy to make that&amp;nbsp;trade.&lt;/p&gt;
&lt;p&gt;&amp;#91;&lt;span class="caps"&gt;DREW&lt;/span&gt;: add a sentence or two here on how NestCA is built (software, root vs intermediate, where the root key lives) and how long your certs are valid for. I did not want to guess at those&amp;nbsp;details.]&lt;/p&gt;
&lt;h2&gt;Certwarden Is the Part That Makes It&amp;nbsp;Livable&lt;/h2&gt;
&lt;p&gt;Issuing a certificate once is easy. Issuing it every few weeks forever and getting the new one to the right place is the part that kills homelab &lt;span class="caps"&gt;PKI&lt;/span&gt; projects. Anyone can follow a guide and generate a cert, then forget about it until it expires on a Saturday night and half the house stops&amp;nbsp;working.&lt;/p&gt;
&lt;p&gt;Certwarden changed that for me by treating certificates as something with a lifecycle rather than a file I generated once. It requests them, renews them before they expire, and gives the consuming services a stable place to fetch the current version. The first time a certificate rotated on its own and nothing noticed, I stared at the logs for a while waiting for the other shoe to drop. It never&amp;nbsp;did.&lt;/p&gt;
&lt;h2&gt;Distributing Trust (The Actually Painful&amp;nbsp;Part)&lt;/h2&gt;
&lt;p&gt;Here is the thing nobody warns you about: running a &lt;span class="caps"&gt;CA&lt;/span&gt; is the easy half. The hard half is getting every single client to trust&amp;nbsp;it.&lt;/p&gt;
&lt;p&gt;Browsers and workstations are the simple case, you import the root once and you are done. The pain shows up in all the places you forget about. Forgejo Actions runners need to trust NestCA or every pipeline that talks to an internal service falls over. Containers carry their own trust stores, so a service that works fine on the host can fail the instant it runs in a container that has never heard of your &lt;span class="caps"&gt;CA&lt;/span&gt;. Wiring up the Infisical integration for my pipelines meant chasing down &lt;span class="caps"&gt;TLS&lt;/span&gt; chain problems in more than one place, and at least once the mysterious &amp;#8220;&lt;span class="caps"&gt;TLS&lt;/span&gt; issue&amp;#8221; I spent an evening on turned out to be a typo in the hostname.&amp;nbsp;Classic.&lt;/p&gt;
&lt;p&gt;The lesson I took away is to treat the trust store like any other piece of configuration. Put the root cert in your Ansible roles and your base images from day one, and you stop discovering missing trust one broken pipeline at a&amp;nbsp;time.&lt;/p&gt;
&lt;h2&gt;What I Would Do&amp;nbsp;Differently&lt;/h2&gt;
&lt;p&gt;If I were starting over I would be more deliberate up front about the boring&amp;nbsp;things:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Decide how the root and intermediates are structured &lt;em&gt;before&lt;/em&gt; issuing anything, because changing it later means re-trusting&amp;nbsp;everywhere&lt;/li&gt;
&lt;li&gt;Bake the &lt;span class="caps"&gt;CA&lt;/span&gt; into base images and configuration management&amp;nbsp;immediately&lt;/li&gt;
&lt;li&gt;Put expiry monitoring in place early. Prometheus and Grafana are already in my stack, so watching certificate expiry dates is a small amount of work that saves a very annoying&amp;nbsp;outage&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Was It Worth&amp;nbsp;It?&lt;/h2&gt;
&lt;p&gt;Absolutely, though not for the reason I expected. The padlock in the browser is nice, and no longer&amp;nbsp;typing &lt;code&gt;-k&lt;/code&gt; is nicer. What I really got was a much better mental model of how trust works, which has paid off at work more than&amp;nbsp;once.&lt;/p&gt;
&lt;p&gt;The pain is front-loaded. It is miserable until the first time everything just works, and then it quietly stops being something you think about at all. I think that is about the best thing you can say about any piece of&amp;nbsp;infrastructure.&lt;/p&gt;
&lt;p&gt;#&lt;span class="caps"&gt;PKI&lt;/span&gt; #Homelab #&lt;span class="caps"&gt;TLS&lt;/span&gt;&amp;nbsp;#Certwarden&lt;/p&gt;</content><category term="homelab"/></entry><entry><title>My Homelab - Building a Production-Grade Network at Home</title><link href="https://dword4.github.io/homelab-overview-infrastructure-tour.html" rel="alternate"/><published>2026-06-08T00:00:00-04:00</published><updated>2026-06-08T00:00:00-04:00</updated><author><name>dword4</name></author><id>tag:dword4.github.io,2026-06-08:/homelab-overview-infrastructure-tour.html</id><summary type="html">&lt;p&gt;A tour of my home lab infrastructure — from Cisco switching and Ruckus APs through Proxmox/Unraid compute, &lt;span class="caps"&gt;VLAN&lt;/span&gt; segmentation, internal &lt;span class="caps"&gt;PKI&lt;/span&gt;, &lt;span class="caps"&gt;SSO&lt;/span&gt; with Authentik, a full Grafana/Loki observability stack, and GitOps-style &lt;span class="caps"&gt;CI&lt;/span&gt;/&lt;span class="caps"&gt;CD&lt;/span&gt; with Forgejo and Infisical. Built for learning, operated like&amp;nbsp;production.&lt;/p&gt;</summary><content type="html">&lt;p&gt;Over the years, my homelab has evolved from a few spare machines running random services into something that genuinely resembles enterprise infrastructure — complete with VLANs, &lt;span class="caps"&gt;SSO&lt;/span&gt;, internal &lt;span class="caps"&gt;PKI&lt;/span&gt;, &lt;span class="caps"&gt;CI&lt;/span&gt;/&lt;span class="caps"&gt;CD&lt;/span&gt; pipelines, and a full observability stack. Here&amp;#8217;s a tour of what I&amp;#8217;m running and&amp;nbsp;why.&lt;/p&gt;
&lt;hr&gt;
&lt;h2&gt;The&amp;nbsp;Hardware&lt;/h2&gt;
&lt;p&gt;The foundation is a &lt;strong&gt;Cisco &lt;span class="caps"&gt;C891F&lt;/span&gt;&lt;/strong&gt; router paired with a &lt;strong&gt;Cisco &lt;span class="caps"&gt;C3560CX&lt;/span&gt;&lt;/strong&gt; switch, giving me proper enterprise-grade L3 switching at the edge. Wireless is handled by a pair of &lt;strong&gt;Ruckus R710&lt;/strong&gt; access points running Unleashed firmware — these are enterprise APs and the Wi-Fi quality shows&amp;nbsp;it.&lt;/p&gt;
&lt;p&gt;For compute, I run two &lt;strong&gt;Proxmox&lt;/strong&gt; hypervisor nodes and two &lt;strong&gt;Unraid&lt;/strong&gt; servers alongside a bare metal Linux dev machine. A &lt;strong&gt;Raspberry Pi 4&lt;/strong&gt; and &lt;strong&gt;Pi 5&lt;/strong&gt; round out the fleet, handling lightweight workloads and edge tasks. It&amp;#8217;s more iron than most people have in a datacenter closet, but there&amp;#8217;s always something to run on&amp;nbsp;it.&lt;/p&gt;
&lt;hr&gt;
&lt;h2&gt;Network&amp;nbsp;Segmentation&lt;/h2&gt;
&lt;p&gt;The network is divided into four&amp;nbsp;VLANs:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;span class="caps"&gt;VLAN&lt;/span&gt;&lt;/th&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;Trusted&lt;/td&gt;
&lt;td&gt;Daily drivers, workstations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;td&gt;IoT&lt;/td&gt;
&lt;td&gt;Smart home devices, cameras&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;30&lt;/td&gt;
&lt;td&gt;Guest&lt;/td&gt;
&lt;td&gt;Visitor Wi-Fi&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;99&lt;/td&gt;
&lt;td&gt;Management&lt;/td&gt;
&lt;td&gt;Infrastructure access&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;span class="caps"&gt;DNS&lt;/span&gt; is handled internally by &lt;strong&gt;Technitium&lt;/strong&gt;&amp;nbsp;at &lt;code&gt;192.168.99.3&lt;/code&gt;, resolving&amp;nbsp;the &lt;code&gt;int.itsn.network&lt;/code&gt; domain for all internal services. This makes service discovery clean and consistent — every self-hosted app gets a proper&amp;nbsp;hostname.&lt;/p&gt;
&lt;hr&gt;
&lt;h2&gt;Identity &lt;span class="amp"&gt;&amp;amp;&lt;/span&gt; &lt;span class="caps"&gt;PKI&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;One of the more &amp;#8220;enterprise-y&amp;#8221; things I&amp;#8217;ve built is a proper identity layer. &lt;strong&gt;Authentik&lt;/strong&gt; serves as my &lt;span class="caps"&gt;SSO&lt;/span&gt;/IdP — think of it as a self-hosted Okta portal. Services like Grafana and Netbox authenticate via &lt;span class="caps"&gt;OIDC&lt;/span&gt;, so there&amp;#8217;s a single login experience across the&amp;nbsp;stack.&lt;/p&gt;
&lt;p&gt;Certificates are managed by &lt;strong&gt;Certwarden&lt;/strong&gt;, backed by an internal &lt;span class="caps"&gt;CA&lt;/span&gt; called &lt;strong&gt;NestCA&lt;/strong&gt;. Every service&amp;nbsp;on &lt;code&gt;*.int.itsn.network&lt;/code&gt; gets a valid &lt;span class="caps"&gt;TLS&lt;/span&gt; cert via wildcard, which means no browser warnings and&amp;nbsp;no &lt;code&gt;curl -k&lt;/code&gt; shortcuts. Real &lt;span class="caps"&gt;TLS&lt;/span&gt;,&amp;nbsp;internally.&lt;/p&gt;
&lt;hr&gt;
&lt;h2&gt;Observability&lt;/h2&gt;
&lt;p&gt;The observability stack centers on &lt;strong&gt;Grafana&lt;/strong&gt; with &lt;strong&gt;Prometheus&lt;/strong&gt; for metrics and &lt;strong&gt;Loki + Promtail&lt;/strong&gt; for log aggregation. Logs flow in from Proxmox hypervisors, Ruckus APs (via rsyslog), and various services — all centralized and queryable from a single Grafana&amp;nbsp;instance.&lt;/p&gt;
&lt;p&gt;This isn&amp;#8217;t just a dashboard for show. When something breaks at 2am, the logs are&amp;nbsp;there.&lt;/p&gt;
&lt;hr&gt;
&lt;h2&gt;&lt;span class="caps"&gt;CI&lt;/span&gt;/&lt;span class="caps"&gt;CD&lt;/span&gt; &lt;span class="amp"&gt;&amp;amp;&lt;/span&gt;&amp;nbsp;Secrets&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Forgejo&lt;/strong&gt; (a self-hosted Gitea fork) hosts my code, and &lt;strong&gt;Forgejo Actions&lt;/strong&gt; handles &lt;span class="caps"&gt;CI&lt;/span&gt;/&lt;span class="caps"&gt;CD&lt;/span&gt; — pipelines that build, test, and deploy against internal infrastructure with &lt;span class="caps"&gt;SSL&lt;/span&gt; trust properly configured against&amp;nbsp;NestCA.&lt;/p&gt;
&lt;p&gt;Secrets are managed by a self-hosted &lt;strong&gt;Infisical&lt;/strong&gt; instance&amp;nbsp;at &lt;code&gt;infisical.int.itsn.network&lt;/code&gt;. Machine identities authenticate to pull secrets at runtime, keeping credentials out of repos and environment&amp;nbsp;variables.&lt;/p&gt;
&lt;hr&gt;
&lt;h2&gt;Infrastructure as&amp;nbsp;Code&lt;/h2&gt;
&lt;p&gt;&lt;span class="caps"&gt;VM&lt;/span&gt; provisioning on Proxmox is fully automated with &lt;strong&gt;Terraform&lt;/strong&gt; (using&amp;nbsp;the &lt;code&gt;bpg/proxmox&lt;/code&gt; provider) and &lt;strong&gt;Ansible&lt;/strong&gt; for configuration management. Cloud-init Ubuntu 24.04 templates make spinning up new VMs a&amp;nbsp;single &lt;code&gt;terraform apply&lt;/code&gt;. &lt;span class="caps"&gt;AWS&lt;/span&gt; infrastructure is also managed via&amp;nbsp;Terraform.&lt;/p&gt;
&lt;hr&gt;
&lt;h2&gt;Self-Hosted&amp;nbsp;Services&lt;/h2&gt;
&lt;p&gt;The application layer is dense. A sampling of what&amp;#8217;s&amp;nbsp;running:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Nginx Proxy Manager&lt;/strong&gt; — reverse proxy and &lt;span class="caps"&gt;SSL&lt;/span&gt;&amp;nbsp;termination&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Netbox&lt;/strong&gt; — &lt;span class="caps"&gt;IPAM&lt;/span&gt; and network&amp;nbsp;documentation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bookstack&lt;/strong&gt; — internal&amp;nbsp;wiki&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Jellyfin + arr stack&lt;/strong&gt; — media&amp;nbsp;server&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Home Assistant&lt;/strong&gt; — home automation with Zigbee, Node-&lt;span class="caps"&gt;RED&lt;/span&gt;, Frigate &lt;span class="caps"&gt;NVR&lt;/span&gt; (object detection, &lt;span class="caps"&gt;LPR&lt;/span&gt;, face recognition), and SmartCast &lt;span class="caps"&gt;TV&lt;/span&gt;&amp;nbsp;control&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Meshtastic/LoRa&lt;/strong&gt; — off-grid mesh networking&amp;nbsp;experiments&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2&gt;Lessons&amp;nbsp;Learned&lt;/h2&gt;
&lt;p&gt;Running homelab infrastructure at this scale teaches you things you can&amp;#8217;t get from a&amp;nbsp;tutorial:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;span class="caps"&gt;PKI&lt;/span&gt; is hard until it isn&amp;#8217;t.&lt;/strong&gt; Getting internal &lt;span class="caps"&gt;TLS&lt;/span&gt; right — &lt;span class="caps"&gt;CA&lt;/span&gt; trust, cert distribution, mTLS — is painful once and painless&amp;nbsp;forever.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Secrets management matters even at home.&lt;/strong&gt; Hardcoded credentials in&amp;nbsp;a &lt;code&gt;docker-compose.yml&lt;/code&gt; are a bad habit at any&amp;nbsp;scale.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Observability is not optional.&lt;/strong&gt; If you can&amp;#8217;t see what&amp;#8217;s happening, you&amp;#8217;re just&amp;nbsp;guessing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Automation compounds.&lt;/strong&gt; Every hour spent on Terraform and Ansible pays back many times over.
The homelab is never &amp;#8220;done&amp;#8221; — there&amp;#8217;s always another service to integrate, another pipeline to harden, another protocol to explore. That&amp;#8217;s the&amp;nbsp;point.&lt;/li&gt;
&lt;/ul&gt;</content><category term="homelab"/></entry><entry><title>Terraform Basics - Importing Existing Resources</title><link href="https://dword4.github.io/terraform-basics-importing.html" rel="alternate"/><published>2026-05-13T00:00:00-04:00</published><updated>2026-05-13T00:00:00-04:00</updated><author><name>dword4</name></author><id>tag:dword4.github.io,2026-05-13:/terraform-basics-importing.html</id><summary type="html">&lt;p&gt;Very basic introduction to importing existing &lt;span class="caps"&gt;AWS&lt;/span&gt;&amp;nbsp;resources&lt;/p&gt;</summary><content type="html">&lt;p&gt;So you have inherited some &lt;span class="caps"&gt;AWS&lt;/span&gt; resources that are not yet in Terraform, but its not feasible to completely rebuild them from scratch without a huge interruption to services. This is where importing comes into play, its not always the most elegant of processes but it helps avoid rebuilding things to get them into&amp;nbsp;IaC.&lt;/p&gt;
&lt;p&gt;Lets say we have a &lt;span class="caps"&gt;VPC&lt;/span&gt; that already exists in &lt;span class="caps"&gt;AWS&lt;/span&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;aws&lt;span class="w"&gt; &lt;/span&gt;ec2&lt;span class="w"&gt; &lt;/span&gt;describe-vpcs&lt;span class="w"&gt; &lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Vpcs&amp;quot;&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;OwnerId&amp;quot;&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;123456789012&amp;quot;&lt;/span&gt;,
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;InstanceTenancy&amp;quot;&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;default&amp;quot;&lt;/span&gt;,
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;CidrBlockAssociationSet&amp;quot;&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;
&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;                    &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;AssociationId&amp;quot;&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;vpc-cidr-assoc-00000000&amp;quot;&lt;/span&gt;,
&lt;span class="w"&gt;                    &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;CidrBlock&amp;quot;&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;172.31.0.0/16&amp;quot;&lt;/span&gt;,
&lt;span class="w"&gt;                    &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;CidrBlockState&amp;quot;&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;                        &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;State&amp;quot;&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;associated&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;                    &lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;,
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;IsDefault&amp;quot;&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;true,
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Tags&amp;quot;&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt;,
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;VpcId&amp;quot;&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;vpc-00000000&amp;quot;&lt;/span&gt;,
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;State&amp;quot;&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;available&amp;quot;&lt;/span&gt;,
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;CidrBlock&amp;quot;&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;172.31.0.0/16&amp;quot;&lt;/span&gt;,
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;DhcpOptionsId&amp;quot;&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;dopt-00000000&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;In order to do an import our code first has to have a very loose idea of what we are going to import, so lets setup for that in our main.tf file. We will assume safely that you have already run terraform init to setup&amp;nbsp;everything.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;resource&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;aws_vpc&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;test_vpc&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;# imported resource&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If you were to run an init and plan on this it would want to create the resource named test-vpc, however we don&amp;#8217;t want to create anything we want to import. Remember the VpcId from earlier when we looked at the available VPCs? We need to use that with import, it should look like&amp;nbsp;this&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;terraform&lt;span class="w"&gt; &lt;/span&gt;import&lt;span class="w"&gt; &lt;/span&gt;aws_vpc.test_vpc&lt;span class="w"&gt; &lt;/span&gt;vpc-00000000
aws_vpc.test_vpc:&lt;span class="w"&gt; &lt;/span&gt;Importing&lt;span class="w"&gt; &lt;/span&gt;from&lt;span class="w"&gt; &lt;/span&gt;ID&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;vpc-00000000&amp;quot;&lt;/span&gt;...
aws_vpc.test_vpc:&lt;span class="w"&gt; &lt;/span&gt;Import&lt;span class="w"&gt; &lt;/span&gt;prepared!
&lt;span class="w"&gt;  &lt;/span&gt;Prepared&lt;span class="w"&gt; &lt;/span&gt;aws_vpc&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;import
aws_vpc.test_vpc:&lt;span class="w"&gt; &lt;/span&gt;Refreshing&lt;span class="w"&gt; &lt;/span&gt;state...&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;vpc-00000000&lt;span class="o"&gt;]&lt;/span&gt;

Import&lt;span class="w"&gt; &lt;/span&gt;successful!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by&amp;nbsp;Terraform.&lt;/p&gt;
&lt;p&gt;If you look at the main.tf it still looks the same, nothing special about it but if we look at the actual terraform state we now see the test_vpc resource we&amp;nbsp;imported.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;terraform&lt;span class="w"&gt; &lt;/span&gt;state&lt;span class="w"&gt; &lt;/span&gt;list
aws_vpc.test_vpc
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And to look at the contents of that&amp;nbsp;resource&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;terraform&lt;span class="w"&gt; &lt;/span&gt;state&lt;span class="w"&gt; &lt;/span&gt;show&lt;span class="w"&gt; &lt;/span&gt;aws_vpc.test_vpc
&lt;span class="c1"&gt;# aws_vpc.test_vpc:&lt;/span&gt;
resource&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;aws_vpc&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;test_vpc&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;arn&lt;/span&gt;&lt;span class="w"&gt;                                  &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;arn:aws:ec2:us-east-1:123456789012:vpc/vpc-00000000&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;assign_generated_ipv6_cidr_block&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;cidr_block&lt;/span&gt;&lt;span class="w"&gt;                           &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;172.31.0.0/16&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;default_network_acl_id&lt;/span&gt;&lt;span class="w"&gt;               &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;acl-00000000&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;default_route_table_id&lt;/span&gt;&lt;span class="w"&gt;               &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;rtb-00000000&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;default_security_group_id&lt;/span&gt;&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;sg-00000000&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;dhcp_options_id&lt;/span&gt;&lt;span class="w"&gt;                      &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;dopt-00000000&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;enable_dns_hostnames&lt;/span&gt;&lt;span class="w"&gt;                 &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;enable_dns_support&lt;/span&gt;&lt;span class="w"&gt;                   &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;enable_network_address_usage_metrics&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;id&lt;/span&gt;&lt;span class="w"&gt;                                   &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;vpc-00000000&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;instance_tenancy&lt;/span&gt;&lt;span class="w"&gt;                     &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;default&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;ipv6_association_id&lt;/span&gt;&lt;span class="w"&gt;                  &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;null
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;ipv6_cidr_block&lt;/span&gt;&lt;span class="w"&gt;                      &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;null
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;ipv6_cidr_block_network_border_group&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;null
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;ipv6_ipam_pool_id&lt;/span&gt;&lt;span class="w"&gt;                    &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;null
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;ipv6_netmask_length&lt;/span&gt;&lt;span class="w"&gt;                  &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;main_route_table_id&lt;/span&gt;&lt;span class="w"&gt;                  &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;rtb-00000000&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;owner_id&lt;/span&gt;&lt;span class="w"&gt;                             &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;123456789012&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;region&lt;/span&gt;&lt;span class="w"&gt;                               &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;us-east-1&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;tags&lt;/span&gt;&lt;span class="w"&gt;                                 &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{}&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;tags_all&lt;/span&gt;&lt;span class="w"&gt;                             &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now to get our main.tf to be more reasonable and show us some of the thing configured about the &lt;span class="caps"&gt;VPC&lt;/span&gt; we have to move the contents of that resource from the state file into main.tf which should look like the below. You may notice that some values are not brought over like arn, id, tags_all and a bunch of default_ items, the rule here is if its something that would be automatically decided based on the result of applying (aka not available until the vpc is created) then those values do not belong in main.tf and terraform will tell you as much if you run a plan with the values present in the file. Depending on the resource imported this can result in a little trial-and-error to find out what all is not&amp;nbsp;needed.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;resource&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;aws_vpc&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;test_vpc&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;assign_generated_ipv6_cidr_block&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;cidr_block&lt;/span&gt;&lt;span class="w"&gt;                           &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;172.31.0.0/16&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;enable_dns_hostnames&lt;/span&gt;&lt;span class="w"&gt;                 &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;enable_dns_support&lt;/span&gt;&lt;span class="w"&gt;                   &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;enable_network_address_usage_metrics&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;instance_tenancy&lt;/span&gt;&lt;span class="w"&gt;                     &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;default&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;region&lt;/span&gt;&lt;span class="w"&gt;                               &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;us-east-1&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;tags&lt;/span&gt;&lt;span class="w"&gt;                                 &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Once you have all the non-needed items removed from the terraform code you plan should come back looking clean like the output&amp;nbsp;below&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;terraform&lt;span class="w"&gt; &lt;/span&gt;plan
aws_vpc.test_vpc:&lt;span class="w"&gt; &lt;/span&gt;Refreshing&lt;span class="w"&gt; &lt;/span&gt;state...&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;vpc-00000000&lt;span class="o"&gt;]&lt;/span&gt;

No&lt;span class="w"&gt; &lt;/span&gt;changes.&lt;span class="w"&gt; &lt;/span&gt;Your&lt;span class="w"&gt; &lt;/span&gt;infrastructure&lt;span class="w"&gt; &lt;/span&gt;matches&lt;span class="w"&gt; &lt;/span&gt;the&lt;span class="w"&gt; &lt;/span&gt;configuration.

Terraform&lt;span class="w"&gt; &lt;/span&gt;has&lt;span class="w"&gt; &lt;/span&gt;compared&lt;span class="w"&gt; &lt;/span&gt;your&lt;span class="w"&gt; &lt;/span&gt;real&lt;span class="w"&gt; &lt;/span&gt;infrastructure&lt;span class="w"&gt; &lt;/span&gt;against&lt;span class="w"&gt; &lt;/span&gt;your&lt;span class="w"&gt; &lt;/span&gt;configuration&lt;span class="w"&gt; &lt;/span&gt;and&lt;span class="w"&gt; &lt;/span&gt;found&lt;span class="w"&gt; &lt;/span&gt;no&lt;span class="w"&gt; &lt;/span&gt;differences,&lt;span class="w"&gt; &lt;/span&gt;so&lt;span class="w"&gt; &lt;/span&gt;no&lt;span class="w"&gt; &lt;/span&gt;changes&lt;span class="w"&gt; &lt;/span&gt;are&lt;span class="w"&gt; &lt;/span&gt;needed.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;From here we can add resources, such as a subnet and the code treats it as if the item was always present in the&amp;nbsp;state&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;cat&lt;span class="w"&gt; &lt;/span&gt;main.tf
resource&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;aws_vpc&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;test_vpc&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;assign_generated_ipv6_cidr_block&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;cidr_block&lt;/span&gt;&lt;span class="w"&gt;                           &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;172.31.0.0/16&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;enable_dns_hostnames&lt;/span&gt;&lt;span class="w"&gt;                 &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;enable_dns_support&lt;/span&gt;&lt;span class="w"&gt;                   &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;enable_network_address_usage_metrics&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;instance_tenancy&lt;/span&gt;&lt;span class="w"&gt;                     &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;default&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;region&lt;/span&gt;&lt;span class="w"&gt;                               &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;us-east-1&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;tags&lt;/span&gt;&lt;span class="w"&gt;                                 &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

resource&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;aws_subnet&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;test_subnet&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;vpc_id&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;aws_vpc.test_vpc.id
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;cidr_block&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;172.31.1.0/24&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;availability_zone&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;us-east-1a&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;map_public_ip_on_launch&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;tags&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;Name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;test_subnet&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

$&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;terraform&lt;span class="w"&gt; &lt;/span&gt;plan
aws_vpc.test_vpc:&lt;span class="w"&gt; &lt;/span&gt;Refreshing&lt;span class="w"&gt; &lt;/span&gt;state...&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;vpc-00000000&lt;span class="o"&gt;]&lt;/span&gt;

Terraform&lt;span class="w"&gt; &lt;/span&gt;used&lt;span class="w"&gt; &lt;/span&gt;the&lt;span class="w"&gt; &lt;/span&gt;selected&lt;span class="w"&gt; &lt;/span&gt;providers&lt;span class="w"&gt; &lt;/span&gt;to&lt;span class="w"&gt; &lt;/span&gt;generate&lt;span class="w"&gt; &lt;/span&gt;the&lt;span class="w"&gt; &lt;/span&gt;following&lt;span class="w"&gt; &lt;/span&gt;execution&lt;span class="w"&gt; &lt;/span&gt;plan.&lt;span class="w"&gt; &lt;/span&gt;Resource&lt;span class="w"&gt; &lt;/span&gt;actions&lt;span class="w"&gt; &lt;/span&gt;are&lt;span class="w"&gt; &lt;/span&gt;indicated&lt;span class="w"&gt; &lt;/span&gt;with&lt;span class="w"&gt; &lt;/span&gt;the&lt;span class="w"&gt; &lt;/span&gt;following&lt;span class="w"&gt; &lt;/span&gt;symbols:
&lt;span class="w"&gt;  &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;create

Terraform&lt;span class="w"&gt; &lt;/span&gt;will&lt;span class="w"&gt; &lt;/span&gt;perform&lt;span class="w"&gt; &lt;/span&gt;the&lt;span class="w"&gt; &lt;/span&gt;following&lt;span class="w"&gt; &lt;/span&gt;actions:

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;# aws_subnet.test_subnet will be created&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;resource&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;aws_subnet&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;test_subnet&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;arn&lt;/span&gt;&lt;span class="w"&gt;                                            &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;known&lt;span class="w"&gt; &lt;/span&gt;after&lt;span class="w"&gt; &lt;/span&gt;apply&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;assign_ipv6_address_on_creation&lt;/span&gt;&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;availability_zone&lt;/span&gt;&lt;span class="w"&gt;                              &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;us-east-1a&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;availability_zone_id&lt;/span&gt;&lt;span class="w"&gt;                           &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;known&lt;span class="w"&gt; &lt;/span&gt;after&lt;span class="w"&gt; &lt;/span&gt;apply&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;cidr_block&lt;/span&gt;&lt;span class="w"&gt;                                     &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;172.31.1.0/24&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;enable_dns64&lt;/span&gt;&lt;span class="w"&gt;                                   &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;enable_resource_name_dns_a_record_on_launch&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;enable_resource_name_dns_aaaa_record_on_launch&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;id&lt;/span&gt;&lt;span class="w"&gt;                                             &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;known&lt;span class="w"&gt; &lt;/span&gt;after&lt;span class="w"&gt; &lt;/span&gt;apply&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;ipv6_cidr_block&lt;/span&gt;&lt;span class="w"&gt;                                &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;known&lt;span class="w"&gt; &lt;/span&gt;after&lt;span class="w"&gt; &lt;/span&gt;apply&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;ipv6_cidr_block_association_id&lt;/span&gt;&lt;span class="w"&gt;                 &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;known&lt;span class="w"&gt; &lt;/span&gt;after&lt;span class="w"&gt; &lt;/span&gt;apply&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;ipv6_native&lt;/span&gt;&lt;span class="w"&gt;                                    &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;map_public_ip_on_launch&lt;/span&gt;&lt;span class="w"&gt;                        &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;owner_id&lt;/span&gt;&lt;span class="w"&gt;                                       &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;known&lt;span class="w"&gt; &lt;/span&gt;after&lt;span class="w"&gt; &lt;/span&gt;apply&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;private_dns_hostname_type_on_launch&lt;/span&gt;&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;known&lt;span class="w"&gt; &lt;/span&gt;after&lt;span class="w"&gt; &lt;/span&gt;apply&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;region&lt;/span&gt;&lt;span class="w"&gt;                                         &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;us-east-1&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;tags&lt;/span&gt;&lt;span class="w"&gt;                                           &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;          &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Name&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;test_subnet&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;tags_all&lt;/span&gt;&lt;span class="w"&gt;                                       &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;          &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Name&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;test_subnet&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;+&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;vpc_id&lt;/span&gt;&lt;span class="w"&gt;                                         &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;vpc-00000000&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;

Plan:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;to&lt;span class="w"&gt; &lt;/span&gt;add,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;to&lt;span class="w"&gt; &lt;/span&gt;change,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;to&lt;span class="w"&gt; &lt;/span&gt;destroy.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="programming"/></entry><entry><title>Looping Unknown API Results</title><link href="https://dword4.github.io/api-results-loop.html" rel="alternate"/><published>2025-12-12T00:00:00-05:00</published><updated>2025-12-12T00:00:00-05:00</updated><author><name>dword4</name></author><id>tag:dword4.github.io,2025-12-12:/api-results-loop.html</id><summary type="html">&lt;p&gt;Dealing with APIs that return unknown numbers of&amp;nbsp;results&lt;/p&gt;</summary><content type="html">&lt;p&gt;Some APIs do not tell you how many results you have to work with, so you end up blindly looping until a failure which is not generally&amp;nbsp;ideal. &lt;/p&gt;
&lt;p&gt;&lt;code&gt;api/v1/projects&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;Take the endpoint above, lets say it takes two possible&amp;nbsp;parameters&lt;/p&gt;
&lt;p&gt;&lt;code&gt;size&lt;/code&gt; which represents the number of results returned by the current&amp;nbsp;call
&lt;code&gt;offset&lt;/code&gt; which means where in the unknown list of projects we want to start the retrieval of the &lt;strong&gt;size&lt;/strong&gt; number of&amp;nbsp;results&lt;/p&gt;
&lt;p&gt;So we would get a bunch of calls like&amp;nbsp;this&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;api/v1/projects?size=20&amp;amp;offset=0
api/v1/projects?size=20&amp;amp;offset=20
api/v1/projects?size=20&amp;amp;offset=40
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;But we must remember we don&amp;#8217;t &lt;em&gt;know&lt;/em&gt; how many of these calls we may need to make without cheating and looking at say the web interface this &lt;span class="caps"&gt;API&lt;/span&gt; is used to build. To help simulate this experience I threw together a very rudimentary script to imitate the idea of an unknown sized list we can use to work&amp;nbsp;against&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;random&lt;/span&gt;

&lt;span class="n"&gt;MAX&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;randint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;SIZE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;

&lt;span class="n"&gt;API&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;MAX&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="n"&gt;API&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="s2"&gt;&amp;quot;id&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Project &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;&amp;quot;rulesets&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Ruleset &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;randint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;))],&lt;/span&gt;
    &lt;span class="s2"&gt;&amp;quot;rules&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;randint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;So this gives us a randomized list called &lt;strong&gt;&lt;span class="caps"&gt;API&lt;/span&gt;&lt;/strong&gt; which we can work against to figure out a sensible looping strategy. Since we don&amp;#8217;t know the size of &lt;strong&gt;&lt;span class="caps"&gt;API&lt;/span&gt;&lt;/strong&gt; in theory, we cant use a for loop without some rather complex conditions, so lets try something much&amp;nbsp;simpler.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# loop contents&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;While loops are ideal for this since we can just do a True/False loop because we either get data we can use from the &lt;span class="caps"&gt;API&lt;/span&gt; or we don&amp;#8217;t, there is no other potential situation (minus obvious outliers like ratelimits, authentication failures, etc) we would occur that the loop needs to&amp;nbsp;handle&lt;/p&gt;
&lt;p&gt;To facilitate this and make things more readable we need a function that will grab a chunk of results from &lt;strong&gt;&lt;span class="caps"&gt;API&lt;/span&gt;&lt;/strong&gt; and return them, that way we can separate out logic a&amp;nbsp;bit.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;grab_projects&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;offset&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;

&lt;span class="n"&gt;url_projects&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;https://some.api.host/api/v1/projects?limit=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;amp;offset=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;offset&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Fetching projects from &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;offset&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; to &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;offset&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;, URL: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;url_projects&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;subset&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;API&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;offset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;offset&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;subset&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;So now we have a function that takes two inputs for size and offset, then returns us that chunk of results. If you were actually making &lt;span class="caps"&gt;API&lt;/span&gt; calls here is where you would slap some requests work and any error handling you may&amp;nbsp;want.&lt;/p&gt;
&lt;p&gt;With that in place we can do the meat and potatoes of this loop, which looks something like&amp;nbsp;this&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;set_of_projects&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;grab_projects&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;offset&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;SIZE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;set_of_projects&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;
    &lt;span class="n"&gt;batches&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_of_projects&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;offset&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;SIZE&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This loops until there is a failure to set the variable &lt;strong&gt;set_of_projects&lt;/strong&gt; from the return from grab_projects() so we don&amp;#8217;t know how many times it will loop, only that there will eventually be an end and we stop looping when that&amp;#8217;s hit. In order to allow us to collect all of the information we have a list called &lt;strong&gt;batches&lt;/strong&gt; to which we append &lt;strong&gt;set_of_projects&lt;/strong&gt; on each iteration of the loop, then after we are done we can flatten it into something we can use elsewhere by using a list&amp;nbsp;comprehension&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# flatten the list of lists&lt;/span&gt;
&lt;span class="n"&gt;all_projects&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;batch&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;batches&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;batch&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;When put together it looks like&amp;nbsp;this &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;random&lt;/span&gt;

&lt;span class="n"&gt;MAX&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;randint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;SIZE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;



&lt;span class="n"&gt;API&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;MAX&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;API&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="s2"&gt;&amp;quot;id&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Project &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;&amp;quot;rulesets&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Ruleset &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;randint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;))],&lt;/span&gt;
        &lt;span class="s2"&gt;&amp;quot;rules&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;randint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="n"&gt;offset&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;grab_projects&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;offset&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;url_projects&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;https://some.api.host/api/v1/projects?limit=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;amp;offset=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;offset&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Fetching projects from &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;offset&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; to &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;offset&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;, URL: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;url_projects&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;subset&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;API&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;offset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;offset&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;subset&lt;/span&gt;



&lt;span class="n"&gt;batches&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="n"&gt;all_projects&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;



&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;set_of_projects&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;grab_projects&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;offset&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;SIZE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;set_of_projects&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;

    &lt;span class="n"&gt;batches&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_of_projects&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;offset&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;SIZE&lt;/span&gt;



&lt;span class="c1"&gt;# flatten the list of lists&lt;/span&gt;

&lt;span class="n"&gt;all_projects&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;batch&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;batches&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;batch&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;


&lt;span class="c1"&gt;# output from all_projects &lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;all_projects&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;id&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;name&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;rulesets&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;rules&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now this at least gets you the results to work with and provides me a chance to show where you could go from here. If the &lt;span class="caps"&gt;API&lt;/span&gt; is particularly slow (which the one I was working with at the moment) then you don&amp;#8217;t want to wait forever for this loop to do its thing. From here it would be worthwhile to make some changes to the script to define a temporary &lt;span class="caps"&gt;MAX&lt;/span&gt; of like say 200 if you are taking chunks of 20 results, run the code and benchmark it to see how long it takes for the 10 calls to return their&amp;nbsp;results. &lt;/p&gt;
&lt;p&gt;Armed with some benchmark information (in my case it was 2 minutes to pull 430ish projects in chunks of 20, avg of like 5 seconds per call) its possible to apply some threading or other similar methodology to get the data set&amp;nbsp;faster&lt;/p&gt;</content><category term="programming"/></entry><entry><title>Terraform &amp; AWS Bug</title><link href="https://dword4.github.io/aws-terraform-bug.html" rel="alternate"/><published>2025-07-14T00:00:00-04:00</published><updated>2025-07-14T00:00:00-04:00</updated><author><name>dword4</name></author><id>tag:dword4.github.io,2025-07-14:/aws-terraform-bug.html</id><summary type="html">&lt;p&gt;Detailing a long-standing bug with Terraform and &lt;span class="caps"&gt;AWS&lt;/span&gt; regarding handling of deletion of&amp;nbsp;resources&lt;/p&gt;</summary><content type="html">&lt;h3&gt;Background&lt;/h3&gt;
&lt;p&gt;If you&amp;#8217;re not a frequent &lt;span class="caps"&gt;AWS&lt;/span&gt; user, here&amp;#8217;s some quick context: &lt;span class="caps"&gt;AWS&lt;/span&gt; Firewall Manager is a service that allows centralized management of &lt;span class="caps"&gt;AWS&lt;/span&gt; WAFs (Web Application Firewalls) across multiple accounts. It&amp;#8217;s commonly used for enforcing global security policies like &lt;span class="caps"&gt;IP&lt;/span&gt; blocking rules. A few components are relevant to this&amp;nbsp;issue:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;span class="caps"&gt;IP&lt;/span&gt; Set&lt;/strong&gt;: A named list of &lt;span class="caps"&gt;CIDR&lt;/span&gt;-notated &lt;span class="caps"&gt;IP&lt;/span&gt;&amp;nbsp;addresses.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Rule Group&lt;/strong&gt;: A collection of &lt;span class="caps"&gt;IP&lt;/span&gt; sets grouped together under a named rule with specified actions (e.g., allow,&amp;nbsp;block).&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As part of building out &lt;span class="caps"&gt;WAF&lt;/span&gt; controls, you might create several &lt;span class="caps"&gt;IP&lt;/span&gt; sets (e.g., for sanctioned countries or specific network ranges) and then reference them in rule&amp;nbsp;groups.&lt;/p&gt;
&lt;p&gt;Here are some sample &lt;span class="caps"&gt;IP&lt;/span&gt; sets used for&amp;nbsp;testing:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;ip_sets = {
  IP-Block = [
    &amp;quot;10.0.1.0/24&amp;quot;,
    &amp;quot;10.2.0.0/24&amp;quot;
  ],
  IP-Sloth = [
    &amp;quot;192.168.2.0/24&amp;quot;,
    &amp;quot;192.168.3.0/24&amp;quot;
  ],
  IP-Snake = [
    &amp;quot;172.22.0.32/32&amp;quot;,
    &amp;quot;10.1.2.3/32&amp;quot;
  ]
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And here&amp;#8217;s how they&amp;#8217;re referenced in a rule&amp;nbsp;group:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nb"&gt;rule_groups&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="na"&gt;NetworkRuleGroup&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;IP-Block&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="na"&gt;priority&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;block&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="nb"&gt;statement&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="na"&gt;ip_set_reference_statement&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;IP-Block&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;IP-Allow&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="na"&gt;priority&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;allow&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="nb"&gt;statement&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="na"&gt;ip_set_reference_statement&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;IP-Sloth&amp;quot;, &amp;quot;IP-Snake&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Pretty straightforward. These values live in&amp;nbsp;a &lt;code&gt;tfvars&lt;/code&gt; file, and Terraform uses some looping logic to construct the necessary&amp;nbsp;resources.&lt;/p&gt;
&lt;p&gt;The configuration plans and applies cleanly—no issues there. The problem arises when modifying an existing &lt;span class="caps"&gt;IP&lt;/span&gt; set or rule group. Let&amp;#8217;s say we want to remove&amp;nbsp;the &lt;code&gt;IP-Sloth&lt;/code&gt; set. You might expect that deleting it from&amp;nbsp;the &lt;code&gt;tfvars&lt;/code&gt; file would suffice. Not so&amp;nbsp;fast.&lt;/p&gt;
&lt;h3&gt;The&amp;nbsp;Problem&lt;/h3&gt;
&lt;p&gt;After&amp;nbsp;removing &lt;code&gt;IP-Sloth&lt;/code&gt; from&amp;nbsp;the &lt;code&gt;tfvars&lt;/code&gt; file, Terraform&amp;#8217;s plan correctly reports that it will destroy one resource and modify another. So far, so good. But when applying the plan, Terraform attempts to destroy&amp;nbsp;the &lt;code&gt;IP-Sloth&lt;/code&gt; &lt;span class="caps"&gt;IP&lt;/span&gt; set &lt;em&gt;before&lt;/em&gt; updating the rule group that references&amp;nbsp;it.&lt;/p&gt;
&lt;p&gt;Naturally, this fails—Terraform can&amp;#8217;t delete an &lt;span class="caps"&gt;IP&lt;/span&gt; set that&amp;#8217;s still in use. The operation spins for a while and then throws an error about the resource being in&amp;nbsp;use.&lt;/p&gt;
&lt;p&gt;This behavior is puzzling. When I ran a&amp;nbsp;full &lt;code&gt;terraform destroy&lt;/code&gt; in my lab environment, everything worked as expected. Terraform deleted the rule groups first and then the &lt;span class="caps"&gt;IP&lt;/span&gt;&amp;nbsp;sets.&lt;/p&gt;
&lt;p&gt;To rule out version-specific issues, I tested with Terraform versions 1.9.7, 1.12.0, and 1.12.1. All exhibited the same&amp;nbsp;behavior.&lt;/p&gt;
&lt;p&gt;This strongly suggests a dependency ordering bug in Terraform when updating resource graphs involving &lt;span class="caps"&gt;WAF&lt;/span&gt; &lt;span class="caps"&gt;IP&lt;/span&gt; sets and rule&amp;nbsp;groups.&lt;/p&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;p&gt;In order to cope with this issue it became necessary to create a much more cumbersome process for revising our &lt;span class="caps"&gt;WAF&lt;/span&gt; resources to be a multi-step hokey-pokey&amp;nbsp;dance.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Remove &lt;span class="caps"&gt;IP&lt;/span&gt; Sets from any Rule Groups that use&amp;nbsp;them&lt;/li&gt;
&lt;li&gt;Commit, Push and&amp;nbsp;Run&lt;/li&gt;
&lt;li&gt;Remove actual &lt;span class="caps"&gt;IP&lt;/span&gt; Set from&amp;nbsp;tfvars&lt;/li&gt;
&lt;li&gt;Commit, Push and&amp;nbsp;Run&lt;/li&gt;
&lt;/ol&gt;</content><category term="programming"/></entry><entry><title>CI Headaches</title><link href="https://dword4.github.io/ci-headaches.html" rel="alternate"/><published>2025-03-17T00:00:00-04:00</published><updated>2025-03-17T00:00:00-04:00</updated><author><name>dword4</name></author><id>tag:dword4.github.io,2025-03-17:/ci-headaches.html</id><summary type="html">&lt;p&gt;The longer I am in this space the more I find myself noticing shortcomings of software that just seems obvious to me. Recently the target of a lot of that feeling has become Gitlab which I use on a daily basis for work.  Particularly a lot of the things around their &lt;span class="caps"&gt;CI&lt;/span&gt;/&lt;span class="caps"&gt;CD&lt;/span&gt; Pipelines has lead to quite a bit of frustration and&amp;nbsp;annoyance.&lt;/p&gt;</summary><content type="html">&lt;!-- PELICAN_BEGIN_SUMMARY --&gt;

&lt;h2&gt;Artifacts and&amp;nbsp;Caches&lt;/h2&gt;
&lt;p&gt;I have a rather large terraform project with multiple modules and I was working on adding a new one that would ultimately add some alarms. The terraform itself wasn&amp;#8217;t overly complex, the real pain came when I realized at scale I would be kicking off 181 jobs at once in the apply&amp;nbsp;stage. &lt;/p&gt;
&lt;p&gt;Kicking off the full 181 jobs at once caused an almost immediate crawl in the runner that got the unfortunate luck of the draw, ultimately leading to a bunch of timeouts pulling down the job plan artifacts.  I started digging into the logs, wondering why my shiny and bright new terraform was not producing the magic I expected from it.  I looked at the first job in the stack and right off the bat I saw it was pulling down a &lt;span class="caps"&gt;TON&lt;/span&gt; of artifacts, but that makes sense I have a lot of them right?  Checked another and saw the same thing, and another, and then as I hopped through more of the jobs I started seeing messages that indicated I was being ratelimited by&amp;nbsp;Gitlab.&lt;/p&gt;
&lt;p&gt;Keeping an old school calculator on my desk I punched in the math to figure out just how many calls for artifacts I could be generating at once (since it was all happening&amp;nbsp;with &lt;code&gt;parallel:&lt;/code&gt;) and realized the headache I was in for: 181 jobs each pulling 181 artifacts at once works out to be 32,761 artifact pulls.  This was definitely not going to work so I hit the search engines and LLMs and landed on caching as an alternative to pass my plan files between&amp;nbsp;stages.&lt;/p&gt;
&lt;p&gt;In the movies this would be a montage spot, burn several hours and water bottles full of caffeine and the cache option was proving to be no better. It would fail to update the cache seemingly at random and then the apply runs wouldn&amp;#8217;t find the plans they expected to be there. At this point I was beyond annoyed with it all and decided to say screw it and go back to the old ways. I reverted back to using artifacts (way easier than the first go-round for some reason) and commented out all but 10 items in my list. The computer gods were smiling on me at that point (or maybe laughing) and decided to bless me with success across the&amp;nbsp;board.&lt;/p&gt;
&lt;p&gt;After the tedious 10-at-a-time process was done and everything checked out I went back to documentation searching and saw suggestions to use something other than gitlab for artifacts when you have very large workloads like what I had. The first suggestion was s3, which in hindsight would have been a fine alternative however I realized that the time to implement that would have slowed things down even&amp;nbsp;further.&lt;/p&gt;
&lt;p&gt;What I truly wish Gitlab made possible would be intelligent fetching of artifacts so that I could specify what artifacts a job/stage needs and it &lt;span class="caps"&gt;ONLY&lt;/span&gt; gets those instead of everything under the sun. Unfortunately I don&amp;#8217;t see that happening anytime soon (more likely masking in pipeline variables will land before something that useful&amp;nbsp;does). &lt;/p&gt;
&lt;h2&gt;Deploys or&amp;nbsp;Local?&lt;/h2&gt;
&lt;p&gt;Again in the context of work we have a slack bot we have been slowly building up over time with utility for the rest of the team. Initially it was just me working on it but once we added a 3rd person to my squad we decided to branch out and everyone took up tasks for it. Deployment for this was rather simple, I had it refined down enough to a docker-compose file that would stand up&amp;nbsp;everything.&lt;/p&gt;
&lt;p&gt;Somewhere along the way we decided the bot needed to be a little more professional so it got moved over to &lt;span class="caps"&gt;ECS&lt;/span&gt; from the standalone &lt;span class="caps"&gt;EC2&lt;/span&gt; Docker server I stood up initially.  This worked great for quite a while, I could work on an update to the bot locally, run it with dev creds and test it a bunch then when ready send it along its way to the main branch and update with a quick docker-compose command and done. This unfortunately did not last for too long as we eventually pulled the dev instance into &lt;span class="caps"&gt;ECS&lt;/span&gt; as well, so now in order to test even the smallest code changes it requires a whole deploy&amp;nbsp;pipeline. &lt;/p&gt;
&lt;p&gt;I realize its probably best to work this way for the sake of doing things in an industry acceptable way but it drives me crazy how much it slows down the process. First the pushes to the repo trigger a whole host of company mandated scans like secrets detection, dependency scanning and a few others I cant recall. Then you have tag the code, login to &lt;span class="caps"&gt;AWS&lt;/span&gt;, fiddle with task definitions and ultimately trigger a new deployment for the dev instance. Now imagine doing this every single time you make a change in code! Forgot a character or mistyped a variable name? Yep time to do that whole&amp;nbsp;process.  &lt;/p&gt;
&lt;p&gt;There has to be some kind of middle ground between wild west locally running things and a rigid and formalized process for something that ultimately is non-critical and just a handy tool to save a little bit of time? I wish I had a good answer for what that middle ground could or should be because the process as it stands really is a turn-off to putting in work adding new&amp;nbsp;features.&lt;/p&gt;</content><category term="devops"/><category term="CI/CD"/><category term="Gitlab"/><category term="DevOps"/></entry><entry><title>AWS Account Switching with Vault in Jenkins</title><link href="https://dword4.github.io/aws-switch-vault-jenkins.html" rel="alternate"/><published>2023-06-15T00:00:00-04:00</published><updated>2023-06-15T00:00:00-04:00</updated><author><name>dword4</name></author><id>tag:dword4.github.io,2023-06-15:/aws-switch-vault-jenkins.html</id><summary type="html">&lt;p&gt;A workaround for &lt;span class="caps"&gt;AWS&lt;/span&gt; Account Switching with Vault in&amp;nbsp;Jenkins&lt;/p&gt;</summary><content type="html">&lt;h2&gt;Problem&lt;/h2&gt;
&lt;p&gt;I ran into an issue recently where some of my automation that cycles through &lt;span class="caps"&gt;AWS&lt;/span&gt; accounts and runs code
against each accounts resources broke. It would become sticky to the account that we initially connected
to Vault and never switch when using `vault read aws/something/else. We worked on trying to use curl calls
and other various workarounds but nothing seemed to&amp;nbsp;work.&lt;/p&gt;
&lt;h2&gt;Eventual&amp;nbsp;Solution&lt;/h2&gt;
&lt;p&gt;After a few days of working on things off and on I decided to just hammer out a custom function in Groovy
that would handle the account switching for us. Fast-forward like 100+ commits and Jenkins runs later and I 
finally got something that worked for&amp;nbsp;switching.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;def vaultAWS(account_level, account_team) {
    def vaultQuery = &amp;quot;aws/$account_level/$account_team/sts/admin&amp;quot;
    print &amp;quot;testing: $vaultQuery&amp;quot;
    try {
        def vaultOutput = sh(returnStdout: true, script: &amp;quot;vault read $vaultQuery&amp;quot;).trim()
        def keyValuePairs = [:]
        vaultOutput.split(&amp;#39;\n&amp;#39;).each { line -&amp;gt;
            def (key, value) = line.split(&amp;#39; &amp;#39;, 2).collect { it.trim() }
            if ( key == &amp;#39;access_key&amp;#39; || key == &amp;#39;secret_key&amp;#39; || key == &amp;#39;security_token&amp;#39;){
                keyValuePairs[key] = value
            }
        }
        // set env variables
        env.AWS_ACCESS_KEY_ID = keyValuePairs[&amp;#39;access_key&amp;#39;]
        env.AWS_SECRET_ACCESS_KEY = keyValuePairs[&amp;#39;secret_key&amp;#39;]
        env.AWS_SESSION_TOKEN = keyValuePairs[&amp;#39;security_token&amp;#39;]
    } catch (Exception e) {
        println &amp;quot;Something went wrong&amp;quot;
    }

}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This let me loop through our lists of accounts and run a basic test to make sure I could actually
see the resources in the &lt;span class="caps"&gt;AWS&lt;/span&gt; account. Unfortunately I found additional problems (like an entire set
of accounts were simply &lt;em&gt;poof&lt;/em&gt; gone) but the code worked exactly as I had hoped. Further research lead
me to the use of @Grab to pull from git repos for code so ideally this can be pulled remotely instead
of manually pasted into every single Jenkins job we end up using it in. Of course by the time I get all
that worked out we are going to start the joyful process of moving out automated jobs from Jenkins to 
Gitlab &lt;span class="caps"&gt;CI&lt;/span&gt;/&lt;span class="caps"&gt;CD&lt;/span&gt;&lt;/p&gt;</content><category term="programming"/></entry><entry><title>Optimizing Gitlab CI/CD Pipelines</title><link href="https://dword4.github.io/optimizing-cicd-pipelines.html" rel="alternate"/><published>2022-11-29T00:00:00-05:00</published><updated>2022-11-29T00:00:00-05:00</updated><author><name>dword4</name></author><id>tag:dword4.github.io,2022-11-29:/optimizing-cicd-pipelines.html</id><summary type="html">&lt;p&gt;collecting my efforts on making my pipelines more&amp;nbsp;streamlined&lt;/p&gt;</summary><content type="html">&lt;h2&gt;Alpine&amp;nbsp;Containers&lt;/h2&gt;
&lt;p&gt;They compile so much from source that it really slows it down when you start with a vanilla container each run of your pipeline.  In my case the solution was to build a new container with a bunch of the compiled dependencies built. Prior to that pipelines even when failing would take an average of 12 minutes to reach&amp;nbsp;failure.&lt;/p&gt;
&lt;p&gt;&lt;img alt="gitlab-stats.png" src="images/gitlab-stats.png"&gt;&lt;/p&gt;
&lt;p&gt;Afterwards a successful test run takes about a minute, with the brunt of the time sink being pushed off to a separate repo for building the image.  On that side its about 48 minutes to generate the image however having it take place in an entirely is worth it for the saved time on rapid&amp;nbsp;re-testing.&lt;/p&gt;</content><category term="programming"/></entry><entry><title>Updating this again</title><link href="https://dword4.github.io/updating-again.html" rel="alternate"/><published>2022-11-01T00:00:00-04:00</published><updated>2022-11-01T00:00:00-04:00</updated><author><name>dword4</name></author><id>tag:dword4.github.io,2022-11-01:/updating-again.html</id><summary type="html">&lt;p&gt;trying to get back in the habit of regular&amp;nbsp;updates&lt;/p&gt;</summary><content type="html">&lt;p&gt;Finally got around to setting everything back up again to push updates, one day I will just write something to auto-update when I push, but until then I guess
I am left with following my own notes when I want to publish content again.  Currently working on a few neat side projects including a friendly python plugin system
for chat bots (i.e. discord, slack, matrix, etc).  Its super early on that project however so its not even ready for a demo yet but its been a learning experience every 
step of the way so far which is&amp;nbsp;great.&lt;/p&gt;</content><category term="thoughts"/></entry><entry><title>Taking Back Email - Update 1</title><link href="https://dword4.github.io/taking-back-email-update1.html" rel="alternate"/><published>2022-05-01T00:00:00-04:00</published><updated>2022-05-01T00:00:00-04:00</updated><author><name>dword4</name></author><id>tag:dword4.github.io,2022-05-01:/taking-back-email-update1.html</id><summary type="html">&lt;p&gt;first update to taking back email&amp;nbsp;project&lt;/p&gt;</summary><content type="html">&lt;p&gt;Not a lot to really say other than so far its been great to have a proper hosted email solution that integrates so well with things.  Having a full blown online office solution tied to my email has been extremely handy while transitioning from contract work back to a full time&amp;nbsp;gig.&lt;/p&gt;
&lt;p&gt;The only real problem I have found so far is some online tools seem to not like non-standard TLDs for email addresses.  While doing paperwork for my new job (I9 documents) their system for whatever reason would not let me complete this step and ultimately they had to send me a request on an older gmail account to get it completed.  I only really ran into this once during the whole process so I did not really pursue a fix for it but I suspect its mostly just due to having .services as my &lt;span class="caps"&gt;TLD&lt;/span&gt; for my email&amp;nbsp;address.&lt;/p&gt;
&lt;p&gt;Originally I had intended to do a lot of integration work with the &lt;span class="caps"&gt;AD&lt;/span&gt; side of things however some life-altering events really cut down on my free time to play with tech projects, however as things stabilize at home I am really hoping to start this side of the project back up both to help keep my mind sharp and move more of my resources off-prem where&amp;nbsp;possible.&lt;/p&gt;</content><category term="thoughts"/></entry><entry><title>Taking Back Email - An Overview</title><link href="https://dword4.github.io/taking-back-email.html" rel="alternate"/><published>2021-12-17T00:00:00-05:00</published><updated>2021-12-17T00:00:00-05:00</updated><author><name>dword4</name></author><id>tag:dword4.github.io,2021-12-17:/taking-back-email.html</id><summary type="html">&lt;p&gt;a quick overview of how to take back&amp;nbsp;email&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;strong&gt;So full disclosure I got this idea from a friend who has already done a lot of the leg&amp;nbsp;work&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;One of the biggest ways we give away &lt;span class="caps"&gt;TONS&lt;/span&gt; of data is using email providers such as Gmail which 
outright data mine our entire inbox contents to build profiles on us.  While I no longer aspire
to run a basement datacenter for fun there is a middle ground to be had I think.  In this case
it would be utilizing a service such as Azure to do the hosting portion but keeping control of
the assets and managing them myself (to a&amp;nbsp;degree).&lt;/p&gt;
&lt;p&gt;The general idea is to setup an Azure &lt;span class="caps"&gt;AD&lt;/span&gt; Premium P2 instance (9$/month) for authentication and 
control and use Office 365 Business specifically for the email portion (5$/month).  With O365 
business you currently get a &lt;span class="caps"&gt;50GB&lt;/span&gt; mailbox, ability to use a custom domain (required for the &lt;span class="caps"&gt;AD&lt;/span&gt;
portion I believe) and a &lt;span class="caps"&gt;1TB&lt;/span&gt; OneDrive account.  Comparison wise it costs about 10$ a month to get 
&lt;span class="caps"&gt;2TB&lt;/span&gt; of storage with Google to split between your Drive and Gmail&amp;nbsp;account.&lt;/p&gt;
&lt;p&gt;Another perk of this path is that I can utilize the &lt;span class="caps"&gt;AD&lt;/span&gt; authentication to tie various apps into 
a central authentication platform that I control.  This opens up a whole new realm of control
and configuration to ensure that I can help keep my data safe and private, allowing for a degree 
of control that otherwise would require a great deal more configuration work to self-host email 
at&amp;nbsp;home.&lt;/p&gt;
&lt;p&gt;The general idea here is to document the process as I go to help guide others who want to take 
back some control of their data. That and it forces me to use Pelican more to update this so its
a nice&amp;nbsp;bonus.&lt;/p&gt;</content><category term="thoughts"/></entry><entry><title>Sunsetting a Project</title><link href="https://dword4.github.io/sunsetting-hockey-info.html" rel="alternate"/><published>2021-10-13T00:00:00-04:00</published><updated>2021-10-13T00:00:00-04:00</updated><author><name>dword4</name></author><id>tag:dword4.github.io,2021-10-13:/sunsetting-hockey-info.html</id><summary type="html">&lt;p&gt;ruminating on the end of a project and the path&amp;nbsp;forward&lt;/p&gt;</summary><content type="html">&lt;p&gt;For a while now I have struggled to develop the &lt;a href="http://gitlab.com/dword4/hockey-info"&gt;hockey-info&lt;/a&gt; project further, trying to make it faster or more friendly for mobile use.  I dabbled with new frameworks to make a faster interface, pondered the idea of turning it into an &lt;span class="caps"&gt;API&lt;/span&gt; and learning &lt;span class="caps"&gt;JS&lt;/span&gt; to put a more stylish interface in front of it.  Even put time into moving some of the more cumbersome &lt;span class="caps"&gt;API&lt;/span&gt; hits into redisJSON objects for the sake of&amp;nbsp;speed. &lt;/p&gt;
&lt;p&gt;It wasn&amp;#8217;t until I had the local version configured to use Redis that I realized I would have to pay more to run it on the internet, and after some research I realized that it would more than double the cost from 5$ a month to about 20 to 25$ a month depending on where I decided to host it.  There are some hosted Redis options that would have simplified the process but they were the most expensive, when I looked at doing most of the configuration by hand it saved me money but added more complexity that I wasn&amp;#8217;t really interested&amp;nbsp;in.&lt;/p&gt;
&lt;p&gt;Realizing I had hit the wall of a reasonable hobby project, going from 60$ a year to well over 240$ was something I could not justify.  I had pondered ways to try to monetize things but they fell flat when I looked at actual traffic numbers.  The users were simply not there to run any sort of advertising and without actual users nobody would donate to such a project either to keep it online.  With the financial realities staring at me from a spreadsheet and the difficulty of writing actual code to move the project forward I decided it was time to hang it&amp;nbsp;up.&lt;/p&gt;
&lt;p&gt;I started the project in March of 2019 almost a year after I had begun documenting the &lt;span class="caps"&gt;NHL&lt;/span&gt; &lt;span class="caps"&gt;API&lt;/span&gt;, taking all the things I learned along the way and creating something to show for all my efforts.  In more than a few job interviews I talked about the project, how I had grown it and shaped it into something I used almost daily. It was great fun to grow the application with new features, fixing the various quirks that showed up during the Covid-19 shortened season as the &lt;span class="caps"&gt;NHL&lt;/span&gt; altered playoff formats.  But as with so many things it just doesn&amp;#8217;t make sense to put money into hosting it when there are so many better applications out there doing the same&amp;nbsp;thing.&lt;/p&gt;
&lt;p&gt;While it is kind of bittersweet to sunset a project like this I think it will eventually free up some mental resources to put into something new and exciting that hopefully will force me to learn some new languages and techniques along the&amp;nbsp;way.&lt;/p&gt;</content><category term="thoughts"/></entry><entry><title>Staircase Challenge</title><link href="https://dword4.github.io/staircase-programming-challenge.html" rel="alternate"/><published>2021-08-27T00:00:00-04:00</published><updated>2021-08-27T00:00:00-04:00</updated><author><name>dword4</name></author><id>tag:dword4.github.io,2021-08-27:/staircase-programming-challenge.html</id><summary type="html">&lt;p&gt;a quick code blurb I wrote for an online&amp;nbsp;challenge&lt;/p&gt;</summary><content type="html">&lt;p&gt;The other day I was doing a programming challenge somewhere online and was given the staircase problem randomly, its a pretty simple one but after looking my code over a few times I thought I had this about as simplified as possible without resorting to something like using&amp;nbsp;lambdas.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/usr/bin/env python3&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;caseit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;spaces&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;stairs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;space&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt;
        &lt;span class="n"&gt;stair&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;sp&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;spaces&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;space&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot; &amp;quot;&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stairs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;stair&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;#&amp;quot;&lt;/span&gt;
        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;space&lt;/span&gt;&lt;span class="si"&gt;}{&lt;/span&gt;&lt;span class="n"&gt;stair&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;spaces&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="n"&gt;stairs&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="n"&gt;caseit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;35&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="programming"/></entry><entry><title>Clean Slate</title><link href="https://dword4.github.io/clean-slate.html" rel="alternate"/><published>2021-08-16T00:00:00-04:00</published><updated>2021-08-16T00:00:00-04:00</updated><author><name>dword4</name></author><id>tag:dword4.github.io,2021-08-16:/clean-slate.html</id><summary type="html">&lt;p&gt;some thoughts on starting&amp;nbsp;over&lt;/p&gt;</summary><content type="html">&lt;p&gt;I have pondered doing this for quite a while, patching Wordpress becomes tiresome and the majority of its features
are of no real use to&amp;nbsp;me&lt;/p&gt;</content><category term="thoughts"/></entry><entry><title>Finding Data in the NHL API</title><link href="https://dword4.github.io/finding-data-NHL-API.html" rel="alternate"/><published>2021-02-03T00:00:00-05:00</published><updated>2021-02-03T00:00:00-05:00</updated><author><name>dword4</name></author><id>tag:dword4.github.io,2021-02-03:/finding-data-NHL-API.html</id><summary type="html">&lt;p&gt;How to find data in the &lt;span class="caps"&gt;NHL&lt;/span&gt; &lt;span class="caps"&gt;API&lt;/span&gt;&lt;/p&gt;</summary><content type="html">&lt;p&gt;So I decided to retake my &lt;span class="caps"&gt;NHL&lt;/span&gt; &lt;span class="caps"&gt;API&lt;/span&gt; video to try to improve things (now that I know how to get my audio better) and maybe make it a little easier to digest. Turns out even a 3 and a half minute video takes hours to get just right and somehow I still am not totally satisfied with it. I think perhaps this may be something I spend more time on in the near future to try to provide people with a little bit of educational material. In the meantime feel free to go have a watch of Finding Data in the &lt;span class="caps"&gt;NHL&lt;/span&gt; &lt;span class="caps"&gt;API&lt;/span&gt; over on&amp;nbsp;Odysee&lt;/p&gt;
&lt;iframe id="lbry-iframe" width="560" height="315" src="https://odysee.com/$/embed/finding-nhl-api-data-ver2/34ef2fb7111b89d085278977ed360a5e2f26b854?r=78vvaGh68aEumFv5QdiG1ocN7FFBLXGi" allowfullscreen&gt;&lt;/iframe&gt;</content><category term="projects"/></entry><entry><title>PaaS Frustrations</title><link href="https://dword4.github.io/paas-frustrations.html" rel="alternate"/><published>2021-02-03T00:00:00-05:00</published><updated>2021-02-03T00:00:00-05:00</updated><author><name>dword4</name></author><id>tag:dword4.github.io,2021-02-03:/paas-frustrations.html</id><summary type="html">&lt;p&gt;Working through a slightly obscure Gitlab&amp;nbsp;problems&lt;/p&gt;</summary><content type="html">&lt;p&gt;So after several days working with the Support folks at Digital Ocean they finally nailed down why my deploys were never getting new code and I am still not clear on the reason it was an issue to begin with but I figured it needs to be documented to maybe save someone else the&amp;nbsp;trouble.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The&amp;nbsp;Details&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;My code is a mix of Python (and some &lt;span class="caps"&gt;HTML&lt;/span&gt;/&lt;span class="caps"&gt;JS&lt;/span&gt;) using Flask, Python version in this specific situation was 3.8.2 (at least locally anyway). Using the Digital Ocean App platform and a domain hosted through them as well (hockey-info.online). Docker version locally was 20.10.2, build 2291f61 on a Fedora 32 based&amp;nbsp;system.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The&amp;nbsp;Problem&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;No code changes I made after Jan 15th seemed to be pulled when doing a deploy, deploys would trigger properly however they never got the correct code just the correct commit sum. I tried manual deploys, I tried automatic, I searched the internet high, low and in between but couldn’t figure it&amp;nbsp;out.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution&amp;nbsp;(Eventually)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I finally broke down and opened a ticket with &lt;span class="caps"&gt;DO&lt;/span&gt; on a Wednesday, after going back and forth with their support people and trying a lot of things they finally informed me of a solution on the Tuesday after. It seems that in the Dockerfile I was doing&amp;nbsp;a &lt;code&gt;RUN git clone https://gitlab.com/dword4/hockey-info.git .&lt;/code&gt; which was running the git command to pull code down outside of the methods used by the App platform. The fix turns out was as simple as replacing that line&amp;nbsp;with &lt;code&gt;COPY . /hockey-info&lt;/code&gt; and then pushing the code&amp;nbsp;up.&lt;/p&gt;
&lt;p&gt;Still not entirely sure why this functions this way, there appears to be some kind of git caching going on but I have no real insight as to why, probably due to how the app platform is&amp;nbsp;built.&lt;/p&gt;</content><category term="programming, cloud, git"/></entry><entry><title>Monitoring on AWS with CloudWatch Agent and Procstat</title><link href="https://dword4.github.io/monitoring-cloudwatch-agent-procstat.html" rel="alternate"/><published>2020-08-26T00:00:00-04:00</published><updated>2020-08-26T00:00:00-04:00</updated><author><name>dword4</name></author><id>tag:dword4.github.io,2020-08-26:/monitoring-cloudwatch-agent-procstat.html</id><summary type="html">&lt;p&gt;Install CloudWatch agent with procstat on an &lt;span class="caps"&gt;EC2&lt;/span&gt; instance and configure a metric alarm in&amp;nbsp;CloudWatch&lt;/p&gt;</summary><content type="html">&lt;p&gt;One of the first issues I ran into was with &lt;span class="caps"&gt;IAM&lt;/span&gt; Policies, or lack thereof . Specifically it was the managed policy &lt;strong&gt;CloudWatchAgentServerPolicy&lt;/strong&gt; which needed to be added. The telltale sign that you forgot to add this Policy is an error message in the Agent logs, seen&amp;nbsp;below&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;2020-08-17T22:46:18Z E! refresh EC2 Instance Tags failed: NoCredentialProviders: no valid providers in chain&amp;lt;br&amp;gt;caused by: EnvAccessKeyNotFound: failed to find credentials in the environment.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The procstat plugin fortunately is already part of the Agent from install, but it still needs to be configured. In order to do this you have to add a configuration file specific to your monitoring needs. For old school admins the easiest way to think of procstat is that it basically ties into the ps tool. It’s like doing&amp;nbsp;a &lt;code&gt;ps -ef | grep&lt;/code&gt; to find something about a running&amp;nbsp;process.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;[root@lab-master amazon-cloudwatch-agent.d]# pwd
/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d
[root@lab-master amazon-cloudwatch-agent.d]# cat processes
{
    &amp;quot;metrics&amp;quot;: {
        &amp;quot;metrics_collected&amp;quot;: {
            &amp;quot;procstat&amp;quot;: [
                {
                    &amp;quot;pattern&amp;quot;: &amp;quot;nginx: master process /usr/sbin/nginx&amp;quot;,
                    &amp;quot;measurement&amp;quot;: [
                        &amp;quot;pid_count&amp;quot;
                    ]
                }
            ]
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This will get us far enough that now we can see values in the Metrics view of CloudWatch. Once we have data there its time to construct a metric alarm. My goal was to use Terraform however its less painful to do in the &lt;span class="caps"&gt;AWS&lt;/span&gt;&amp;nbsp;console.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;resource &amp;quot;aws_cloudwatch_metric_alarm&amp;quot; &amp;quot;nginx-master&amp;quot; {
  alarm_name = &amp;quot;nginx master alarm&amp;quot;
  comparison_operator = &amp;quot;LessThanThreshold&amp;quot;
  evaluation_periods = 1
  datapoints_to_alarm = 1
  metric_name = &amp;quot;procstat_lookup_pid_count&amp;quot;
  namespace = &amp;quot;CWAgent&amp;quot;
  period = &amp;quot;300&amp;quot;
  statistic = &amp;quot;Average&amp;quot;
  threshold = &amp;quot;1&amp;quot;
  alarm_description = &amp;quot;Checks for the presence of an nginx-master process&amp;quot;
  alarm_actions = [aws_sns_topic.pagerduty_standard_alarms.arn]
  insufficient_data_actions = []
  treat_missing_data = &amp;quot;missing&amp;quot;
  dimensions = {
    &amp;quot;AutoScalingGroupName&amp;quot; = &amp;quot;some-ASG-YXI8VDT6MBE3&amp;quot;
    &amp;quot;ImageId&amp;quot;       = &amp;quot;some-ami&amp;quot;
    &amp;quot;InstanceId&amp;quot;    = &amp;quot;some-instance-id&amp;quot;
    &amp;quot;InstanceType&amp;quot;  = &amp;quot;t3a.large&amp;quot;
    &amp;quot;pattern&amp;quot;       = &amp;quot;nginx: master process /usr/sbin/nginx&amp;quot;
    &amp;quot;pid_finder&amp;quot;    = &amp;quot;native&amp;quot;
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The alarm creation proved to be a lot harder than I had expected, taking up several hours. I had to re-create things in my lab setup twice and do a Terraform import. The problem turned out to be that the dimensions{} block is not optional despite what the Terraform docs say. Had it said the fields were all required I probably would have saved days of&amp;nbsp;time&lt;/p&gt;
&lt;h2&gt;Polish&amp;nbsp;Work&lt;/h2&gt;
&lt;p&gt;In the process of working things out I hard coded a lot of values in the Dimensions {} block. Naturally that is not good practice, especially with IaaS so I will need to rework it to use variables instead. Also the alarm names should utilize the Terraform workspace values for better&amp;nbsp;naming.&lt;/p&gt;</content><category term="cloud-aws"/><category term="AWS"/><category term="CloudWatch"/><category term="procstat"/><category term="EC2"/><category term="monitoring"/></entry><entry><title>Hockey-Info Release v1.0</title><link href="https://dword4.github.io/hockey-info-release-1.html" rel="alternate"/><published>2020-07-26T00:00:00-04:00</published><updated>2020-07-26T00:00:00-04:00</updated><author><name>dword4</name></author><id>tag:dword4.github.io,2020-07-26:/hockey-info-release-1.html</id><summary type="html">&lt;p&gt;The 1.0 release of&amp;nbsp;Hockey-Info&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;img alt="screenshot" src="images/hockey-info-release-1.png"&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://gitlab.com/dword4/hockey-info"&gt;gitlab.com/dword4/hockey-info&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This is probably as “complete” as the Hockey-Info project may ever get so I figured its worth an actual blog post (and git tag at v1.0 too). A little over a year ago I was fed up with the &lt;span class="caps"&gt;NHL&lt;/span&gt;’s mobile website and decided I wanted to create something that gave me all the information without the associated fluff and annoyance. I had already spent time documenting the &lt;span class="caps"&gt;NHL&lt;/span&gt; &lt;span class="caps"&gt;API&lt;/span&gt; and using that knowledge to build smaller things like a sopel plugin for hockey stats. So I started throwing things together with Flask and suddenly hockey-info.online came to&amp;nbsp;be!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Features&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;News&amp;nbsp;Headlines&lt;/li&gt;
&lt;li&gt;Scores view (only shows today’s&amp;nbsp;games/scores)&lt;/li&gt;
&lt;li&gt;Standings (grouped by Conference/Division and sometimes showing&amp;nbsp;Wildcards)&lt;/li&gt;
&lt;li&gt;Schedule (day, week and month views, team specific or league&amp;nbsp;wide)&lt;/li&gt;
&lt;li&gt;Team&amp;nbsp;Views&lt;/li&gt;
&lt;li&gt;Regular&amp;nbsp;Season&lt;/li&gt;
&lt;li&gt;Playoffs&lt;/li&gt;
&lt;li&gt;Previous&amp;nbsp;Games&lt;/li&gt;
&lt;li&gt;Game&amp;nbsp;details&lt;/li&gt;
&lt;li&gt;Box Score&amp;nbsp;information&lt;/li&gt;
&lt;li&gt;Goals by period with&amp;nbsp;details&lt;/li&gt;
&lt;li&gt;Shots on goal by&amp;nbsp;period&lt;/li&gt;
&lt;li&gt;Penalties by period with&amp;nbsp;details&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Important&amp;nbsp;Details&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Built in Python 3 with Flask, Requests, and some various other bits and bobs. It runs either by itself with the usual process to launch a Flask application or if you are so inclined there is a Dockerfile that can be used to launch it with a little less&amp;nbsp;pain.&lt;/p&gt;
&lt;p&gt;There is some caching going on with requests_cache however this is by no means optimal, I would like to eventually do more work with a proper web cache but for now this works since the site is so light weight. I make use of CDNs for all the JavaScript so that also helps speed things up (and more importantly move the burden off of wherever you choose to run it in the first&amp;nbsp;place).&lt;/p&gt;
&lt;p&gt;Timezone awareness is non-existent, I basically converted everything from whatever the &lt;span class="caps"&gt;NHL&lt;/span&gt; stores (&lt;span class="caps"&gt;UTC&lt;/span&gt; time/date) to Eastern Time since that is where I live. I try to be very privacy conscious and I couldn’t justify the time expenditure in methods of determining user location for time conversion processes, if someone wants to suggest it or contribute it PRs are&amp;nbsp;welcome.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Legal&amp;nbsp;Considerations&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I have zero affiliation with the &lt;span class="caps"&gt;NHL&lt;/span&gt; beyond sometimes buying their branded merchandise and viewing their games when I get the chance. There are no ads served by the application (or even any decent way to add them without altering all the templates) so I make no money from anything (not even the&amp;nbsp;blog).&lt;/p&gt;</content><category term="programming"/></entry><entry><title>Quick Code: Repo List</title><link href="https://dword4.github.io/git-repo-list.html" rel="alternate"/><published>2020-05-19T00:00:00-04:00</published><updated>2020-05-19T00:00:00-04:00</updated><author><name>dword</name></author><id>tag:dword4.github.io,2020-05-19:/git-repo-list.html</id><summary type="html">&lt;p&gt;Quick little bit of code to let you list all repos your currently logged in account can&amp;nbsp;access&lt;/p&gt;</summary><content type="html">&lt;hr&gt;
&lt;p&gt;So I ran into an interesting problem over the weekend, I forgot my &lt;span class="caps"&gt;2FA&lt;/span&gt; token for Gitlab at home while I was away. My laptop&amp;#8217;s &lt;span class="caps"&gt;SSH&lt;/span&gt; key was already loaded into Gitlab so I knew I could clone any of my repositories if only I could remember the exact name. That of course turned out to be the problem: I couldn&amp;#8217;t remember the name of a specific repository that I wanted to work on. I even tried throwing a bunch of things at git clone to try to guess it and still had no luck. Enter the Gitlab &lt;span class="caps"&gt;API&lt;/span&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;#!/usr/bin/env python3

import requests
from tabulate import tabulate

personal_token = &amp;#39;asdf132kj6lkj1lk6j&amp;#39;
user_id = &amp;#39;dword4&amp;#39;

base_url = &amp;#39;https://gitlab.com/api/v4/&amp;#39;
repo_url = &amp;#39;users/&amp;#39;+user_id+&amp;#39;/projects&amp;#39;

full_url = base_url + repo_url + &amp;#39;?private_token=&amp;#39; + personal_token

res = requests.get(full_url).json()

table = []
for project in res:
    name = project[&amp;#39;name&amp;#39;]
    name_spaced = project[&amp;#39;name_with_namespace&amp;#39;]
    path = project[&amp;#39;path&amp;#39;]
    if project[&amp;#39;description&amp;#39;] is None:
        description = &amp;#39;&amp;#39;
    else:
        description = project[&amp;#39;description&amp;#39;]
    table.append([name, description])
print(tabulate(table, headers=[&amp;quot;name&amp;quot;, &amp;quot;description&amp;quot;]))
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This is of course super simplistic and does virtually no error checking, fancy formatting, etc. However now with a quick alias I can get a list of my repositories even when I do flake out and forget my token at&amp;nbsp;home.&lt;/p&gt;</content><category term="programming"/><category term="git"/><category term="python"/></entry><entry><title>Terraform – Reference parent resources</title><link href="https://dword4.github.io/reference-parent-resource-tf.html" rel="alternate"/><published>2020-05-02T00:00:00-04:00</published><updated>2020-05-02T00:00:00-04:00</updated><author><name>dword</name></author><id>tag:dword4.github.io,2020-05-02:/reference-parent-resource-tf.html</id><summary type="html">&lt;p&gt;How to reference a parent resource in&amp;nbsp;Terraform&lt;/p&gt;</summary><content type="html">&lt;p&gt;Sometimes things get complicated in Terraform, like when I touch it and make a proper mess of the code. Here is a fairly straight forward example of how to reference parent resources in a&amp;nbsp;child.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;├── Child
│   └── main.tf
└── main.tf

1 directory, 2 files
$ pwd
/Users/dword4/Terraform
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;First lets look at what should be in the top level main.tf file, the substance of which is not super important other than to have a rough idea of what you&amp;nbsp;want/need&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kr"&gt;provider&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;&amp;quot;aws&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="na"&gt;region&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;us-east-2&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="na"&gt;profile&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;lab-profile&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nb"&gt;terraform&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kr"&gt;backend&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;&amp;quot;s3&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# lets create an ECS cluster&lt;/span&gt;

&lt;span class="kr"&gt;resource&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;&amp;quot;aws_ecs_cluster&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;&amp;quot;goats&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;goat-herd&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kr"&gt;output&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;&amp;quot;ecs_cluster_id&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;aws_ecs_cluster.goats.id&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;What this does simply is create an &lt;span class="caps"&gt;ECS&lt;/span&gt; cluster with the name &amp;#8220;goat-herd&amp;#8221; in us-east-2 and then outputs ecs_cluster_id which contains the &lt;span class="caps"&gt;ID&lt;/span&gt; of the cluster. While we don&amp;#8217;t necessarily need the value outputted visually to us, we need the output because it makes the data available to other modules including child objects. Now lets take a look at what should be in&amp;nbsp;Child/main.tf&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kr"&gt;provider&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;&amp;quot;aws&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="na"&gt;region&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;us-east-2&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="na"&gt;profile&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;lab-profile&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nb"&gt;terraform&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kr"&gt;backend&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;&amp;quot;s3&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kr"&gt;module&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;&amp;quot;res&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;../../Terraform&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kr"&gt;output&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;&amp;quot;our_cluster_id&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;${module.res.ecs_cluster_id}&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;What is going on in this file is that it creates a module called res and sources it from the parent directory where the other main.tf file resides. This allows us to reference the module and the outputs it houses, enabling us to access the ecs_cluster_id value and use it within other resources as&amp;nbsp;necessary.&lt;/p&gt;</content><category term="cloud"/><category term="aws"/><category term="cloud"/><category term="terraform"/></entry><entry><title>Managing a Growing Project</title><link href="https://dword4.github.io/managing-growing-project.html" rel="alternate"/><published>2020-05-01T00:00:00-04:00</published><updated>2020-05-01T00:00:00-04:00</updated><author><name>dword</name></author><id>tag:dword4.github.io,2020-05-01:/managing-growing-project.html</id><summary type="html">&lt;p&gt;Thoughts on managing a project as it grows more&amp;nbsp;complex&lt;/p&gt;</summary><content type="html">&lt;hr&gt;
&lt;p&gt;I am no Project Manager in even the loosest sense of the word. Despite that I find myself learning more and more of the processes of &lt;span class="caps"&gt;PM&lt;/span&gt;. This is especially true when projects start to expand and grow. Specifically I am speaking about the &lt;span class="caps"&gt;NHL&lt;/span&gt; &lt;span class="caps"&gt;API&lt;/span&gt; project I started almost two years ago. This lead me to the rabbit hole that is permissions and how to manage the project overall going forward. The projects roots are very rough, even today I still generally commit directly to master. Now the repository has grown to over 70 commits, two distinct files and 17&amp;nbsp;contributors.&lt;/p&gt;
&lt;h4&gt;&lt;strong&gt;Balance&lt;/strong&gt;&lt;/h4&gt;
&lt;p&gt;I am constantly trying to be cognizant of is becoming overly possessive of the project. While it may have started as a one-man show I want and enjoy contributions from others. The converse of worrying about becoming possessive is that there are times when steering is necessary. One of the instances that comes to mind is the suggestion of including example code. The goal of the project is documentation, so I declined such suggestions. Unmaintained code becomes a hindrance over time and I don&amp;#8217;t want to add that complexity to the&amp;nbsp;project. &lt;/p&gt;
&lt;h4&gt;&lt;strong&gt;Growth&lt;/strong&gt;&lt;/h4&gt;
&lt;p&gt;There is often a pressure to grow projects, to make them expand over time and change. Its a common thing for businesses to always want growth and it seems that mentality has spread to software. Something like the &lt;span class="caps"&gt;NHL&lt;/span&gt; &lt;span class="caps"&gt;API&lt;/span&gt; is a very slow changing thing, just looking at the commit history shows this. Weeks and months will go by without new contributions or even me looking at the &lt;span class="caps"&gt;API&lt;/span&gt; itself. I dabbled with ideas such as using Swagger to generate more appealing documentation. Every time I tried to add something new and unique I realized it felt forced. This ultimately forced me to accept that growth will not be happening, the project has likely reached its zenith.&lt;mark class="annotation-text annotation-text-yoast" id="annotation-text-1d274ed2-619d-46e6-be96-9bcdb68488be"&gt;&lt;/mark&gt; &lt;/p&gt;
&lt;h4&gt;&lt;strong&gt;Looking&amp;nbsp;Forward&lt;/strong&gt;&lt;/h4&gt;
&lt;p&gt;The next steps are likely small quality-of-life things such as the recent Gitter.im badge. Things that make it easier for people to interact but don&amp;#8217;t change the project overall. My knowledge of the &lt;span class="caps"&gt;API&lt;/span&gt; makes for fast answers so I try to help out when I am&amp;nbsp;able.&lt;/p&gt;</content><category term="programming"/><category term="code"/><category term="hockey"/><category term="NHL"/><category term="NHL-api"/><category term="programming"/><category term="project-management"/></entry><entry><title>Selecting an AWS subnet by name in Terraform</title><link href="https://dword4.github.io/aws-subnet-by-name.html" rel="alternate"/><published>2020-02-12T00:00:00-05:00</published><updated>2020-02-12T00:00:00-05:00</updated><author><name>dword</name></author><id>tag:dword4.github.io,2020-02-12:/aws-subnet-by-name.html</id><summary type="html">&lt;p&gt;Selecting an &lt;span class="caps"&gt;AWS&lt;/span&gt; Subnet by name using&amp;nbsp;Terraform&lt;/p&gt;</summary><content type="html">&lt;p&gt;One of my recent challenges has been to write tf code to select existing &lt;a href="https://www.terraform.io/docs/providers/aws/d/subnet.html"&gt;subnets&lt;/a&gt; and use them in new blocks of code (specifically in this case to create a Directory, Workspaces and add a few Security Group entries). Since I am relatively new to using Terraform to do this it took far longer to figure out than I would care to say and I figured it would be best to document what finally worked and had the concept click for me in my&amp;nbsp;mind. &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kr"&gt;provider&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;&amp;quot;aws&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="na"&gt;region&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;us-east-1&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kr"&gt;variable&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;&amp;quot;subnet_name&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="na"&gt;default&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;workspaces-private-us-east-1c&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kr"&gt;data&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;&amp;quot;aws_subnet&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;&amp;quot;selected&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nb"&gt;filter&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;tag:Name&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="na"&gt;values&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;${var.subnet_name}&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kr"&gt;output&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;&amp;quot;vpcid&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;${data.aws_subnet.selected.vpc_id}&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kr"&gt;output&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;&amp;quot;subnet_name&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;${var.subnet_name}&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kr"&gt;output&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;&amp;quot;subnet_id&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;${data.aws_subnet.selected.id}&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This will look up the named subnet &amp;#8220;workspaces-private-us-east-1c&amp;#8221; and obtain not only the &lt;span class="caps"&gt;VPC&lt;/span&gt; &lt;span class="caps"&gt;ID&lt;/span&gt; associated with it but the unique subnet id as well, the output should look something like the below sample provided the name you are looking up is&amp;nbsp;unique&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;data.aws_subnet.selected:&lt;span class="w"&gt; &lt;/span&gt;Refreshing&lt;span class="w"&gt; &lt;/span&gt;state...

Apply&lt;span class="w"&gt; &lt;/span&gt;complete!&lt;span class="w"&gt; &lt;/span&gt;Resources:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;added,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;changed,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;destroyed.

Outputs:

&lt;span class="nv"&gt;subnet_id&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;subnet-0299e079c90b20ea6
&lt;span class="nv"&gt;subnet_name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;workspaces-private-us-east-1c
&lt;span class="nv"&gt;vpcid&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;vpc-04066bef0a56ebcc2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This is of course specific to things as of Terraform 0.12.20 and provider.aws 2.48.0 so naturally things may change over time, however this will get you close and provide you enough of a starting point to use these subnets in other&amp;nbsp;things.&lt;/p&gt;</content><category term="cloud"/><category term="aws"/><category term="terraform"/></entry><entry><title>Apple 7th Gen iPad + Smart Cover Fix</title><link href="https://dword4.github.io/apple-7th-gen-ipad-smart-cover-fix.html" rel="alternate"/><published>2020-01-12T00:00:00-05:00</published><updated>2020-01-12T00:00:00-05:00</updated><author><name>dword</name></author><id>tag:dword4.github.io,2020-01-12:/apple-7th-gen-ipad-smart-cover-fix.html</id><summary type="html">&lt;hr&gt;
&lt;p&gt;Perhaps the most frustrating part of using the Apple Smart Cover with the 7th Gen iPad is that the keyboard just randomly stops working from time to time with no real rhyme or reason as to why. After lots of searching around and not getting anywhere I finally found a …&lt;/p&gt;</summary><content type="html">&lt;hr&gt;
&lt;p&gt;Perhaps the most frustrating part of using the Apple Smart Cover with the 7th Gen iPad is that the keyboard just randomly stops working from time to time with no real rhyme or reason as to why. After lots of searching around and not getting anywhere I finally found a solution that works like a&amp;nbsp;charm&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Physically disconnect cover from the&amp;nbsp;iPad&lt;/li&gt;
&lt;li&gt;Reconnect the&amp;nbsp;cover&lt;/li&gt;
&lt;li&gt;use Cmd + Tab to switch through a few&amp;nbsp;apps&lt;/li&gt;
&lt;li&gt;resume typing because Apple hasn&amp;#8217;t fixed this in the software&amp;nbsp;yet&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Considering I have seen articles from like 2 years ago where this was an issue it really feels like Apple should have fixed this by now but nope, an up to date 7th generation iPad in 2020 is still having this issue. Makes me wonder what that premium price tag for most Apple goods go to if not fixing/refining the&amp;nbsp;products.&lt;/p&gt;</content><category term="fixes"/><category term="apple"/><category term="fix"/><category term="ios"/><category term="ipad"/></entry><entry><title>Patching CentOS 7 (and overcoming problems)</title><link href="https://dword4.github.io/patching-centos-7-and-overcoming-problems.html" rel="alternate"/><published>2019-06-19T00:00:00-04:00</published><updated>2019-06-19T00:00:00-04:00</updated><author><name>dword</name></author><id>tag:dword4.github.io,2019-06-19:/patching-centos-7-and-overcoming-problems.html</id><summary type="html">&lt;hr&gt;
&lt;p&gt;So I was working on patching some of my Icinga infrastructure at work, and it seems that sometimes libyajl breaks things, as illustrated&amp;nbsp;below&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;root@icingasatellite ~]# yum update
 Loaded plugins: fastestmirror, rhnplugin
 This system is receiving updates from RHN Classic or Red Hat Satellite.
 Loading mirror speeds from cached hostfile …&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</summary><content type="html">&lt;hr&gt;
&lt;p&gt;So I was working on patching some of my Icinga infrastructure at work, and it seems that sometimes libyajl breaks things, as illustrated&amp;nbsp;below&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;root@icingasatellite ~]# yum update
 Loaded plugins: fastestmirror, rhnplugin
 This system is receiving updates from RHN Classic or Red Hat Satellite.
 Loading mirror speeds from cached hostfile`

  * `epel: mirror.optus.net
 Resolving Dependencies
 --&amp;gt; Running transaction check
 ---&amp;gt; Package icinga2.x86_64 0:2.10.4-1.el7.icinga will be updated
 ---&amp;gt; Package icinga2.x86_64 0:2.10.5-1.el7.icinga will be an update
 ---&amp;gt; Package icinga2-bin.x86_64 0:2.10.4-1.el7.icinga will be updated
 ---&amp;gt; Package icinga2-bin.x86_64 0:2.10.5-1.el7.icinga will be an update
 --&amp;gt; Processing Dependency: libyajl.so.2()(64bit) for package: icinga2-bin-2.10.5-1.el7.icinga.x86_64
 Traceback (most recent call last):
 File &amp;quot;/bin/yum&amp;quot;, line 29, in 
 yummain.user_main(sys.argv[1:], exit_code=True)
 File &amp;quot;/usr/share/yum-cli/yummain.py&amp;quot;, line 375, in user_main
 errcode = main(args)
 File &amp;quot;/usr/share/yum-cli/yummain.py&amp;quot;, line 239, in main
 (result, resultmsgs) = base.buildTransaction()
 File &amp;quot;/usr/lib/python2.7/site-packages/yum/`**`init`**`.py&amp;quot;, line 1198, in buildTransaction
 (rescode, restring) = self.resolveDeps()
 File &amp;quot;/usr/lib/python2.7/site-packages/yum/depsolve.py&amp;quot;, line 893, in resolveDeps
 CheckDeps, checkinstalls, checkremoves, missing = self._resolveRequires(errors)
 File &amp;quot;/usr/lib/python2.7/site-packages/yum/depsolve.py&amp;quot;, line 1025, in _resolveRequires
 (checkdep, missing, errormsgs) = self._processReq(po, dep)
 File &amp;quot;/usr/lib/python2.7/site-packages/yum/depsolve.py&amp;quot;, line 350, in _processReq
 CheckDeps, missingdep = self._requiringFromTransaction(po, requirement, errormsgs)
 File &amp;quot;/usr/lib/python2.7/site-packages/yum/depsolve.py&amp;quot;, line 680, in _requiringFromTransaction
 rel=pkg.rel)
 File &amp;quot;/usr/lib/python2.7/site-packages/yum/`**`init`**`.py&amp;quot;, line 5280, in update
 availpkgs = self._compare_providers(availpkgs, requiringPo)
 File &amp;quot;/usr/lib/python2.7/site-packages/yum/depsolve.py&amp;quot;, line 1648, in _compare_providers
 bestnum = max(pkgresults.values())
 ValueError: max() arg is an empty sequence
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Turns out the secret is simply to install yajl and yajl-devel and then I can patch successfully, really surprised nobody else out there has run into this yet but its the second time in a month I have had it happen when&amp;nbsp;patching.&lt;/p&gt;</content><category term="sysadmin"/><category term="linux"/><category term="centos7"/></entry><entry><title>Simple CI with Chef</title><link href="https://dword4.github.io/simple-ci-chef.html" rel="alternate"/><published>2018-09-04T00:00:00-04:00</published><updated>2018-09-04T00:00:00-04:00</updated><author><name>dword</name></author><id>tag:dword4.github.io,2018-09-04:/simple-ci-chef.html</id><summary type="html">&lt;p&gt;Creating a simple pipeline using&amp;nbsp;Chef&lt;/p&gt;</summary><content type="html">&lt;p&gt;So I needed to work out a way to make a script I wrote recently be deployed across a whole host of systems, turns out the only option is Chef so I had to dive into it and read a bunch of stuff.  Also had to try a bunch of things and ended up with my own Chef server in the lab to test against.  Several hours of clicking and clacking later and I have my task worked out, so here it&amp;nbsp;is.&lt;/p&gt;
&lt;p&gt;First we need to create a new cookbook and drop a pretty simple default recipe in, all it does is make sure git is installed then clone a repo to&amp;nbsp;/opt/nhlapi.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="c1"&gt;# Cookbook:: repo&lt;/span&gt;
&lt;span class="c1"&gt;# Recipe:: default&lt;/span&gt;
&lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="c1"&gt;# Copyright:: 2018, The Authors, All Rights Reserved.&lt;/span&gt;
&lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="n"&gt;package&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;git&amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;do&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;action&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ss"&gt;:install&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;/opt/nhlapi&amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;do&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;git://gitlab.com/dword4/nhlapi.git&amp;#39;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;revision&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;master&amp;#39;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;action&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ss"&gt;:sync&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rb&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;END&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Once we have the recipe we need a role to tell it what to&amp;nbsp;do.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;repo-update&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;description&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;update chef from time to time&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;json_class&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Chef::Role&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;default_attributes&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;chef_client&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;interval&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1800&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;splay&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;override_attributes&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;chef_type&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;role&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;run_list&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;recipe[chef-client::default]&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;recipe[chef-client::delete_validation]&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;env_run_lists&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Create the role&amp;nbsp;with &lt;code&gt;# knife role from file repo-update.json&lt;/code&gt;  (or whatever you named the file to create the role&amp;nbsp;from).&lt;/p&gt;
&lt;p&gt;Now all that is left is to assign the role to the node so&amp;nbsp;use &lt;code&gt;#knife node edit itsj-cheftest.itscum.local&lt;/code&gt; and assign the role and repo to the node we&amp;nbsp;want&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;itsj-cheftest.itscum.local&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;chef_environment&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;_default&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;normal&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;tags&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;policy_name&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;policy_group&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;&amp;quot;run_list&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;recipe[nginx]&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;recipe[repo]&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;role[repo-update]&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;That is enough to get it working, you can kick back and watch it&amp;nbsp;with &lt;code&gt;while :; do knife status 'role:repo-update' run-list; sleep 120; done&lt;/code&gt; and wait to see it run in about 30 minutes based on the interval and splay values.  Speaking of which Interval is pretty self explanatory, but Splay not-so-much; Splay is used keep a bunch of nodes from all running at once basically so it doesn&amp;#8217;t overwhelm a system that they might be checking into or otherwise digitally&amp;nbsp;assaulting.&lt;/p&gt;</content><category term="automation"/><category term="automation"/><category term="chef"/><category term="CI"/><category term="devops"/><category term="git"/></entry><entry><title>Simple Icinga2 Plugin</title><link href="https://dword4.github.io/simple-icinga2-plugin.html" rel="alternate"/><published>2018-07-30T00:00:00-04:00</published><updated>2018-07-30T00:00:00-04:00</updated><author><name>dword</name></author><id>tag:dword4.github.io,2018-07-30:/simple-icinga2-plugin.html</id><summary type="html">&lt;p&gt;A simple Icinga2 Plugin to build off&amp;nbsp;of&lt;/p&gt;</summary><content type="html">&lt;hr&gt;
&lt;p&gt;I&amp;#8217;ve seen bits and pieces of the process of creating an Icinga2 (or Nagios) plugin, so here are my notes dumped straight from my&amp;nbsp;brain.&lt;/p&gt;
&lt;p&gt;First and foremost we need a script to call from Icinga, in this case I created a very simple Python script to simply get the version of LibreNMS running on my monitoring&amp;nbsp;system.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;#!/usr/bin/python
import argparse
import requests
import json
import sys

parser = argparse.ArgumentParser(description=&amp;#39;Process some integers.&amp;#39;)

parser.add_argument(&amp;#39;-H&amp;#39;, action=&amp;quot;store&amp;quot;,dest=&amp;quot;host&amp;quot;, help=&amp;#39;name of host to check&amp;#39;)

#parser.add_argument(&amp;#39;token&amp;#39;, metavar=&amp;#39;token&amp;#39;, help=&amp;#39;API token&amp;#39;)
token = &amp;#39;yourAPItokenGOEShere&amp;#39;
args = parser.parse_args()

host_check = &amp;#39;http://&amp;#39;+args.host+&amp;#39;/api/v0/system&amp;#39;
headers = {&amp;#39;X-Auth-Token&amp;#39;: token }
r = requests.get(host_check, headers=headers,verify=False)

json_string = r.text
parsed_json = json.loads(json_string)

system_status = parsed_json[&amp;#39;status&amp;#39;]
system_ver = parsed_json[&amp;#39;system&amp;#39;][0][&amp;#39;local_ver&amp;#39;]

if system_status == &amp;#39;ok&amp;#39;:
    ret = &amp;quot;status: &amp;quot;+system_status+&amp;quot; version:&amp;quot;+system_ver
    print(ret)
    sys.exit(0)
elif system_status != &amp;#39;ok&amp;#39;:
    ret = &amp;quot;status: &amp;quot;+system_status+&amp;quot; version:&amp;quot;+system_ver
    print(ret)
    sys.exit(3)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This is a pretty simple script, you could call it with ./check_lnms_ver.py -H 192.168.1.100 to see how it works.  With the script working the next portion is done in the command line, first create the directory that will later be referenced as&amp;nbsp;CustomPluginDir&lt;/p&gt;
&lt;p&gt;&lt;code&gt;# mkdir -p /opt/monitoring/plugins&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Now we need to tell Icinga2 about the directory, this is done in a few different&amp;nbsp;places&lt;/p&gt;
&lt;p&gt;in &lt;strong&gt;/etc/icinga2/constants.conf&lt;/strong&gt; add the&amp;nbsp;following&lt;/p&gt;
&lt;p&gt;&lt;code&gt;const CustomPluginDir = &amp;amp;#8220;/opt/monitoring/plugins&amp;amp;#8221;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;and in &lt;strong&gt;/etc/icinga2/conf.d/commands.conf&lt;/strong&gt; we add the following&amp;nbsp;block&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;object CheckCommand &amp;quot;check-lnms&amp;quot; {
    command = [ CustomPluginDir + &amp;quot;/check_librenms.py&amp;quot; ]

    arguments = {
        &amp;quot;-H&amp;quot; = &amp;quot;$address$&amp;quot;
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The block above defines the custom command, specifies the script we created first and also passes the correct flags.  Now its time to add the check into the hosts.conf file, so place the following block into &lt;strong&gt;/etc/icinga2/conf.d/hosts.conf&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;object Host &amp;quot;itsj-lnms&amp;quot; {
        address = &amp;quot;192.168.1.85&amp;quot;
        check_command = &amp;quot;check-lnms&amp;quot;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And with that we wait for the next polling cycle and should see something like the screenshot below
&lt;a href="images/Greenshot-2018-07-30-14.18.48.png"&gt;&lt;img alt="screenshot" src="images/Greenshot-2018-07-30-14.18.48.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This is a highly simplistic example, but figuring it out was necessary for me because I had to port some existing code from Ruby to Python so I wanted to know exactly how a plugin was created to understand what values were returned and how it all fits&amp;nbsp;together.&lt;/p&gt;</content><category term="Homelab"/><category term="homelab"/><category term="linux"/><category term="programming"/><category term="icinga"/><category term="monitoring"/></entry><entry><title>Homelab: Synology failure post-mortem</title><link href="https://dword4.github.io/synology-post-mortem.html" rel="alternate"/><published>2018-07-02T00:00:00-04:00</published><updated>2018-07-02T00:00:00-04:00</updated><author><name>dword</name></author><id>tag:dword4.github.io,2018-07-02:/synology-post-mortem.html</id><summary type="html">&lt;p&gt;a post-mortem of my Synology storage system&amp;#8217;s&amp;nbsp;failure&lt;/p&gt;</summary><content type="html">&lt;hr&gt;
&lt;p&gt;I take my homelab very seriously, its modeled after several production environments I have worked on over the years. What follows is my recap of events over a few weeks leading up to the total failure of my central storage system, my beloved Synology &lt;span class="caps"&gt;DS1515&lt;/span&gt; hosting 5.&lt;span class="caps"&gt;5TB&lt;/span&gt; of redundant network storage. The first signs of problems cropped up on May 31st and culminated over the last week in&amp;nbsp;June.&lt;/p&gt;
&lt;!--more--&gt;

&lt;h3&gt;Prelude&lt;/h3&gt;
&lt;p&gt;So about a month ago I got a curious alert from LibreNMS about one of my servers going down. Normally this is just me patching things and not scheduling a maintenance window or something. Upon checking the server however &lt;span class="caps"&gt;SNMP&lt;/span&gt; was indeed failing, I logged in to check the server and found snmpd was well and truly hung. No big deal right? I&amp;#8217;ll just reboot it and go on my merry way. I restart the service and watch it for a few minutes and it goes funky again. Now I am wondering what the hell has changed so I start digging into the&amp;nbsp;logs.&lt;/p&gt;
&lt;p&gt;A few minutes later I finally turn something up in /var/log/messages which points to a remote filesystem going away unexpectedly. I only had one remote filesystem mounted at the time, a &lt;span class="caps"&gt;NFS&lt;/span&gt; share for backups of VMs so I go check the storage system to see what is&amp;nbsp;up.&lt;/p&gt;
&lt;p&gt;Upon trying to login to the web interface of the storage system I find it unresponsive, so I try to ssh to it instead. Nope, not having that either it seems, maybe it will respond to ping? Naturally that didn&amp;#8217;t work either, so now I am confused as to what is going on. About that time I check my email to see if I got any alerts but alas there nothing. Fresh out of ideas I trot myself downstairs and stab the power button a few times until it turns blue and starts coming back, a little weird it took more than one poke but&amp;nbsp;whatever.&lt;/p&gt;
&lt;p&gt;As the storage system comes back up I hear a beep of an incoming email; seems it did in fact have a power failure and shut&amp;nbsp;down&amp;#8230;&lt;/p&gt;
&lt;p&gt;&lt;a href="images/storage-email-1024x163.png"&gt;&lt;img alt="screenshot" src="images/storage-email-1024x163.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Intermission&lt;/h3&gt;
&lt;p&gt;All is well for a few weeks, then some drunken idiot snaps a telephone pole about 1am and knocks everything offline.  Seems I sleep too heavily to hear an accident less than 50 ft away.  I also sleep too soundly to hear the chorus of &lt;span class="caps"&gt;UPS&lt;/span&gt; alert tones telling me the entire lab was about to shut down ungracefully.  The power company took a few hours to get me power back, Comcast however took two&amp;nbsp;days.&lt;/p&gt;
&lt;p&gt;Surprisingly the lab all came back fine other than a storm of delayed alerts and some VMs that didn&amp;#8217;t start automatically.  Once I get all the alerts cleared I call it a day and go relax.  Unfortunately I was unaware that I had maybe another 24h of peace before the Synology decided to truly flake&amp;nbsp;out.&lt;/p&gt;
&lt;h3&gt;Finale&lt;/h3&gt;
&lt;p&gt;On June 27th out of the blue I start getting hammered with alerts via Pushover coming from the lab.  Seems a bunch of VMs on xenserver are unhappy.  Login, check and they look green in xen orchestra, what about monitoring?  Yep monitoring says they are down, starting to have flashbacks to the previous storage problems.  I run through all the same steps I have before and come to the conclusion that storage is down again.  I start it up once more and this time it takes even longer to convince the power button to work.  Later in the evening it goes down again, not even a full 24h of uptime on it.  At this point I start to accept that its probably dying and I may lose a lot of data including backups and &lt;span class="caps"&gt;VM&lt;/span&gt;&amp;nbsp;disks.&lt;/p&gt;
&lt;p&gt;With plans in mind for a replacement I went about my business and disabled a few monitors to cut down on noise.  With those monitors disabled I started the selection process for a replacement which I&amp;#8217;m still working on.  Several hours later I get an alert that my xenserver is down.  Fast-forward 5 minutes and I get a cleared notification that its back to normal.  At this point I am tired so I just call it a night and silence my&amp;nbsp;phone.&lt;/p&gt;
&lt;p&gt;The following day I get more of the same alerts for both xen and proxmox along with the recoveries as well.  By the afternoon I get fed up and just ignore all the alerts from both servers completely.  This of course is making my neck itch, I hate not knowing what is going on in the lab.  Several days go by and I am still wondering about the weird alerts.  I look in LibreNMS to find that its happening on a regular interval, this is&amp;nbsp;interesting!&lt;/p&gt;
&lt;p&gt;&lt;a href="images/Greenshot-2018-07-02-16.39.57-1-1024x330.png"&gt;&lt;img alt="screenshot" src="images/Greenshot-2018-07-02-16.39.57-1-1024x330.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Focusing on the monitoring system I checked crontab for a few users and didn&amp;#8217;t find anything useful. Upon checking cron.d however I finally found the culprit, or at least a smoking gun of&amp;nbsp;sorts.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;# Using this cron file requires an additional user on your system, please see install docs.

33  */6   * * *   librenms    /opt/librenms/discovery.php -h all &amp;amp;gt;&amp;amp;gt; /dev/null 2&amp;amp;gt;&amp;amp;1
*/5  *    * * *   librenms    /opt/librenms/discovery.php -h new &amp;amp;gt;&amp;amp;gt; /dev/null 2&amp;amp;gt;&amp;amp;1
*/5  *    * * *   librenms    /opt/librenms/cronic /opt/librenms/poller-wrapper.py 16
15   0    * * *   librenms    /opt/librenms/daily.sh &amp;amp;gt;&amp;amp;gt; /dev/null 2&amp;amp;gt;&amp;amp;1
*    *    * * *   librenms    /opt/librenms/alerts.php &amp;amp;gt;&amp;amp;gt; /dev/null 2&amp;amp;gt;&amp;amp;1
*/5  *    * * *   librenms    /opt/librenms/poll-billing.php &amp;amp;gt;&amp;amp;gt; /dev/null 2&amp;amp;gt;&amp;amp;1
01   *    * * *   librenms    /opt/librenms/billing-calculate.php &amp;amp;gt;&amp;amp;gt; /dev/null 2&amp;amp;gt;&amp;amp;1
*/5  *    * * *   librenms    /opt/librenms/check-services.php &amp;amp;gt;&amp;amp;gt; /dev/null 2&amp;amp;gt;&amp;amp;1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now I know its discovery going off every 6 hours, something has to be making it angry. More clicking and clacking on my behalf and I realize that the xenserver discovery takes over 800 seconds.  By now I am fed up with the dead storage system causing me grief, its time to go nuclear.  I go into both xen and proxmox and delete the remote storage as well as any now-dead VMs that lived on it.  Backup jobs? yep deleted those as well since they weren&amp;#8217;t going to run again. One more time I restart snmpd and kick off a discovery manually and await the&amp;nbsp;results.&lt;/p&gt;
&lt;p&gt;Another 800 seconds later I get my answer, still taking too long to complete and failing. Its still the same two servers too despite all my ministrations on them to remove the failed remote storage.  I have advanced from annoyed to frustrated to pissed at this point, I just want things back working and my alert board green. With furious typing I login to the xenserver and manually check the mount points.  What. The. Hell. There are still mount points to the remote filesystems despite Xen Orchestra and the Xen Client telling me that its gone. Tired of all this I run umount -l on the mount point,which is the least polite option I can find for removing it. Again with the restart of snmpd and a discovery and&amp;nbsp;wait.&lt;/p&gt;
&lt;p&gt;Success! Now the discovery is much faster, but there is one more system still slowing it down a bit, the proxmox server.  A quick check reveals its also got the mount pointing hanging around so snmp is still trying to reach it and timing out.  Blow that one away and test again and now discovery is completing in under 10 seconds as opposed to 800. Eager to finally get to bed as its now midnight I re-enable all the monitors on the hypervisors and head for&amp;nbsp;sleep.&lt;/p&gt;
&lt;h3&gt;Conclusions&lt;/h3&gt;
&lt;p&gt;&lt;a href="images/Greenshot-2018-07-02-17.06.50-1-1024x348.png"&gt;&lt;img alt="screenshot" src="images/Greenshot-2018-07-02-17.06.50-1-1024x348.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Monitoring was worth its weight in gold in this situation even for a homelab, it gave me context I didn&amp;#8217;t easily have otherwise.  Being able to look over 48 hours of data made the difference in finding the discovery process possible.  Although I still have a lot of tuning to do for better alerting getting them still prompted my action.  Another point I realized is to never rely on a single tool or information source.  I trusted both xenserver and proxmox to faithfully show me that the storage was gone but they did not.  While that is not a fault of them so much as a discrepancy between &lt;span class="caps"&gt;OS&lt;/span&gt; and applications running on top its still important to&amp;nbsp;note.&lt;/p&gt;
&lt;p&gt;Ticketing was another valuable tool for me in writing this up afterwards.  Being able to look up dates in tickets made finding graphs much easier for me. I am more than a little proud of the fact that I wrote the &lt;a href="https://github.com/librenms/librenms/pull/8246"&gt;Gitlab Transport for LibreNMS&lt;/a&gt; myself, and its nice that its proven useful in the homelab beyond just a programming and &lt;span class="caps"&gt;OSS&lt;/span&gt; contribution&amp;nbsp;project.&lt;/p&gt;
&lt;p&gt;As for the now dead Synology it might be possible to rescue but I am not holding my breath.  One thing is for sure, its replacement will be much larger and probably not an&amp;nbsp;appliance.&lt;/p&gt;</content><category term="homelab"/><category term="homelab"/><category term="librenms"/><category term="linux"/><category term="monitoring"/><category term="xenserver"/></entry><entry><title>Curl within a salt-state</title><link href="https://dword4.github.io/curl-in-salt.html" rel="alternate"/><published>2017-09-12T00:00:00-04:00</published><updated>2017-09-12T00:00:00-04:00</updated><author><name>dword</name></author><id>tag:dword4.github.io,2017-09-12:/curl-in-salt.html</id><summary type="html">&lt;p&gt;using Curl from a within a salt state&amp;nbsp;file&lt;/p&gt;</summary><content type="html">&lt;hr&gt;
&lt;p&gt;So I have been looking all over for how to make this happen and finally figured it out, preserving it for anybody else who wants to kick off a curl in a salt state to say add something into monitoring or begin another process via an &lt;span class="caps"&gt;API&lt;/span&gt;&amp;nbsp;call&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;# this will perform a curl on the target minion
do_a_curl:
  cmd.run:
    - name: &amp;amp;gt;-
        curl -X POST -d &amp;#39;{&amp;quot;hostname&amp;quot;:&amp;quot;192.168.1.65&amp;quot;,&amp;quot;version&amp;quot;:&amp;quot;v2c&amp;quot;,&amp;quot;community&amp;quot;:&amp;quot;public&amp;quot;}&amp;#39; -H &amp;#39;X-Auth-Token: 286755fad04869ca523320acce0dc6a4&amp;#39; &amp;quot;http://192.168.1.85/api/v0/devices&amp;quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Right now this is just using testing data from my lab, but as long as you enclose all the salient data in &amp;#8216; or &amp;#8221; it should be&amp;nbsp;fine&lt;/p&gt;</content><category term="automation"/></entry><entry><title>Crontab – Always Check your Environment Variables</title><link href="https://dword4.github.io/always-check-env-variables.html" rel="alternate"/><published>2016-06-16T00:00:00-04:00</published><updated>2016-06-16T00:00:00-04:00</updated><author><name>dword</name></author><id>tag:dword4.github.io,2016-06-16:/always-check-env-variables.html</id><summary type="html">&lt;p&gt;Always remember to check environment variables&amp;nbsp;folks&lt;/p&gt;</summary><content type="html">&lt;hr&gt;
&lt;p&gt;So I have been running into this issue for like a month now where a script that I can run from the command line by hand executes fine, but when I try to run it via a crontab job it just goes absolutely pear shaped without any real explanation.  Finally I got some time at the beginning of a shift to sit with one of our senior guys to take a look at it as the script provides data the entire team uses and when it doesn&amp;#8217;t run they get cranky.  It turns out that the environment my cron jobs run as is highly different, as indicated by the following which is obtained by adding a line to output env to a text file every time the crontab job&amp;nbsp;ran.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nv"&gt;XDG_SESSION_ID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;159&lt;/span&gt;
&lt;span class="nv"&gt;SHELL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/bin/sh
&lt;span class="nv"&gt;OLDPWD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home/dword
&lt;span class="nv"&gt;USER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;dword
&amp;lt;strong&amp;gt;PATH&lt;span class="o"&gt;=&lt;/span&gt;/usr/bin:/bin
&amp;lt;/strong&amp;gt;PWD&lt;span class="o"&gt;=&lt;/span&gt;/home/dword/labmap
&lt;span class="nv"&gt;LANG&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;en_US.UTF-8
&lt;span class="nv"&gt;HOME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home/dword
&lt;span class="nv"&gt;SHLVL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;
&lt;span class="nv"&gt;LOGNAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;dword
&lt;span class="nv"&gt;XDG_RUNTIME_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/run/user/1000
&lt;span class="nv"&gt;_&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/bin/env
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Compare that against the results from env when run by&amp;nbsp;hand&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;XDG_SESSION_ID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;145&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;HOSTNAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;dword-cent7
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;TERM&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;xterm
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;SHELL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/bin/bash
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;HISTSIZE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;500000&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;SSH_CLIENT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;192&lt;/span&gt;.168.42.120&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;49429&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;22&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;SSH_TTY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/dev/pts/0
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;USER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;dword
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;LS_COLORS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;rs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;:di&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;34&lt;/span&gt;:ln&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;36&lt;/span&gt;:mh&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;00&lt;/span&gt;:pi&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;40&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;33&lt;/span&gt;:so&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:do&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:bd&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;40&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;33&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;:cd&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;40&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;33&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;:or&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;40&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;:mi&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;05&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;37&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;41&lt;/span&gt;:su&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;37&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;41&lt;/span&gt;:sg&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;30&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;43&lt;/span&gt;:ca&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;30&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;41&lt;/span&gt;:tw&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;30&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;42&lt;/span&gt;:ow&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;34&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;42&lt;/span&gt;:st&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;37&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;44&lt;/span&gt;:ex&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;32&lt;/span&gt;:*.tar&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.tgz&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.arc&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.arj&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.taz&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.lha&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.lz4&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.lzh&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.lzma&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.tlz&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.txz&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.tzo&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.t7z&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.zip&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.z&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.Z&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.dz&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.gz&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.lrz&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.lz&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.lzo&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.xz&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.bz2&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.bz&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.tbz&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.tbz2&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.tz&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.deb&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.rpm&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.jar&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.war&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.ear&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.sar&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.rar&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.alz&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.ace&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.zoo&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.cpio&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.7z&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.rz&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.cab&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;:*.jpg&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.jpeg&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.gif&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.bmp&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.pbm&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.pgm&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.ppm&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.tga&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.xbm&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.xpm&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.tif&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.tiff&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.png&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.svg&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.svgz&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.mng&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.pcx&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.mov&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.mpg&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.mpeg&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.m2v&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.mkv&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.webm&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.ogm&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.mp4&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.m4v&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.mp4v&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.vob&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.qt&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.nuv&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.wmv&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.asf&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.rm&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.rmvb&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.flc&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.avi&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.fli&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.flv&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.gl&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.dl&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.xcf&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.xwd&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.yuv&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.cgm&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.emf&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.axv&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.anx&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.ogv&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.ogx&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;35&lt;/span&gt;:*.aac&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;36&lt;/span&gt;:*.au&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;36&lt;/span&gt;:*.flac&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;36&lt;/span&gt;:*.mid&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;36&lt;/span&gt;:*.midi&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;36&lt;/span&gt;:*.mka&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;36&lt;/span&gt;:*.mp3&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;36&lt;/span&gt;:*.mpc&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;36&lt;/span&gt;:*.ogg&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;36&lt;/span&gt;:*.ra&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;36&lt;/span&gt;:*.wav&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;36&lt;/span&gt;:*.axa&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;36&lt;/span&gt;:*.oga&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;36&lt;/span&gt;:*.spx&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;36&lt;/span&gt;:*.xspf&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;36&lt;/span&gt;:
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;MAIL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/var/spool/mail/dword
&amp;lt;strong&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/dword/.local/bin:/home/dword/bin&amp;lt;/strong&amp;gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;PWD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home/dword/labmap
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;LANG&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;en_US.UTF-8
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;HISTCONTROL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ignoredups
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;SHLVL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;HOME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home/dword
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;LOGNAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;dword
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;SSH_CONNECTION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;192&lt;/span&gt;.168.42.120&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;49429&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;192&lt;/span&gt;.168.33.232&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;22&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;LESSOPEN&lt;/span&gt;&lt;span class="o"&gt;=||&lt;/span&gt;/usr/bin/lesspipe.sh&lt;span class="w"&gt; &lt;/span&gt;%s
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;XDG_RUNTIME_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/run/user/1000
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;_&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/bin/env
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;OLDPWD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home/dword/labmap/web
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Notice the path statement is very sparse when cron outputs the environment variables, turns out that anemic path lacked access to fping which was integral to my script building out a list of live hosts within our lab environment. Once that was fixed the cron jobs hum along nicely and churn out an updated map of the lab every hour without me doing anything and now I know that crontab jobs run with fairly different environment variables than scripts manually ran and can cause all kinds of havoc if you don&amp;#8217;t use full explicit path statements in your bash scripts that you plan to&amp;nbsp;automate.&lt;/p&gt;</content><category term="general"/></entry><entry><title>go find some prime numbers!</title><link href="https://dword4.github.io/go-find-primes.html" rel="alternate"/><published>2015-11-09T00:00:00-05:00</published><updated>2015-11-09T00:00:00-05:00</updated><author><name>dword</name></author><id>tag:dword4.github.io,2015-11-09:/go-find-primes.html</id><summary type="html">&lt;p&gt;finding prime numbers with&amp;nbsp;Go&lt;/p&gt;</summary><content type="html">&lt;hr&gt;
&lt;p&gt;so a few friends keep bugging me that i need to learn their wonderful hipster language go, finally i relented this evening and poked around in it for about 45 minutes to create my tried and true primes code that i can almost do in my sleep now. its ugly and nowhere near as fast as i had it running in c++ back in the day but its kinda cool that i could get it done in about an hour from first writing a line of code in go. i honestly don&amp;#8217;t know if i will ever use the language as a main language in any projects but its the first time i have touched a compiled language in probably the better part of 5 years, these days i do about 105% of my things in python or bash when there are command line tools to do most of what i&amp;nbsp;want.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;quot;fmt&amp;quot;&lt;/span&gt;

&lt;span class="kd"&gt;func&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;limit&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10000&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nx"&gt;lt&lt;/span&gt;&lt;span class="p"&gt;;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;                        &lt;/span&gt;&lt;span class="c1"&gt;// not prime, we care not!&lt;/span&gt;
&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;                        &lt;/span&gt;&lt;span class="c1"&gt;// lets do the test loop thing&lt;/span&gt;
&lt;span class="w"&gt;                        &lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;slimit&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;

&lt;span class="w"&gt;                        &lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;multiples&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="w"&gt;                        &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;jj&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;jj&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nx"&gt;lt&lt;/span&gt;&lt;span class="p"&gt;;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;slimit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;jj&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;                                &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;jj&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;                                        &lt;/span&gt;&lt;span class="nx"&gt;multiples&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;
&lt;span class="w"&gt;                                &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;                                        &lt;/span&gt;&lt;span class="c1"&gt;// no multiples here boss&lt;/span&gt;
&lt;span class="w"&gt;                                &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;                        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;                        &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;multiples&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;                                &lt;/span&gt;&lt;span class="nx"&gt;fmt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;quot;is probably a prime&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;                        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="programming"/></entry></feed>