From f13cbdcdbee359b41f1d0360e41dacbf3d8794b4 Mon Sep 17 00:00:00 2001 From: William Graef Date: Tue, 16 Jul 2024 16:51:48 -0400 Subject: [PATCH 1/2] add steps to install podman to ol --- ol/create_instance.yml | 4 ++++ ol/default_vars.yml | 4 +++- ol/provision_podman.yml | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 ol/provision_podman.yml diff --git a/ol/create_instance.yml b/ol/create_instance.yml index 72d626b..e81d6f5 100644 --- a/ol/create_instance.yml +++ b/ol/create_instance.yml @@ -299,6 +299,10 @@ ansible.builtin.import_playbook: provision_kvm.yml when: use_kvm +- name: Provision Podman and Container Tools + ansible.builtin.import_playbook: provision_podman.yml + when: use_podman + - name: Print instances hosts: all become: true diff --git a/ol/default_vars.yml b/ol/default_vars.yml index c20bf73..0ff8254 100644 --- a/ol/default_vars.yml +++ b/ol/default_vars.yml @@ -34,4 +34,6 @@ vm_vcpus: 2 vm_ram_mb: 2048 vm_net: default vm_root_pass: -cleanup_tmp: no \ No newline at end of file +cleanup_tmp: no + +use_podman: false \ No newline at end of file diff --git a/ol/provision_podman.yml b/ol/provision_podman.yml new file mode 100644 index 0000000..c35616d --- /dev/null +++ b/ol/provision_podman.yml @@ -0,0 +1,32 @@ +--- +# Copyright (c) 2024 Oracle and/or its affiliates. +# This software is made available to you under the terms of the Universal Permissive License (UPL), Version 1.0. +# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl) +# See LICENSE.TXT for details. + +- name: Install Podman and Container Tools + hosts: server + vars_files: + - default_vars.yml + become: true + + tasks: + + - name: Install Oracle Linux 8 container tools packages + ansible.builtin.dnf: + name: + - "@container-tools:ol8" + - conntrack + - curl + state: present + when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8' + + - name: Install Oracle Linux 9 container tools packages + ansible.builtin.dnf: + name: + - podman + - podman-docker + - conntrack + - curl + state: present + when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '9' From 554e3e2b234bfc78afc7d2aad305d40a59f45f24 Mon Sep 17 00:00:00 2001 From: William Graef Date: Tue, 16 Jul 2024 19:38:19 -0400 Subject: [PATCH 2/2] add playbook to update all rpms for ol --- ol/create_instance.yml | 4 ++++ ol/default_vars.yml | 1 + ol/update_all_rpms.yml | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 ol/update_all_rpms.yml diff --git a/ol/create_instance.yml b/ol/create_instance.yml index e81d6f5..a79358d 100644 --- a/ol/create_instance.yml +++ b/ol/create_instance.yml @@ -295,6 +295,10 @@ - name: Configure instance ansible.builtin.include_tasks: "host_setup.yml" +- name: Update all rpm packages + ansible.builtin.import_playbook: update_all_rpms.yml + when: update_all + - name: Provision KVM server ansible.builtin.import_playbook: provision_kvm.yml when: use_kvm diff --git a/ol/default_vars.yml b/ol/default_vars.yml index 0ff8254..1a2cebf 100644 --- a/ol/default_vars.yml +++ b/ol/default_vars.yml @@ -36,4 +36,5 @@ vm_net: default vm_root_pass: cleanup_tmp: no +update_all: false use_podman: false \ No newline at end of file diff --git a/ol/update_all_rpms.yml b/ol/update_all_rpms.yml new file mode 100644 index 0000000..d83e466 --- /dev/null +++ b/ol/update_all_rpms.yml @@ -0,0 +1,37 @@ +--- +# Copyright (c) 2024 Oracle and/or its affiliates. +# This software is made available to you under the terms of the Universal Permissive License (UPL), Version 1.0. +# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl) +# See LICENSE.TXT for details. + +- name: Install latest Oracle Linux packages + hosts: server + vars_files: + - default_vars.yml + become: true + + tasks: + + - name: Update all Oracle Linux packages + ansible.builtin.dnf: + name: "*" + state: latest + update_only: true + when: ansible_distribution == 'OracleLinux' + + - name: Check if a reboot is required + ansible.builtin.command: /usr/bin/needs-restarting -r + register: reboot_required + ignore_errors: true + changed_when: false + failed_when: reboot_required.rc == 2 + when: ansible_distribution == 'OracleLinux' + + - name: Print reboot is required + ansible.builtin.debug: + var: reboot_required + when: debug_enabled + + - name: Reboot (if needed) to apply latest kernel and updates + ansible.builtin.reboot: + when: ansible_distribution == 'OracleLinux' and reboot_required.rc == 1