I wanted to do an uninstallation of OMS agent in our Linux machines. Unfortunately, we do have different OMS agent versions assigned to each machine. I hard coded the version from my Ansible script
command: sudo {{ file_path }}/omsagent-1.13.9-0.universal.x64.sh —-purge
It only works for machine with that same OMS agent version else, it will fail.
I tried adding wildcard syntax, but it is getting an error stating that command not found
stderr: “sudo :/home/filename/omsagent-* : command not found
if I changed my previous command to
command: sudo {{file_path}}/omsagent-*.universal.x64.sh —-purge
Since I do not have this specific agent in place, I can't provide a full tested working example, but some some guidance.
According the package documentation and All bundle operations, the bundle has an option for
which should provide the installed version. Furthermore any installed agent has an directory with service control script
and probably others, like
scxadmin --version
. By executing one or the other it should be possible to gather the correct installed version of the agent.Please take note that instead of using
sudo
within the command, you should usebecome
. Since it is a version reporting task only, you should also usechanged_when
andcheck_mode
.After the correct version is gathered you use it like
Is there any reason why the option
--upgrade
or--force
can`t be used?You may also have a look into How to troubleshoot issues with the Log Analytics agent for Linux, there is a standalone versionless purge script available.