Here is an example Ansible playbook to remove a package using the yum package manager:

yaml

---

- name: Remove a package using yum

  hosts: your_host

  become: yes

 

  vars:

    package_name: your_package_name

 

  tasks:

    - name: Remove the package

      yum:

        name: "{{ package_name }}"

        state: absent

In this playbook, we define the package_name variable to specify the name of the package we want to remove. The become: yes parameter is used to escalate the privilege level to root, so we can execute the yum command to remove the package.

The yum module is used to manage packages with yum package manager. We pass the name parameter with the value of the package_name variable to specify which package to remove. We set the state parameter to absent to indicate that we want to remove the package.

Save this playbook as a YAML file (e.g. yum_remove.yml) and run it using the ansible-playbook command:

ansible-playbook yum_remove.yml

Replace your_host with the name of the host or group of hosts you want to run this playbook on.

أحدث أقدم