From: Kienan Stewart Date: Thu, 25 Jul 2024 19:30:02 +0000 (-0400) Subject: ansible: Set core pattern on LXD hosts and CI nodes X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=c426b44b233d1a84ede09b1fcd062cfe8315ac58;p=lttng-ci.git ansible: Set core pattern on LXD hosts and CI nodes Change-Id: I7633740ff2122b88ddfcb52a373e6186f06722fa Signed-off-by: Kienan Stewart --- diff --git a/automation/ansible/roles/common-node/tasks/main.yml b/automation/ansible/roles/common-node/tasks/main.yml index 0fddb5a..c55884d 100644 --- a/automation/ansible/roles/common-node/tasks/main.yml +++ b/automation/ansible/roles/common-node/tasks/main.yml @@ -8,6 +8,24 @@ - "{{ ansible_distribution }}.yml" - "{{ ansible_os_family }}.yml" +- when: ansible_virtualization_role == "host" or (ansible_virtualization_role == "guest" and ansible_virtualization_type == "kvm") + block: + - name: 'Set core pattern for reboot' + ansible.builtin.copy: + dest: '/etc/sysctl.d/10-core_pattern.conf' + owner: 'root' + group: 'root' + mode: '0644' + content: "kernel.core_pattern /tmp/core.%p\n" + - name: 'Check current core pattern' + ansible.builtin.command: + argv: ['cat', '/proc/sys/kernel/core_pattern'] + register: current_core_pattern + - name: 'Update current core pattern' + when: current_core_pattern.stdout|trim != common_node_core_pattern + ansible.builtin.command: + argv: ['sysctl', '-w', "kernel.core_pattern='{{common_node_core_pattern}}'"] + # Setup/install tasks. - ansible.builtin.include_tasks: setup-RedHat.yml when: ansible_os_family in ['RedHat', 'Rocky'] diff --git a/automation/ansible/roles/lxd/defaults/main.yml b/automation/ansible/roles/lxd/defaults/main.yml index d5dcf05..bccf3fe 100644 --- a/automation/ansible/roles/lxd/defaults/main.yml +++ b/automation/ansible/roles/lxd/defaults/main.yml @@ -10,3 +10,5 @@ lxd_container_defaults: # server: https://images.linuxcontainers.org alias: debian/bookworm/cloud/amd64/ci-node/lxd wait_for_container: true + +lxd_core_pattern: '/tmp/core.%p' diff --git a/automation/ansible/roles/lxd/tasks/main.yml b/automation/ansible/roles/lxd/tasks/main.yml index c6a58b5..47e3a6c 100644 --- a/automation/ansible/roles/lxd/tasks/main.yml +++ b/automation/ansible/roles/lxd/tasks/main.yml @@ -1,4 +1,25 @@ --- + +# The core pattern is used by the CI containers +- when: ansible_virtualization_role == "host" or (ansible_virtualization_role == "guest" and ansible_virtualization_type == "kvm") + block: + - name: 'Set core pattern for reboot' + ansible.builtin.copy: + dest: '/etc/sysctl.d/10-core_pattern.conf' + owner: 'root' + group: 'root' + mode: '0644' + content: "kernel.core_pattern /tmp/core.%p\n" + - name: 'Check current core pattern' + ansible.builtin.command: + argv: ['cat', '/proc/sys/kernel/core_pattern'] + register: current_core_pattern + - name: 'Update current core pattern' + when: current_core_pattern.stdout|trim != lxd_core_pattern + ansible.builtin.command: + argv: ['sysctl', '-w', "kernel.core_pattern='{{lxd_core_pattern}}'"] + + - name: Install LXD ansible.builtin.apt: name: lxd