I've an EC2 instance create using Vagrant and provisioned with Ansible.
I've this task that install 2 package using apt
.
---
- name: Install GIT & TIG
action: apt pkg={{ item }} state=installed
with_items:
- git
- tig
I want now delete/remove tig
from my instance. I've removed it from my playbook and I've run vagrant provision
but the package is still there.
How can I do this ?
Ansible cannot automatically remove packages when you remove them from your playbook. Ansible is stateless. This means it will not keep track of what it does and therefore does not know what it did in recent runs or if your playbook/role has been modified. Ansible will only do what you explicitly describe in the playbook/role. So you have to write a task to remove it.
You can easily do this with the apt module.
- name: Remove TIG
apt:
pkg: tig
state: absent
become: true