aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/testbed-setup/ansible/roles/kernel
diff options
context:
space:
mode:
authorpmikus <pmikus@cisco.com>2021-02-15 16:16:31 +0000
committerPeter Mikus <pmikus@cisco.com>2021-02-19 11:57:30 +0000
commit7b93e96740997dab4383140a639b055e074f63c1 (patch)
tree8d54d10e65af9a6c58546fd3b36aed9cb8d174af /resources/tools/testbed-setup/ansible/roles/kernel
parentecfe59f83a49e0dda9cead06b81339e4ea545053 (diff)
Infra: Ansible Ubuntu Focal
Signed-off-by: pmikus <pmikus@cisco.com> Change-Id: I6558938fe4bbdfb5add7a361adb4a12da6b0a6dc
Diffstat (limited to 'resources/tools/testbed-setup/ansible/roles/kernel')
-rw-r--r--resources/tools/testbed-setup/ansible/roles/kernel/defaults/main.yaml39
-rw-r--r--resources/tools/testbed-setup/ansible/roles/kernel/handlers/main.yaml2
-rw-r--r--resources/tools/testbed-setup/ansible/roles/kernel/tasks/main.yaml7
-rw-r--r--resources/tools/testbed-setup/ansible/roles/kernel/tasks/ubuntu_bionic.yaml31
-rw-r--r--resources/tools/testbed-setup/ansible/roles/kernel/tasks/ubuntu_focal.yaml51
5 files changed, 102 insertions, 28 deletions
diff --git a/resources/tools/testbed-setup/ansible/roles/kernel/defaults/main.yaml b/resources/tools/testbed-setup/ansible/roles/kernel/defaults/main.yaml
index d84a163487..b9b4253622 100644
--- a/resources/tools/testbed-setup/ansible/roles/kernel/defaults/main.yaml
+++ b/resources/tools/testbed-setup/ansible/roles/kernel/defaults/main.yaml
@@ -2,27 +2,42 @@
# file: roles/kernel/defaults/main.yaml
# Kernel version to install (Default to any version).
-kernel_version: "{{ kernel_version_by_distro[ansible_distribution | lower] | join(' ') }}"
+kernel_version: "{{ kernel_version_by_distro[ansible_distribution|lower][ansible_distribution_release] | join(' ') }}"
kernel_version_by_distro:
ubuntu:
- - "4.15.0-72"
+ bionic:
+ - "4.15.0-72"
+ focal:
+ - "5.4.0-65"
-kernel_packages: "{{ kernel_packages_by_distro[ansible_distribution | lower] | flatten(levels=1) }}"
+kernel_packages: "{{ kernel_packages_by_distro[ansible_distribution|lower][ansible_distribution_release] | flatten(levels=1) }}"
kernel_packages_by_distro:
ubuntu:
- - "linux-image"
- - "linux-headers"
- - "linux-modules"
- - "linux-modules-extra"
- - "linux-tools"
+ bionic:
+ - "linux-image"
+ - "linux-headers"
+ - "linux-modules"
+ - "linux-modules-extra"
+ - "linux-tools"
+ focal:
+ - "linux-image"
+ - "linux-headers"
+ - "linux-modules"
+ - "linux-modules-extra"
+ - "linux-tools"
# Packages to remove in relation to kernel upgrade.
-absent_packages: "{{ absent_packages_by_distro[ansible_distribution | lower] | flatten(levels=1) }}"
+absent_packages: "{{ absent_packages_by_distro[ansible_distribution|lower][ansible_distribution_release] | flatten(levels=1) }}"
absent_packages_by_distro:
ubuntu:
- - "amd64-microcode"
- - "intel-microcode"
- - "iucode-tool"
+ bionic:
+ - "amd64-microcode"
+ - "intel-microcode"
+ - "iucode-tool"
+ focal:
+ - "amd64-microcode"
+ - "intel-microcode"
+ - "iucode-tool" \ No newline at end of file
diff --git a/resources/tools/testbed-setup/ansible/roles/kernel/handlers/main.yaml b/resources/tools/testbed-setup/ansible/roles/kernel/handlers/main.yaml
index 3d30a0973c..963fd71756 100644
--- a/resources/tools/testbed-setup/ansible/roles/kernel/handlers/main.yaml
+++ b/resources/tools/testbed-setup/ansible/roles/kernel/handlers/main.yaml
@@ -4,3 +4,5 @@
- name: Reboot Server
reboot:
reboot_timeout: 3600
+ tags:
+ - reboot-server \ No newline at end of file
diff --git a/resources/tools/testbed-setup/ansible/roles/kernel/tasks/main.yaml b/resources/tools/testbed-setup/ansible/roles/kernel/tasks/main.yaml
index 4c63c709a6..431e344fb8 100644
--- a/resources/tools/testbed-setup/ansible/roles/kernel/tasks/main.yaml
+++ b/resources/tools/testbed-setup/ansible/roles/kernel/tasks/main.yaml
@@ -1,8 +1,9 @@
---
# file: roles/kernel/tasks/main.yaml
-- name: Kernel - Install distribution - release
- include_tasks: '{{ ansible_distribution|lower }}_{{ ansible_distribution_release }}.yaml'
- tags: install-kernel
+- name: Inst - Prerequisites
+ include_tasks: "{{ ansible_distribution|lower }}_{{ ansible_distribution_release }}.yaml"
+ tags:
+ - kernel-inst-prerequisites
- meta: flush_handlers
diff --git a/resources/tools/testbed-setup/ansible/roles/kernel/tasks/ubuntu_bionic.yaml b/resources/tools/testbed-setup/ansible/roles/kernel/tasks/ubuntu_bionic.yaml
index 3cb79352ee..349c853c11 100644
--- a/resources/tools/testbed-setup/ansible/roles/kernel/tasks/ubuntu_bionic.yaml
+++ b/resources/tools/testbed-setup/ansible/roles/kernel/tasks/ubuntu_bionic.yaml
@@ -1,33 +1,37 @@
---
# file: roles/kernel/tasks/ubuntu_bionic.yaml
-- name: Kernel - Get Available Kernel Versions
+- name: Get Available Kernel Versions
command: "apt-cache showpkg linux-headers-*"
changed_when: false
register: apt_kernel_list
- tags: install-kernel
+ tags:
+ - kernel-inst
-- name: Kernel - Get installed packages with APT
+- name: Get installed packages with APT
command: "dpkg -l"
changed_when: false
register: apt_packages_list
- tags: install-kernel
+ tags:
+ - kernel-inst
-- name: Kernel - Set target APT kernel version
+- name: Set target APT kernel version
set_fact:
_kernel: "{{ apt_kernel_list | deb_kernel(
kernel_version, ansible_kernel) }}"
- tags: install-kernel
+ tags:
+ - kernel-inst
-- name: Kernel - Ensure Packages Versions
+- name: Ensure Packages Versions
apt:
name: "{{ apt_kernel_list | deb_kernel_pkg(
kernel_version, ansible_kernel, ansible_distribution,
ansible_architecture, item) }}"
loop: "{{ kernel_packages }}"
- tags: install-kernel
+ tags:
+ - kernel-inst
-- name: Kernel - Ensure Any Other Kernel Packages Are Removed
+- name: Ensure Any Other Kernel Packages Are Removed
apt:
name: "{{ apt_packages_list | deb_installed_kernel(
apt_kernel_list, kernel_version, ansible_kernel) }}"
@@ -35,12 +39,13 @@
purge: true
notify:
- "Reboot Server"
- tags: install-kernel
+ tags:
+ - kernel-inst
-- name: Kernel - Ensure Any Microcode Is Absent
+- name: Ensure Any Microcode Is Absent
apt:
name: "{{ absent_packages }}"
state: absent
purge: true
- tags: install-kernel
-
+ tags:
+ - kernel-inst \ No newline at end of file
diff --git a/resources/tools/testbed-setup/ansible/roles/kernel/tasks/ubuntu_focal.yaml b/resources/tools/testbed-setup/ansible/roles/kernel/tasks/ubuntu_focal.yaml
new file mode 100644
index 0000000000..9cbc4d4787
--- /dev/null
+++ b/resources/tools/testbed-setup/ansible/roles/kernel/tasks/ubuntu_focal.yaml
@@ -0,0 +1,51 @@
+---
+# file: roles/kernel/tasks/ubuntu_focal.yaml
+
+- name: Get Available Kernel Versions
+ command: "apt-cache showpkg linux-headers-*"
+ changed_when: false
+ register: apt_kernel_list
+ tags:
+ - kernel-inst
+
+- name: Get installed packages with APT
+ command: "dpkg -l"
+ changed_when: false
+ register: apt_packages_list
+ tags:
+ - kernel-inst
+
+- name: Set target APT kernel version
+ set_fact:
+ _kernel: "{{ apt_kernel_list | deb_kernel(
+ kernel_version, ansible_kernel) }}"
+ tags:
+ - kernel-inst
+
+- name: Ensure Packages Versions
+ apt:
+ name: "{{ apt_kernel_list | deb_kernel_pkg(
+ kernel_version, ansible_kernel, ansible_distribution,
+ ansible_architecture, item) }}"
+ loop: "{{ kernel_packages }}"
+ tags:
+ - kernel-inst
+
+- name: Ensure Any Other Kernel Packages Are Removed
+ apt:
+ name: "{{ apt_packages_list | deb_installed_kernel(
+ apt_kernel_list, kernel_version, ansible_kernel) }}"
+ state: absent
+ purge: true
+ notify:
+ - "Reboot Server"
+ tags:
+ - kernel-inst
+
+- name: Ensure Any Microcode Is Absent
+ apt:
+ name: "{{ absent_packages }}"
+ state: absent
+ purge: true
+ tags:
+ - kernel-inst \ No newline at end of file