# Common Ansible Tasks

## Update or Install RHEL Packages

```bash
# To run this command do:
# ansible-playbook ~/ansible/playbooks/yum_update.yml -i ~/ansible/inventory -u adm_user --ask-pass --ask-become-pass
# And provide the password for the user

- hosts: all
  become: yes

  tasks:
  - name : Update multiple packages
    yum: name={{ item }} state=latest update_cache=true

    # Add packages to below list
    loop: [expat, openssh]
```

## Remove RHEL Packages

```yaml
# To run this command do:
# ansible-playbook ~/ansible/playbooks/yum_update.yml -i ~/ansible/inventory -u adm_user --ask-pass --ask-become-pass
# And provide the password for the user

- hosts: all
  become: yes

  tasks:
  - name : Update multiple packages
    yum: name={{ item }} state=absent update_cache=true

    # Add packages to below list
    loop: [expat, openssh]
```

## Update, Install or Remove RHEL packages using tags

```yaml
# To run this command do:
# ansible-playbook ~/ansible/playbooks/yum.yml -i ~/ansible/inventory -u adm_user --ask-pass --tags install
# And provide the password for the user & sudo password

- hosts: all
  become: yes

  tasks:
  - name: Update or install multiple packages
    tags:
      - install
      - update
    yum: name={{ item }} state=latest update_cache=true
    
  
# To run this command do:
# ansible-playbook ~/ansible/playbooks/yum_update.yml -i ~/ansible/inventory -u adm_user --ask-pass --tags remove
# And provide the password for the user & sudo password

    # ADD PAKCAGES YOU WANT TO UPDATE/INSTALL HERE SEPARATED BY ,
    # Example:
    # loop: [httpd, openssh] 

    loop: [httpd, openssh]

  - name: Remove multiple packages
    tags:
      - remove
      - uninstall
    yum: name={{ item }} state=absent update_cache=true

    # ADD PACKAGES YOU WANT TO REMOVE HERE SEPARATED BY ,
    # Example:
    # loop: [httpd, expat]
    
    loop: [httpd]

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.arkannis.net/devops/ansible/common-ansible-tasks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
