ansible: Set core pattern on LXD hosts and CI nodes
authorKienan Stewart <kstewart@efficios.com>
Thu, 25 Jul 2024 19:30:02 +0000 (15:30 -0400)
committerKienan Stewart <kstewart@efficios.com>
Thu, 25 Jul 2024 19:30:02 +0000 (15:30 -0400)
Change-Id: I7633740ff2122b88ddfcb52a373e6186f06722fa
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
automation/ansible/roles/common-node/tasks/main.yml
automation/ansible/roles/lxd/defaults/main.yml
automation/ansible/roles/lxd/tasks/main.yml

index 0fddb5af5988dc8dbb5731f2f6c49e2be49a1baa..c55884da752f52c1dfed78e18a132d399f2646ab 100644 (file)
@@ -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']
index d5dcf0513bd57df46f0ea5b8476efcfecd6b2360..bccf3fe0a4df726a1a0f7e922415b003108fecd9 100644 (file)
@@ -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'
index c6a58b5e41902f447919f1bdec665d99ad835c73..47e3a6c34e72893ab74182685933d9d50bda1250 100644 (file)
@@ -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
This page took 0.025566 seconds and 4 git commands to generate.