Install qemu-guest-agent with Ansible on Proxmox 7.2
I already have over 10 virtual machines in my home virtual environment. It is the number I find enough to start using some automation tools like Ansible. Installing Ansible on Ubuntu or CentOS systems is straightforward, just use regular apt or yum commands. With Ansible you can use commands or create scripts. First you should start with hosts definition file which by default is located at /etc/ansible/hosts.
[servers]
myhostname ansible_host=192.168.1.1
You can use different hosts file but then you need to point it while running commands. This one is default, so no need to do anything special here. Now going quickly to Proxmox’s qemu-guest-agent. What it is for? By using it, Proxmox knows what’s going on inside your VM, for example it will know IP addresses. Install package using apt or yum modules:
ansible all -m apt -a "name=qemu-guest-agent" --become -K -o
Go to each and every VM in Proxmox’s UI and enable QEMU Guest Agent. Then stop and start all VM. You will know that it works when there will be IP address shown on Summary page. Still you can check if service is running using Ansible:
ansible all -m shell -a "service qemu-guest-agent status | grep Active" --become -K -o -f 4