r/ansible • u/masterofrants • May 15 '26
windows My experience learning Ansible with Claude and need suggestions going fwd!
Hi, I am a network engineer and new to Ansible.
I installed WSL 2 on Windows and tried some things. What happened is I soon ran into a lot of issues, like some Python issues and then some Azure environment issues, because I was trying to integrate secrets management with Azure Key Vault. I am not sure if AI is teaching me good practices.
The next thing I am trying to get set up is Semaphore because I think that's one of the ways to actually learn production practices.
I am just putting my workflow here, what I did so far, but I want to know if this is a good idea or maybe I'm going down a wrong path and learning bad practices.
Verified Ansible was installed via apt on Ubuntu WSL2 — no /etc/ansible/ created, used project-based ansible.cfg in ~/ansible/ instead
Reinstalled Az CLI natively in WSL (was running Windows Az CLI via PATH passthrough) and authenticated with az login --use-device-code
Created Service Principal sp-ansible-akmlabs in Entra ID, assigned Key Vault Secrets Officer role on the vault, stored credentials in ~/ansible/.env
Created Azure Key Vault akmlab-az-kv in portal with RBAC mode enabled, stored a test secret via Az CLI
Created Python venv, installed azure.azcollection requirements plus hidden dependencies, installed ansible-core inside the venv so Ansible runs from venv Python
Wrote and tested playbook that authenticates as the SP and pulls the secret from Key Vault — confirmed hello-from-akmlabs returned successfully
Then ran into some crazy python issues which took 3 hrs to troubleshoot!
No /etc/ansible/ — modern apt install doesn't create it; used project-based ansible.cfg in ~/ansible/ instead
Az CLI using Windows Python — WSL was calling the Windows Az CLI via PATH passthrough; fixed by installing Az CLI natively in WSL via the Microsoft install script
Wrong collection module name (claude got these wrong) — used azure_keyvault_secret_info which doesn't exist; correct name is azure_rm_keyvaultsecret_info, found by listing the modules directory
Ubuntu blocked pip — PEP 668 prevents pip from modifying system Python; fixed by creating a venv and installing all packages there
Missing hidden dependencies — requirements.txt from the collection is incomplete; had to manually install msrestazure and others not listed (known upstream issue GitHub #1463) - This then took 3 hrs lol!
Venv packages being ignored — interpreter_python in ansible.cfg controls target host Python, not Ansible's own process; fixed by installing ansible-core inside the venv so Ansible itself runs from venv Python
Wrong env var names — azure.azcollection uses AZURE_SECRET and AZURE_TENANT, not AZURE_CLIENT_SECRET and AZURE_TENANT_ID; silent auth failure until corrected
Wrong secret field name — output dict uses .secret not .value; dumped raw output with var: kv_output to find the correct field name.
Feeling like all this was a waste of time and I did not learn anything that is done in a real production environment. If somebody can make a quick list of things that I could look into and actually learn something, it would be nice. Overall I think it's still fine. I did something I guess.