~ / archivo / stackoverflow / 55418667
Unable to uninstall package using deb module in Ansible
-
Today I'm experiencing a problem using ansible and trying to uninstall a debian package. The package does not come from a repository but instead a .deb file directly, so, in Ansible I've defined the installation task:
- name: install nomachine apt: deb: /root/{{ nomachine_package }}Which actually works, the package gets installed in the S.O.
But, when it's time to remove it:
- name: uninstall nomachine apt: deb: nomachine-enterprise-terminal-server state: absentThe horror:
fatal: [SERVER]: FAILED! => {"changed": false, "failed": true, "msg": "deb only supports state=present"}I'm not a developer but take a look on
apt.pyand it seems that the uninstall process is only available for packages installed via repository? (it seems to validate against cache of apt).So, as workaround for this uninstall process I'm doing:
- name: uninstall nomachine shell: dpkg -r nomachine-enterprise-terminal-serverI'm using ansible 2.3.0.0
Maybe I'm not using the tool properly or the functionality is not available.
Thanks for any help you can provide on this.
H.
EDIT: I think I'm doing it ok because following the example of ansible:
- name: Remove "foo" package apt: name: foo state: absentAnd for those who are wondering why "- name" isn't defined it's because the task is a handler.
-
I'm a silly boy. after taking a look on the documentation as suggested in my recently "newbug" on github the syntax varies for uninstalling packages, small difference in usage for the same module (and In the question I already answered myself):
# WRONG - name: uninstall nomachine apt: deb: nomachine-enterprise-terminal-server state: absent # RIGHT - name: Remove "foo" package apt: name: foo state: absentdeb --> name !! Just for uninstalling... for installing packages it is still "deb".
Facepalm today, experience tomorrow.