From 20ae87120535a77cb58fb779e275a97e63419924 Mon Sep 17 00:00:00 2001 From: Fco Javier Lopez Perez Date: Fri, 17 May 2024 13:04:53 +0200 Subject: [PATCH] #7402 - Use template and not lineinline avoid inserting content multiple times --- roles/config-hot-plug/tasks/main.yaml | 18 +++++++++++------- roles/config-hot-plug/templates/grub.j2 | 1 + roles/config-hot-plug/templates/udev.j2 | 1 + 3 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 roles/config-hot-plug/templates/grub.j2 create mode 100644 roles/config-hot-plug/templates/udev.j2 diff --git a/roles/config-hot-plug/tasks/main.yaml b/roles/config-hot-plug/tasks/main.yaml index 16c7070..e9853ba 100644 --- a/roles/config-hot-plug/tasks/main.yaml +++ b/roles/config-hot-plug/tasks/main.yaml @@ -10,22 +10,26 @@ # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # configure /usr/lib/udev/rules.d/80-hotplug-cpu-mem.rules - name: configure /usr/lib/udev/rules.d/80-hotplug-cpu-mem.rules file - lineinfile: + template: + src: udev.j2 path: "{{ path_hot_plug_udev }}" - line: "{{ line_hot_plug_udev }}" - create: yes + owner: root + group: root + mode: '0644' # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # configure /etc/default/grub.d/hotplug.cfg - name: configure /etc/default/grub.d/hotplug.cfg file - lineinfile: + template: + src: grub.j2 path: "{{ path_hot_plug_grub }}" - line: "{{ line_hot_plug_grub }}" - create: yes + owner: root + group: root + mode: '0644' # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - name: Execute the command update-grub in remote shell ansible.builtin.shell: update-grub -# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \ No newline at end of file +# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/roles/config-hot-plug/templates/grub.j2 b/roles/config-hot-plug/templates/grub.j2 new file mode 100644 index 0000000..897c720 --- /dev/null +++ b/roles/config-hot-plug/templates/grub.j2 @@ -0,0 +1 @@ +{{ line_hot_plug_grub }} diff --git a/roles/config-hot-plug/templates/udev.j2 b/roles/config-hot-plug/templates/udev.j2 new file mode 100644 index 0000000..71cd77d --- /dev/null +++ b/roles/config-hot-plug/templates/udev.j2 @@ -0,0 +1 @@ +{{ line_hot_plug_udev }} -- 2.40.1