Azure Linux Agent Install

Started by markes20754, May 01, 2024, 11:39:40 PM

Previous topic - Next topic
I've been able to find some references in posts but I haven't found any clear instructions on how to install the Azure Linux Agent onto an uploaded OPNSense HyperV image.  Has anyone been able to successfully install and configure the agent? If so, could you share your steps?

Thanks in advance!

According to their documentation https://learn.microsoft.com/en-us/azure/virtual-machines/extensions/agent-linux, not much support for freeBSD:
Other supported systems:

    The Agent works on more systems than those listed in the documentation. However, we do not test or provide support for distros that are not on the endorsed list. In particular, FreeBSD is not endorsed. The customer can try FreeBSD 8 and if they run into problems they can open an issue in our GitHub repository and we may be able to help.

More importantly:
The Linux agent depends on these system packages to function properly:

    Python 2.6+
    OpenSSL 1.0+
    OpenSSH 5.3+
    File system utilities: sfdisk, fdisk, mkfs, parted
    Password tools: chpasswd, sudo
    Text processing tools: sed, grep
    Network tools: ip-route
    Kernel support for mounting UDF file systems

Some of these dependencies will not be met in a freeBSD system by default.

UPDATE: After posting this I was able to piece together some other articles and get this working. These are just my quick notes so someone smarter than me should be able to polish this up.

#Disable the default swap file - Azure agent mounts a temp volume presented to the VM and creates its own swap file
swapoff /dev/gpt/swapfs

#Install the agent dependencies
pkg upgrade
pkg install -y sudo bash git

# check on the python path -- at the time of this post it's 3.9 and create the link for python
ls /usr/local/bin/python*
ln -s /usr/local/bin/python3.9 /usr/local/bin/python

# clone the agent
git clone https://github.com/Azure/WALinuxAgent.git
cd WALinuxAgent

#check the current stable build -- at the time of this post it's v2.10.0.8
git checkout v2.10.0.8

#install the agent and register it as a service
python setup.py install --register-service

#create links for the agent
ln -sf /usr/local/sbin/waagent /usr/sbin/waagent
ln -sf /usr/local/sbin/waagent2.0 /usr/sbin/waagent2.0

#Setup the agent service scripts
echo '#! /bin/sh' >> /usr/local/etc/rc.d/waagent.sh
echo '/usr/local/sbin/waagent --daemon' >> /usr/local/etc/rc.d/waagent.sh
chmod +x /usr/local/etc/rc.d/waagent.sh
echo 'waagent_enable="YES"' >> /etc/rc.conf.local

#Change the agent built swap from 16gb default to 6gb -- the temp volume in my VM was only 8GB
sed -i .bak 's/ResourceDisk.SwapSizeMB=16384/ResourceDisk.SwapSizeMB=6144/g' /etc/waagent.conf

#A quick version check. If this doesn't return the version something went wrong
waagent -version

service waagent status
service waagent start
service waagent status






I have a problem with waagent on my opnsense custom image. Current waagent reports a failure to mount a cdrom:

In the Azure Portal:
OS Provisioning failed for VM 'vm-fw3' due to an internal error: [ProtocolError] [CopyOvfEnv] Error mounting dvd: [OSUtilError] Failed to mount dvd device Inner error: [['mount', '-o', 'ro', '-t', 'udf,iso9660,vfat', '/dev/cd0', '/mnt/cdrom/secure']] returned 1: stdout: stderr: mount_udf: /dev/cd0: Device not configured .

In waagent.log:

2025-03-01T20:39:54.495854Z ERROR Daemon Daemon Event: name=WALinuxAgent, op=Provision, message=Provisioning failed: [ProtocolError] [CopyOvfEnv] Error mounting dvd: [OSUtilError]
 Failed to mount dvd device
Inner error: [['mount', '-o', 'ro', '-t', 'udf,iso9660,vfat', '/dev/cd0', '/mnt/cdrom/secure']] returned 1:
 stdout:

stderr: mount_udf: /dev/cd0: Device not configured

Anyone?


Thank you, this is much easier then installation of waagent from repo.

Nevertheless, I experience the same behaviour with the package or the latest version from repo. Meanwhile i found out that the static routes to Azure infrastructure was not created by waagent and after setting them manually communication with Hypervisor to mount the virtual cdrom at initial provisioning worked. Some other tweaks where necessary like copying rsa key files from /conf/sshd to /usr/local/etc/ssh otherwise waagent stopped working and tried again 15 seconds later and then the virtual cdrom is not available anymore which results to a problem with the vm in the Azure Portal. Uff.

To summarise, we now have an acceptable working setup, but it doesn't feel very good and clean.