Skip to content

Commit 554e3e2

Browse files
author
William Graef
committed
add playbook to update all rpms for ol
1 parent f13cbdc commit 554e3e2

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

ol/create_instance.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@
295295
- name: Configure instance
296296
ansible.builtin.include_tasks: "host_setup.yml"
297297

298+
- name: Update all rpm packages
299+
ansible.builtin.import_playbook: update_all_rpms.yml
300+
when: update_all
301+
298302
- name: Provision KVM server
299303
ansible.builtin.import_playbook: provision_kvm.yml
300304
when: use_kvm

ol/default_vars.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ vm_net: default
3636
vm_root_pass:
3737
cleanup_tmp: no
3838

39+
update_all: false
3940
use_podman: false

ol/update_all_rpms.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
# Copyright (c) 2024 Oracle and/or its affiliates.
3+
# This software is made available to you under the terms of the Universal Permissive License (UPL), Version 1.0.
4+
# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl)
5+
# See LICENSE.TXT for details.
6+
7+
- name: Install latest Oracle Linux packages
8+
hosts: server
9+
vars_files:
10+
- default_vars.yml
11+
become: true
12+
13+
tasks:
14+
15+
- name: Update all Oracle Linux packages
16+
ansible.builtin.dnf:
17+
name: "*"
18+
state: latest
19+
update_only: true
20+
when: ansible_distribution == 'OracleLinux'
21+
22+
- name: Check if a reboot is required
23+
ansible.builtin.command: /usr/bin/needs-restarting -r
24+
register: reboot_required
25+
ignore_errors: true
26+
changed_when: false
27+
failed_when: reboot_required.rc == 2
28+
when: ansible_distribution == 'OracleLinux'
29+
30+
- name: Print reboot is required
31+
ansible.builtin.debug:
32+
var: reboot_required
33+
when: debug_enabled
34+
35+
- name: Reboot (if needed) to apply latest kernel and updates
36+
ansible.builtin.reboot:
37+
when: ansible_distribution == 'OracleLinux' and reboot_required.rc == 1

0 commit comments

Comments
 (0)