Lev Goncharov

Infrastructure simplifying engineer

Simple Engineer Notes

GPT 4 IaC

Date: 2025-02-12

I’ve made some practical experiments with GPT in the IaC context and gave a speech about that at the meetup and DevConf.

video: www.youtube.com/watch?v=OMOVEMChr8A

I’m using chatGPT like solutions in real life for different purpose:

And I realized 🔥 it works well. But what’s about the IaC? is it usefull?

Limitations

There are many solutions available publicly:

However, I’ve decided to limit myself to Copilot because it integrates smoothly with VSCode and is allowed for use. The main limitation is that only public data is allowed.

Copilot 4 IaC: use cases

Let’s take a look into real life examples and try to make some conclusions

@ work: Documentations & presentations

Goal: Fluent, easy-to-read texts without mistakes.

Pros:

Cons:

Conclusion: 🔥 it works well.

@ work: create ansible lookup plugin

Goal: Transform the script get-latest-version.py to an Ansible lookup plugin. The purpose of the script was to:

Pros:

Cons:

Conclusion: ✅ ok to use for well known domain area.

@ work: generate documentation

Goal: Avoid boring tasks.

Pros:

Cons:

Conclusion: ✅ it works well.

@ work: explain jinja2 expressions

Goal: Understand written templates.

Pros:

Cons:

Conclusion: ✅ ok to use for well known domain area.

@ work: debug Ansible OTC dynamic inventory plugin

Goal: Get list of VMs from OTC in Ansible friendly format.

Pros:

Cons:

Conclusion: ⛔️ fail.

@ work: fix errors in Ansible roles

Goal: Fix errors during Java installation.

Pros:

Cons:

Conclusion: ❓ acceptable.

@ work: explain dependencies across the project

Goal: Understand infrastructure dependencies across the different parts.

Pros:

Cons:

Conclusion: ⛔️ doesn’t work.

Copilot 4 IaC: use cases summary

Let’s sum up:

Pros   Cons
Improves readability   Lacks context
Proposes syntax changes   Possible errors in suggestions
Generates documentation   Requires iterations
Step-by-step explanations   Limited knowledge
Generates configurations   Unable to identify root causes

In other words we can re-phrase it like

Conclusion: ❗️just imagine that there is very smart junior in your team.

Ideas

In case of IaC I’m following IDLC(SDLC for IaC) approach and I think it can be improved.

💡 Idea: PR reviewer

Make GPT as an optional reviewer in a repo:

  1. Get the diff.
  2. Load affected files as context.
  3. Provide prompt: “review it”.
  4. Suggest changes to PR.

Conclusion: ❗️ IDLC can be improved.

💡 Idea: Increase IaC test coverage

There is IaC testing pyramid concept. It describes how to test IaC. The problem is that it’s slow or just linting. The idea is that maybe it will be possible to add gpt to Static Analysis level. I.e. simulate an ansible or terraform execution without real execution. Maybe it will be faster or cheaper.

Conclusion: ❗️ IaC testing can be improved.

💡 Idea: AI agents in incident management

Conclusion: 💡 AI prepare overviews & possible actions, but humans decide

Copilot 4 learning

There is another way how to use it eg for learning to become better DevOps

Copilot 4 learning: debugging

Systems are too complicated nowadays days. Troubleshooting itself is explaining the discrepancy between what you expect and what you observe. There are some standard approaches to troubleshoot:

Conclusion: ✅ Can inspire new debugging directions


Copilot 4 learning: root-cause analysis

Learn deeply and be T-shaped

Nowadays systems might be complicated and over engineered. AI can mislead you, it’s your responsobility to navigate troubleshooting.

Conclusion: ⛔️ Doesn’t replace system understanding


Copilot 4 learning: feedback and reflection

There are 2 mindsets: expert & fixer. If you want to be better you should to dig into problems and find a root cause. You need to stay curious to learn new debug techniques and train your brain.

Conclusion: ⛔️ Without feedback and reflection, it’s waste of tokens


Copilot 4 learning: summary

Conclusion: 🔥 Helps you enter a new domain faster

GPT 4 IaC summary

The biggest question from my side is operational impact. Numbers without proofs look suspicious. I have kind of proof but it might be misleading, because maybe there is no direct correlation on AI, but the team maturity & expertise. Let me explain:

According to the plot the growing infrastructure is supported by the less amount of people. But technically it’s not only because of AI, it’s because of engineering practices like IDLC(IaC Development Life Cycle) and maturity of the project. And it was possible to use as foundation for AI.

🧠 Copilot 4 IaC is a skills multiplier, not a problem solver: