IT Monitoring Tool
Infrastructure as Code Example

Infrastructure as Code Example for Sysadmins: Why AI Won’t Save You

Managers Want Infrastructure as Code – You Think “Fine, AI Can Do That for Me”

The bulk of position descriptions now carry many dot points like this:

Infrastructure as Code Example: Position Description Example
Infrastructure as Code Example: Position Description Example

That role is titled “Infrastructure Engineer”, it is not a cloud role, it’s paying less than $130,000 and it is not uncommon.

Why is Infrastructure as Code So Important

What is this nonsense and why are you getting overlooked for roles – probably because you don’t have a genuine infrastructure as code example ready to talk about.

Let’s look at a few points to bring us back to reality.

  • “Cloud only” is becoming the norm, especially within small and medium sized businesses.
  • On-prem and hybrid roles/companies are becoming less common.
  • Engineers doing “click-ops” over the years create outages and surprises.
  • Managers want rock solid infrastructure – no outages, no surprises.

👉 The solution has become Infrastructure as Code (IaC).

How This Affected Jobs

Read enough sysadmin and network job ads and you’ll spot a new line wedged between “Active Directory” and “must be comfortable with on-call” – experience with infrastructure as code.

It used to be a developer thing. Now it’s turning up in position descriptions for Windows/Wintel admins, network engineers and systems engineers, usually with Git, Jira and “CI/CD” tagging along like uninvited mates.

The tempting response is to shrug and think, “I’ll just get AI to write the scripts.” and give the recruiters or hiring managers some fluff if they ask me about CICD or IaC. That’s like thinking you can do surgery because you own a knife and you have ChatGPT.

The script is the easy part, the hard part is the process around it: the ticket, the branch, the code review, the testing, and the Atlassian apps like Bitbucket, Jira, SourceTree and Jira Assets which sys admins never had to worry about.

You think you know change control? Wait until you see how developers do it.

This article walks through one complete infrastructure as code example from start to finish. The change is deliberately boring: raising the domain’s minimum password length from 14 characters to 15 using group policy. One extra character and somehow it justifies a week of your time and thousands of dollars.

What infrastructure as code actually means

Infrastructure as code means your systems, firewall policies, group policies, Azure configuration etc, are configured by code (just well-structured text files) that describe what they should look like.

Here is an example of Terraform (one of many tools you can use for IaC) from my What is Terraform Used For article.

Instead of by someone clicking through the Azure console or the Palo Alto firewall dashboard, we are now expected to do the same work using those text files.

Because the text files are basically code, they are stored, versioned and reviewed the same way developers handle application code.

👉 Let that sink in – In 10 years’ time; network/systems/cloud engineers will be much closer to developers than ever before.

Here’s the traditional way to change a firewall rule.

  • You raise a CR.
  • You backup your firewall config.
  • You update the inbound rule to allow port 443.
  • CR complete, ticket closed.

The problem? In 3 years’ time, someone less confident in networking configures it, but accidentally does it on one firewall only. They change the Melbourne Palo Alto while forgetting the Darwin firewall.

5 years later, a different engineer, makes the same change to allow port 3389 and does both firewalls in the active-active pair, but forgets Melbourne.

This is why managers want IaC – it keeps everything the same. Deploy something once or 47 times – identical results.

Here’s the infrastructure as code way.

  • The firewall policy lives as a file in a repository.
  • To change it, you raise a ticket, edit the file on a branch, get a colleague to review the exact line you changed, test it, merge it, then apply it.
  • Anyone can see the ticket number, the reviewer, the date.
  • All future changes are just editing a text file, no clicking around in a portal (“click ops”).

Three things make it proper infrastructure as code rather than “a process that Dave does”:

  • It’s version controlled. Every change is recorded in Git, with who made it and why, and you can roll back.
  • It’s the source of truth. The code describes how production should look. If production disagrees, production is wrong. The fancy term is drift.
  • It’s repeatable. Run the same code against Dev, then Test, then Prod, and you get the same result each time.

That third point is why managers love it. A repeatable change is a predictable change, and predictable changes don’t wake anyone up at 2am. Any infrastructure as code example worth learning from should show all three, and ours will.

One honest caveat: not everything suits this. Some servers, like a certificate authority, are built once and carefully maintained rather than rebuilt from scratch. Even then, the build script and every change to it still belong in Git.

Why AI isn’t the quick fix

AI is genuinely useful for writing scripts, I’m sure we have all heard about the guy who “vibe coded” the entire Adobe suite.

But as we know AI’s accuracy is medium good, it’s like the bloke at the pub explaining interest rates and why you should invest in gold and not a house – he’s probably right, but who has the time to check. Ask it to raise the minimum password length to 15 and you’ll probably get something like this:

Set-ADDefaultDomainPasswordPolicy -Identity monrocloud.local -MinPasswordLength 15

It looks right. It even runs. It’s also a great infrastructure as code example of why you need a process, because it has three problems the AI didn’t mention.

Problem 1: Group Policy will quietly undo it. The domain password policy is controlled by the GPO linked to the root of the domain, normally the Default Domain Policy. That command changes the domain directly, but the GPO still says 14. Domain controllers reapply security policy regularly, and the GPO wins. Your change lasts until the next refresh, then vanishes like a contractor on the last day of a project.

Problem 2: Windows has a 14-character ceiling. For decades, Windows wouldn’t accept a minimum password length above 14. Size matters and Windows was insecure about it. Microsoft’s guidance says you must first enable a setting called Relax minimum password length limits (RelaxMinimumPasswordLengthLimits) on all domain controllers. Without it, a value over 14 is treated as a misconfiguration.

Problem 3: Something will break. Microsoft recommends running the companion Minimum password length audit setting for three to six months first. That’s how you find the ancient app or appliance that silently truncates passwords at 14 characters and locks out the finance team at month end.

None of these are scripting problems. They’re knowledge and process problems. AI wrote a line of code in two seconds; it didn’t raise a ticket, test anything in Dev, get a second opinion or leave an audit trail. That’s the 90% of the job managers are actually hiring for.

So the honest pitch is this: AI makes writing the code faster, which makes the process around the code more important, not less. A fast way to make mistakes still needs a reliable way to catch them. The rest of this infrastructure as code example is about that reliable way.

Thinking like a developer

The biggest shift isn’t learning PowerShell (most sysadmins already script), the shift is learning how developers manage change. Infrastructure as code borrows the developer workflow and here are the dev words you’ll hear, and what they actually mean.

Imagine you had a group policy change to make – raise the password expiry from 14 to 15 characters. Let’s break down some terms/jargon for that example:

Infrastructure as Code Example: Common Terminology in 3 minutes.

Git is a program that tracks changes to files. Every saved version records exactly which lines have changed, who changed them, when, and a message explaining why. It keeps every version forever. An example Atlassian’s Bitbucket.

Repository (repo) is a folder that Git tracks. A folder that keeps every version of your files, like a file share’s Previous Versions (shadow copy) turned on forever. In our example, it’s your C:\GPO folder of exported Group Policy XML files, e.g. Password-Policy.xml. The shared copy lives in Bitbucket, and everyone has their own copy on their PC.

Main is the branch that holds the approved version of your code, matching what’s in production. In our example it’s the approved version of your Group Policy files. Right now Main says the password length is 14, and Group Policy matches.

Branch is a separate copy of the code for one change. In our infrastructure as code example it’s a separate copy of the Password-Policy.xml file. It’s your own test copy of main.

Infrastructure as Code Example: What is a Branch?
Infrastructure as Code Example: What is a Branch?

👉 Test the change here. Many organisations have a DEV environment. You would now copy the updated XML file and import it to a domain controller to updated the changes to 15 characters.

Commit saves a snapshot of your changes, with a message. Until now we have just put an XML file on your computer (e.g. you have exported group policy from a domain controller and copied it to your laptop). We need this file to be tracked for changes.
After you have made the change in the xml file from 14 to 15, SourceTree shows the changed XML file. Type “Password length 15” and click Commit. So far it’s only on your PC and nothing has been saved to Bitbucket.

For a bit more depth, in the folder on your laptop (lets say it’s C:\GPO) your exported file from the domain controller has XML saying “password expiry 14 characters”. When you commit, it doesn’t override that file with the new XML. It creates a new copy of it inside a folder called .git within C:\GPO

Push uploads the commit from your PC to your new branch in Bitbucket. In other words, when you click Push in Source Tree your team can see it because it’s now in a shared location. So far group policy on the domain controllers still has password length set to 14 characters.

Pull downloads the latest changes from Bitbucket into your C:\GPO folder, for the branch you’re on. In our example, we just Pushed the change up to the Bitbucket cloud, our colleagues may now want to download it by using Pull so they can see it on their laptops and approve it.

Merge applies the approved branch to main. Main now reflects the new state of production.

Environment promotion means we now put the same file from Main (which now includes the XML file say min password length is 15 characters from the Merge above) and apply it to any other environments like TEST and PROD.

The toolkit: Jira, Bitbucket and SourceTree

Many organisations run this workflow on the Atlassian suite, because the products are built to talk to each other. You need three of them, plus a text editor, and each one does a single job.

ToolWhat it doesWhere it runsCost to learn on
JiraTracks the change as a ticket: what, why, who, statusWebsite (Jira Cloud)Free for up to 10 users
BitbucketStores the shared code, files, scripts, configs (repo).Website (Bitbucket Cloud)Free for up to 5 users
SourceTreeAn app on your PC for saving, uploading and downloading your code changes to and from Bitbucket, by clicking buttons instead of typing commands.Windows or Mac appFree
VS CodeWhere you actually edit the filesWindows or Mac appFree

Jira is the why. Every change starts as a ticket with a key like IT-1. That short number is the thread that ties everything else together. Jira now calls tickets “work items” and projects “spaces”, the renaming department were clearly bored.

Bitbucket is Atlassian’s website for storing and sharing code, with every version ever saved. Teams review and approve changes there before they become the official version. With Infrastructure as Code, things like scripts, config files and exported Group Policy are treated as code, so they live in Bitbucket too.

SourceTree is Atlassian’s free app on your PC for saving, uploading and downloading your code changes to and from Bitbucket, by clicking buttons instead of typing commands.

The linking is what makes this a suite rather than three separate subscriptions. Put “IT-1” in a branch name or commit message, and Jira’s Development panel shows it automatically. That’s your audit trail building itself while you work.

The free plans are enough to build a full infrastructure as code example at home. Free tier limits are listed by iTechGuides for Jira and for Bitbucket.

A real infrastructure as code example: 14 to 15 characters

This is the full loop, in the order you’d do it. The one-off setup comes first, then the change itself, which you’d repeat for every change after this.

Until now, we referenced the XML file as the place to make the changes from 14 to 15. This was for simplicity, however in reality there are some extra steps. The following is the real world example.

One-off setup

  • Create a Jira space. Use a Kanban template, call it IT Changes, and give it the key IT. Every ticket will be numbered IT-1, IT-2 and so on. Careful: Atlassian Home also has something called “Projects” that’s just for status updates. If the Create button only offers Project, Team and Goal, you’re in the wrong app.
Infrastructure as Code Example: Create a Space
Infrastructure as Code Example: Create a Space
  • Create a Bitbucket repository called group-policy, inside a workspace for your organisation. Make it private and include a README.
Infrastructure as Code Example: Create a Repository
Infrastructure as Code Example: Create a Repository
  • Link Jira to Bitbucket. In your Jira space, open the Development tab and choose Connect Bitbucket. Leave Smart Commits enabled. You only need to do this once.
Infrastructure as Code Example: Link Jira to Bitbucket
Infrastructure as Code Example: Link Jira to Bitbucket
  • Clone the repo in SourceTree. Cloning is downloading your own copy of the code from Bitbucket to your PC for the first time (such as C:\GPO). When asked for a credential helper, choose manager so Windows remembers your login.
Infrastructure as Code Example: Clone the Repo
Infrastructure as Code Example: Clone the Repo
  • Put the current GPO into your repo. Back up the existing GPO onto a server such as the domain controller and then copy it to your laptop’s C:\GPO directory.
Infrastructure as Code Example: Backup the GPO
Infrastructure as Code Example: Backup the GPO
  • In SourceTree, the new files show under File Status. Tick them, type “Baseline: Default Domain Policy” and click Commit. Then click Push. The backup is now in Main in Bitbucket, tracked from here on, and every branch you create will include it.

The change

Step 1: Raise the ticket. Create IT-3: Increase minimum password length from 14 to 15. In the description, say why (e.g. ISM security baseline changes), what else is needed (enable Relax minimum password length limits), and how it’ll be tested. In a real organisation, this ticket is also what goes to the change advisory board (CAB): a meeting where people who’ve never opened GPMC decide whether you may open GPMC.

Infrastructure as Code Example: Raise the Jira Ticket
Infrastructure as Code Example: Raise the Jira Ticket

Step 2: Create a branch from the ticket. On IT-3, in the Development panel, click Create branch. Bitbucket opens with a name like IT-3-increase-min-password-length already filled in. Back in SourceTree, click Fetch, then double-click the new branch under Remotes > origin and click OK to check it out. The bold branch name in SourceTree is the one you’re working on.

Infrastructure as Code Example: Create the Branch
Infrastructure as Code Example: Create the Branch
Infrastructure as Code Example: Create the Branch (2)
Infrastructure as Code Example: Create the Branch (2)
Infrastructure as Code Example: Fetch
Infrastructure as Code Example: Fetch
Infrastructure as Code Example: Select the New Branch
Infrastructure as Code Example: Select the New Branch

Step 3: Make the change in the file. The password settings live in the backup’s GptTmpl.inf file, under DomainSysvol\GPO\Machine\microsoft\windows nt\SecEdit. You change one line and add one:

Infrastructure as Code Example: Change the GptTmpl.inf File
Infrastructure as Code Example: Change the GptTmpl.inf File
 [System Access]
-MinimumPasswordLength = 14
+MinimumPasswordLength = 15

 [Registry Values]
+MACHINE\System\CurrentControlSet\Control\SAM\RelaxMinimumPasswordLengthLimits=4,1

The first line is the actual policy. The second enables the “relax limits” setting, the one AI forgot. Without it, your shiny new 15 is ignored.

Step 4: Create the deploy script. In your C:\GPO folder (on your IT-3 branch), create a new file called Deploy-PasswordPolicy.ps1 and paste this in:

# Deploy-PasswordPolicy.ps1
param([Parameter(Mandatory)][string]$Domain)

Import-GPO -BackupGpoName "Default Domain Policy" `
           -Path "$PSScriptRoot\backups" `
           -TargetName "Default Domain Policy" `
           -Domain $Domain

Save it. You’re not running it yet; it’s run in Step 5 (Dev) and Step 10 (Prod). When it runs, Import-GPO replaces the target GPO’s settings with what’s in the repo.

Step 5: Test in Dev. On a Dev domain controller (or a management server with the Group Policy tools), copy your C:\GPO folder across, including the script and the backups folder. Then run the script against your Dev domain and check the result:

Infrastructure as Code Example: Test it in Dev Environment
Infrastructure as Code Example: Test it in Dev Environment
Get-ADDefaultDomainPasswordPolicy -Server dev.monrocloud.local | Select MinPasswordLength
Infrastructure as Code Example: Confirm Minimum Password Length Increased
Infrastructure as Code Example: Confirm Minimum Password Length Increased

It should report 15. Then try setting a 14-character password on a test account and watch it get rejected. This is the most satisfying part of any infrastructure as code example: proof, not hope.

Step 6: Commit and push. In SourceTree, open File Status, stage all files, and commit with the message IT-3 raise minimum password length to 15.

Infrastructure as Code Example: Commit and Push
Infrastructure as Code Example: Commit and Push
Infrastructure as Code Example: Commit
Infrastructure as Code Example: Commit

Step 7: Click Push. A Push window opens listing your branches. Tick only your IT-3 branch (leave main and the others unticked) and click Push to upload it to Bitbucket.

Infrastructure as Code Example: Push
Infrastructure as Code Example: Push
Infrastructure as Code Example: Push (2)
Infrastructure as Code Example: Push (2)

Step 8: Open a pull request. A pull request asks for your branch to be added to Main, with someone checking it first (step 9 is the actual review). Go to bitbucket.org, open the group-policy repository, click Pull requests in the left menu, then Create pull request. Set the source to your IT-3 branch and the destination to main. In the description, say what you tested in Dev, add a teammate as a reviewer, tick Delete branch after merge (because nobody likes a hoarder), and click Create pull request.

Infrastructure as Code Example: Create a Pull Request
Infrastructure as Code Example: Create a Pull Request
Infrastructure as Code Example: What is a Pull Request?
Infrastructure as Code Example: What is a Pull Request?

Step 9: Review. The reviewer opens the pull request in Bitbucket and clicks the Files changed tab. This is the diff: a view showing only what changed, with removed lines in red and added lines in green. They’ll see the password length go from 14 to 15, the relax-limits line added, and the new deploy script. They’re not reviewing your memory of what you clicked; they’re reviewing the actual change. If it looks right, they click Approve.

🔥Notice below I deleted an old file called New-ScreenLockGPO which is why you see a red negative symbol.

Infrastructure as Code Example: Review Files Changed
Infrastructure as Code Example: Review Files Changed

Step 10: Merge. Once approved, click Merge. Main now says 15, which means main now describes what production should look like.

Infrastructure as Code Example: Merge
Infrastructure as Code Example: Merge
Infrastructure as Code Example: Merge (2)
Infrastructure as Code Example: Merge (2)

Step 11: Deploy to Prod. After change approval, in SourceTree double-click main to switch to it, then click Pull. A Pull window opens. Leave the defaults as they are (remote: origin, remote branch: main, local branch: main, only “Commit merged changes immediately” ticked) and click Pull. Check the history: main and origin/main should now be on the same top commit, so your PC has exactly what was approved.

Then run the same script with the production domain name. Same code, same result, different target. In bigger shops, a CI/CD pipeline runs this step automatically after the merge.

Infrastructure as Code Example: Pull
Infrastructure as Code Example: Pull
Infrastructure as Code Example: Pull (2)
Infrastructure as Code Example: Pull (2)

Step 12: Tidy up. Close IT-3 in Jira. Its Development panel now lists the branch, the commit and the merged pull request.

That’s a complete infrastructure as code example. It took twelve steps to change one number, and every step left evidence behind. The first time feels absurd. The fifth time feels normal. The first time an auditor asks who changed the password policy, it feels like the best decision you ever made.

Gotchas from doing it for real

Tutorials skip the ugly bits. Here are the ones that showed up while building this infrastructure as code example.

Bitbucket accused a one-person workspace of having too many users. The first push failed with error 402, claiming the free 5-user limit was exceeded. The admin page showed exactly one user. I’ve been called many things, but never a crowd. Waiting a while and pushing again fixed it; it’s a known hiccup with new free workspaces. Your commit is safe on your PC until the push works.

Git may show your change as “binary files differ”. GptTmpl.inf is saved as UTF-16, which Git treats as binary by default. Your reviewer then sees nothing useful. Add a .gitattributes file to the repo with this line, and the diff shows properly:

*.inf text working-tree-encoding=UTF-16LE-BOM eol=crlf

Import-GPO overwrites hand edits. If someone changed the Default Domain Policy in the console, your next deploy wipes it. That’s drift being corrected, which is the whole idea, but warn the team before you start. Then make “no clicking in GPMC” a rule, not a suggestion.

Old systems hate long passwords. Before enforcing 15, run the Minimum password length audit setting so you find whatever chokes on it. That’s a separate ticket, branch and pull request, which is the process working as designed.

When not to bother

Not every change deserves 30+ steps. Using the full process to reset a password is like hiring a removalist to move a stapler. A simple rule helps: the more people a change affects, and the harder it is to undo, the more of the process it gets.

Use the full process when:

  • The change hits production and lots of users, like a GPO, a firewall rule or a server build.
  • The change is scripted or will be repeated.
  • Several people work on the same systems.
  • You need an audit trail for ISO 27001, Essential Eight or an external auditor.

Skip some or all of it when:

  • It’s a standard change. Password resets and group memberships are pre-approved, need a ticket at most, and no Git.
  • You’re only looking. Checking logs and troubleshooting change nothing, so there’s nothing to version.
  • It’s a lab or a tiny shop. One admin and ten users don’t need pull requests; they need backups.

The password policy in this infrastructure as code example sits firmly in the first group. It touches every account in the domain, and getting it wrong locks people out. If you can’t justify the process for that, the process isn’t the problem.

What this means for your career

This isn’t only for Windows admins. Network engineers do the same loop with Palo Alto rules written in Ansible or Terraform, reviewed in a pull request and pushed through Panorama. Cloud engineers do it with Azure resources in Terraform or Bicep. The tools change; the ticket, branch, review and merge don’t.

Here’s how it tends to read in a position description:

  • Manage infrastructure and network changes using infrastructure as code and Git version control.
  • Follow ITIL change management, tracking changes in Jira and seeking CAB approval where required.
  • Promote changes through Dev, Test and Production environments using CI/CD pipelines.
  • Peer review changes via pull requests.
  • Experience with Ansible, Terraform, PowerShell DSC, Bitbucket, GitHub or Azure DevOps.

If you see “Git” and “infrastructure as code” in the same ad, they work this way, or they want to and are hoping you’ll set it up for them. Both are opportunities.

The fastest way to get credible is to build one infrastructure as code example in a home lab, using the free plans. A Windows Server evaluation VM, a free Jira and Bitbucket, and SourceTree are all you need. Then you can say “here’s my repo and the ticket history” in an interview, instead of “I’ve heard of it”.

When an interviewer asks how you’d manage branches, the safe modern answer is: main matches production, and every change gets a short-lived branch named after its ticket. Say that with a real infrastructure as code example behind you and you’ll sound like you’ve done it, because you have.

The bottom line

Infrastructure as code isn’t a scripting skill. It’s a way of working, where every change is a ticket, a branch, a reviewed difference and a merge. AI can write the script faster than you can, but it can’t own the change, test it in Dev, or explain it to an auditor.

Our infrastructure as code example changed one number, from 14 to 15. Along the way, it caught a policy that would have silently reverted, a Windows limit nobody mentioned, and a file Git couldn’t read. That’s the argument for the process in a single, very small change.

So pick a boring change in your own lab and run it through the full loop. Raise the ticket, make the branch, commit, push, review, merge, deploy and close. Your first infrastructure as code example will feel slow and slightly ridiculous. By the third, you’ll wonder how you ever trusted yourself in GPMC on a Friday afternoon.

And if anyone complains that one extra character is too much to remember, tell them what every good infrastructure as code example teaches: length matters, but process matters more.

Sources