Terraform and Ansible Automate First Boot

I am using Terraform and Ansible. With Azure VMs. I am just using ansible without AWX/Tower and hoping to not use those as it’s not a very big environment. For the ansible inventory we are using Azure dynamic inventory plugin for ansible.

What I want to do is have terraform provision the azure vms, then somehow copy our ansible vault password to the vm (securely), install ansible, clone our ansible repo, and have the server do an ansible-pull on the first boot so it gets it’s initial configuration automatically.

Does anyone have any recommendations on how to do this?

Entitle the VM to get the relevant secret from Azure Key Vault and combine that with (assuming these are Linux VMs): Install Ansible - cloud-init 25.1.2 documentation

Thanks @wayt . Yes. Linux VMs. This is exactly what I was looking for.

Can you clarify a bit more about the process of “Entitle the VM to get the relevant secret from Azure Key Vault”. Are there any instructions online for that?

You marked it as a solution without knowing what he was telling you to do…?

Assign a managed identity to the VM and grant that identity/ VM access to the key vault.

1 Like