For use with eg CentOS.
Assumes you have a file /etc/ansible/hosts with groups and members already configured.
A properly formatted .yml-file can be found at the end of the article.
yum.update.yml
---
- hosts: centos-cli
gather_facts: no
tasks:
# Alternative 1
# - name: upgrade all packages
# yum:
# name'*'
# state=latest
# exclude=kmod*,nvidia*
#
# Alternative 2
# - name: upgrade some packages
# yum: name='tzdata' state=latest; name='firefox' state=latest
#
# On error pending transactions clean up remote host with
# yum-complete-transaction --cleanup-only
#
# Alternative 3
- name: upgrade some packages v2
yum: name={{ item }} state=latest
with_items:
- tzdata*
- firefox
...