# Ansible playbook to remove a rpm package

**URL:** <https://forum.ansible.com/t/ansible-playbook-to-remove-a-rpm-package/35043>\
**Category:** Ansible Developer\
**Created:** [April 23, 2021, 2:18pm UTC](https://forum.ansible.com/t/ansible-playbook-to-remove-a-rpm-package/35043 "2021-04-23T14:18:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Swordfish\_Binary](https://avatars.discourse-cdn.com/v4/letter/s/8dc957/32.png) [@Swordfish\_Binary](https://forum.ansible.com/u/Swordfish_Binary)\
**Post date:** [April 23, 2021, 2:18pm UTC](https://forum.ansible.com/t/ansible-playbook-to-remove-a-rpm-package/35043/1 "2021-04-23T14:18:31Z")

</div>

I am trying to remove a rpm package using ansible playbook. I tried to do as shown below but its not working. Any idea how this rpm package can be removed. Note: This rpm package is not present in yum

```auto
 ---
- hosts: all
  gather_facts: false
  become: true
  tasks:
    - name: stop rscd server
      systemd:
        state: stopped
        name: rscd
      register: output
      notify:
        - remove rscd

  handlers:
    - name: remove rscd
      shell: rpm -e '{{ item }}'

```

The above playbook when I run it runs but it just stops the process alone but never removes the package. Any idea what I am doing wrong?

---

<div class="post-metadata">

**Author:** ![dimndskier](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dimndskier/32/773_2.png) [@dimndskier](https://forum.ansible.com/u/dimndskier)\
**Post date:** [April 23, 2021, 6:27pm UTC](https://forum.ansible.com/t/ansible-playbook-to-remove-a-rpm-package/35043/2 "2021-04-23T18:27:20Z")

</div>

Does the package have any dependencies that are also required by other packages?

Have you attempted and **rpm -e rscd** from the cli on the machine in question. I always prototype my scripts and programs on the cli to ensure their is a strong potential for a successful execution of whatever I am doing.

---

<div class="post-metadata">

**Author:** ![Frank\_Dias](https://avatars.discourse-cdn.com/v4/letter/f/eada6e/32.png) [@Frank\_Dias](https://forum.ansible.com/u/Frank_Dias)\
**Post date:** [April 23, 2021, 6:34pm UTC](https://forum.ansible.com/t/ansible-playbook-to-remove-a-rpm-package/35043/3 "2021-04-23T18:34:35Z")

</div>

Your handler is references an item but you do not list the item
