Common Ansible Tasks

Update or Install RHEL Packages

# 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

# 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

Last updated