From cfbb7f884e28f55400023f60ab879d850b64d719 Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Wed, 26 Feb 2025 17:55:38 +0000 Subject: [PATCH] ci: Add playbook to configure container host for image prep --- .gitignore | 1 + tests/image_prep/_container_host.yml | 5 ++++ .../roles/container_host/handlers/main.yml | 6 +++++ .../roles/container_host/tasks/main.yml | 27 +++++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 tests/image_prep/_container_host.yml create mode 100644 tests/image_prep/roles/container_host/handlers/main.yml create mode 100644 tests/image_prep/roles/container_host/tasks/main.yml diff --git a/.gitignore b/.gitignore index 43e46a19..b3710ea2 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ build/ dist/ extra/ tests/ansible/.*.pid +tests/image_prep/logs docs/_build/ htmlcov/ *.egg-info diff --git a/tests/image_prep/_container_host.yml b/tests/image_prep/_container_host.yml new file mode 100644 index 00000000..d3c2aca8 --- /dev/null +++ b/tests/image_prep/_container_host.yml @@ -0,0 +1,5 @@ +- name: Setup container host + hosts: localhost + become: true + roles: + - role: container_host diff --git a/tests/image_prep/roles/container_host/handlers/main.yml b/tests/image_prep/roles/container_host/handlers/main.yml new file mode 100644 index 00000000..60c76cee --- /dev/null +++ b/tests/image_prep/roles/container_host/handlers/main.yml @@ -0,0 +1,6 @@ +- name: Update GRUB + command: update-grub + changed_when: true + +- name: Reboot + reboot: diff --git a/tests/image_prep/roles/container_host/tasks/main.yml b/tests/image_prep/roles/container_host/tasks/main.yml new file mode 100644 index 00000000..c7736790 --- /dev/null +++ b/tests/image_prep/roles/container_host/tasks/main.yml @@ -0,0 +1,27 @@ +# > If running `docker run --rm -it centos:centos6.7 bash` immediately exits +# > with status code 139, check to see if your system has disabled vsyscall: +# > ... +# > If you do not see a vsyscall mapping, and you need to run a CentOS 6 +# > container, try adding vsyscall=emulated to the kernel options. +# > -- https://hub.docker.com/_/centos + +- name: Check vsyscall enabled + command: + cmd: grep -c vsyscall /proc/self/maps + register: grep_self_maps_result + changed_when: false + check_mode: false + failed_when: + # 0 -> match, 1 -> no match, 2 -> error + - grep_self_maps_result.rc not in [0, 1] + +- name: Enable vsyscall + lineinfile: + path: /etc/default/grub + regexp: '^GRUB_CMDLINE_LINUX_DEFAULT.+' + line: GRUB_CMDLINE_LINUX_DEFAULT="quiet vsyscall=emulate" + when: + - grep_self_maps_result.rc != 0 + notify: + - Update GRUB + - Reboot