-
Notifications
You must be signed in to change notification settings - Fork 1
/
RHEL7x_Apply-OS-Updates-playbook.yml
42 lines (31 loc) · 1.46 KB
/
RHEL7x_Apply-OS-Updates-playbook.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
---
################################################################################
# description: Installs/applies OS updates and patches on CentOS7x
# usage: ansible-playbook RHEL7x_Apply-OS-Updates-playbook.yml --extra-vars 'HostOrGroup=YourServerOrGroupNameGoesHere'
# author: Ernest G. Wilson II <[email protected]> (https://github.com/ernestgwilsonii)
# license: MIT
################################################################################
# Ansible Playbook options
# REF: http://docs.ansible.com/ansible/playbooks.html
#####################################################
- name: Apply OS updates and patches on RHEL7x
hosts: "{{ HostOrGroup|default ('FATAL ERROR --> HostOrGroup NOT SET! You must specify either a Host or a Group name!') }}"
serial: "100%"
gather_facts: False
tasks:
# Install yum packages
# REF: http://docs.ansible.com/ansible/yum_module.html
######################################################
- name: Update / upgrade all existing installed packages
yum:
name=*
state=latest
- name: Install yum-utils if that package is not already present or update existing if needed
yum:
name=yum-utils
state=latest
# Execute command(s)
# REF: http://docs.ansible.com/ansible/command_module.html
##########################################################
- name: Remove old kernels from the OS keeping only the last most recent two
command: /usr/bin/package-cleanup --oldkernels --count=2 -y