From f9ebd45c749647c0e8fdd55ea58d0fb0b6612d08 Mon Sep 17 00:00:00 2001
From: Max Gautier <mg@max.gautier.name>
Date: Thu, 5 Sep 2024 07:24:49 +0000
Subject: [PATCH] boostrap-os: use import_tasks instead of symlinks (#11508)

Working symlinks are dependant on git configuration (when using the playbook as
a git repository, which is common), precisely `git config
core.symlinks`.

While this is enabled by default, some company policies will disable it.

Instead, use import_tasks which should avoid that class of bugs.
---
 roles/bootstrap-os/tasks/debian.yml           | 20 -----------------
 roles/bootstrap-os/tasks/openEuler.yml        |  4 +++-
 roles/bootstrap-os/tasks/opensuse-leap.yml    |  4 +++-
 .../tasks/opensuse-tumbleweed.yml             |  4 +++-
 roles/bootstrap-os/tasks/ubuntu.yml           | 22 ++++++++++++++++++-
 5 files changed, 30 insertions(+), 24 deletions(-)
 mode change 120000 => 100644 roles/bootstrap-os/tasks/openEuler.yml
 mode change 120000 => 100644 roles/bootstrap-os/tasks/opensuse-leap.yml
 mode change 120000 => 100644 roles/bootstrap-os/tasks/opensuse-tumbleweed.yml
 mode change 120000 => 100644 roles/bootstrap-os/tasks/ubuntu.yml

diff --git a/roles/bootstrap-os/tasks/debian.yml b/roles/bootstrap-os/tasks/debian.yml
index 9ede45f9b..9b18baa06 100644
--- a/roles/bootstrap-os/tasks/debian.yml
+++ b/roles/bootstrap-os/tasks/debian.yml
@@ -62,23 +62,3 @@
     - '"changed its" in bootstrap_update_apt_result.stdout'
     - '"value from" in bootstrap_update_apt_result.stdout'
   ignore_errors: true
-
-- name: Check unattended-upgrades file exist
-  stat:
-    path: /etc/apt/apt.conf.d/50unattended-upgrades
-  register: unattended_upgrades_file_stat
-  when:
-    - os_release_dict['ID'] == 'ubuntu'
-    - ubuntu_kernel_unattended_upgrades_disabled
-
-- name: Disable kernel unattended-upgrades
-  lineinfile:
-    path: "{{ unattended_upgrades_file_stat.stat.path }}"
-    insertafter: "Unattended-Upgrade::Package-Blacklist"
-    line: '"linux-";'
-    state: present
-  become: true
-  when:
-    - os_release_dict['ID'] == 'ubuntu'
-    - ubuntu_kernel_unattended_upgrades_disabled
-    - unattended_upgrades_file_stat.stat.exists
diff --git a/roles/bootstrap-os/tasks/openEuler.yml b/roles/bootstrap-os/tasks/openEuler.yml
deleted file mode 120000
index fa2c37f2a..000000000
--- a/roles/bootstrap-os/tasks/openEuler.yml
+++ /dev/null
@@ -1 +0,0 @@
-centos.yml
\ No newline at end of file
diff --git a/roles/bootstrap-os/tasks/openEuler.yml b/roles/bootstrap-os/tasks/openEuler.yml
new file mode 100644
index 000000000..42551339a
--- /dev/null
+++ b/roles/bootstrap-os/tasks/openEuler.yml
@@ -0,0 +1,3 @@
+---
+- name: Import Centos boostrap for openEuler
+  import_tasks: centos.yml
diff --git a/roles/bootstrap-os/tasks/opensuse-leap.yml b/roles/bootstrap-os/tasks/opensuse-leap.yml
deleted file mode 120000
index 389442aed..000000000
--- a/roles/bootstrap-os/tasks/opensuse-leap.yml
+++ /dev/null
@@ -1 +0,0 @@
-opensuse.yml
\ No newline at end of file
diff --git a/roles/bootstrap-os/tasks/opensuse-leap.yml b/roles/bootstrap-os/tasks/opensuse-leap.yml
new file mode 100644
index 000000000..233f84865
--- /dev/null
+++ b/roles/bootstrap-os/tasks/opensuse-leap.yml
@@ -0,0 +1,3 @@
+---
+- name: Import Opensuse bootstrap
+  import_tasks: opensuse.yml
diff --git a/roles/bootstrap-os/tasks/opensuse-tumbleweed.yml b/roles/bootstrap-os/tasks/opensuse-tumbleweed.yml
deleted file mode 120000
index 389442aed..000000000
--- a/roles/bootstrap-os/tasks/opensuse-tumbleweed.yml
+++ /dev/null
@@ -1 +0,0 @@
-opensuse.yml
\ No newline at end of file
diff --git a/roles/bootstrap-os/tasks/opensuse-tumbleweed.yml b/roles/bootstrap-os/tasks/opensuse-tumbleweed.yml
new file mode 100644
index 000000000..233f84865
--- /dev/null
+++ b/roles/bootstrap-os/tasks/opensuse-tumbleweed.yml
@@ -0,0 +1,3 @@
+---
+- name: Import Opensuse bootstrap
+  import_tasks: opensuse.yml
diff --git a/roles/bootstrap-os/tasks/ubuntu.yml b/roles/bootstrap-os/tasks/ubuntu.yml
deleted file mode 120000
index f1a5a89f1..000000000
--- a/roles/bootstrap-os/tasks/ubuntu.yml
+++ /dev/null
@@ -1 +0,0 @@
-debian.yml
\ No newline at end of file
diff --git a/roles/bootstrap-os/tasks/ubuntu.yml b/roles/bootstrap-os/tasks/ubuntu.yml
new file mode 100644
index 000000000..545de9436
--- /dev/null
+++ b/roles/bootstrap-os/tasks/ubuntu.yml
@@ -0,0 +1,21 @@
+---
+- name: Import Debian bootstrap
+  import_tasks: debian.yml
+
+- name: Check unattended-upgrades file exist
+  stat:
+    path: /etc/apt/apt.conf.d/50unattended-upgrades
+  register: unattended_upgrades_file_stat
+  when:
+    - ubuntu_kernel_unattended_upgrades_disabled
+
+- name: Disable kernel unattended-upgrades
+  lineinfile:
+    path: "{{ unattended_upgrades_file_stat.stat.path }}"
+    insertafter: "Unattended-Upgrade::Package-Blacklist"
+    line: '"linux-";'
+    state: present
+  become: true
+  when:
+    - ubuntu_kernel_unattended_upgrades_disabled
+    - unattended_upgrades_file_stat.stat.exists
-- 
GitLab