Add EFI support for grub.cfg generation 09/2109/10
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Mon, 9 Dec 2019 14:24:47 +0000 (15:24 +0100)
committerAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Fri, 13 Dec 2019 15:13:35 +0000 (16:13 +0100)
On UEFI-enabled systems, the location of grub.cfg is different.
While at it, add ttyAMA0 (aarch64 PL011 serial device) console
to default kernel cmdline.

Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
Change-Id: I98b709587bfaef21134da45dfa227673c2b10678

infra-ansible.spec
roles/change_kernel_cmdline/defaults/main.yml
roles/change_kernel_cmdline/tasks/main.yml
roles/ops-hardening/tasks/main.yaml

index b6f3951..218c941 100644 (file)
@@ -15,7 +15,7 @@
 
 Name:           infra-ansible
 Version:        %{_version}
-Release:        3%{?dist}
+Release:        4%{?dist}
 Summary:        Contains ansible playbook and roles for Akraino rec blueprint
 License:        %{_platform_licence}
 Source0:        %{name}-%{version}.tar.gz
index 0c786c5..e807cc7 100644 (file)
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 # Common kernel arguments.
-kcmdline_list: ['console=tty0', 'console=ttyS1,115200', 'no_timer_check', 'audit=1']
+kcmdline_list: ['console=tty0', 'console=ttyS1,115200', 'console=ttyAMA0,115200', 'no_timer_check', 'audit=1']
 
 # Default kernel arguments.
 kcmdline_default_list: ['nofb', 'nomodeset', 'vga=normal', 'iommu=pt', 'intel_iommu=on', 'crashkernel=256M']
index 6e161bb..71dfdec 100644 (file)
     line: "GRUB_CMDLINE_LINUX_DEFAULT='{{ kcmdline_default_list | list_to_cmdline }}'"
   register: grub_cmdline_default
 
+- name: Check whether grub-efi exists
+  stat:
+    path: /boot/efi/EFI/centos/grub.cfg
+  register: grub_efi_file_stat
+
 - name: Generate grub configurations
   command: grub2-mkconfig -o /boot/grub2/grub.cfg
   when: grub_cmdline.changed or grub_cmdline_default.changed
 
+- name: Generate grub-efi configurations
+  command: grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
+  when:
+    - grub_cmdline.changed or grub_cmdline_default.changed
+    - grub_efi_file_stat.stat.exists == true
+
 - name: Ensure network.service is enabled
   systemd:
     name: network
index 193bfe2..5558cd0 100644 (file)
 # Set file permissions
 #
 
-- name: "Set set the 600 file permissions"
-  file:
-    path: "{{item}}"
-    state: touch
-    mode: 600
+- name: "Check files exist to determine the proper location of grub.cfg on UEFI systems"
+  stat: path={{item}}
   with_items:
+    - /boot/efi/EFI/centos/grub.cfg
     - /boot/grub2/grub.cfg
     - /var/log/boot.log
     - /var/log/cron
+  register: file_stat
+
+- name: "Set the 600 file permissions"
+  file:
+    path: "{{item.item}}"
+    state: touch
+    mode: "600"
+  with_items: "{{ file_stat.results }}"
+  when:
+    - item.stat.exists == true
 
 #
 # Disable direct root login
       #define users
       password_pbkdf2 root "{{ grub2_pass }}"
 
+- name: check whether grub-efi exists
+  stat:
+    path: /boot/efi/EFI/centos/grub.cfg
+  register: grub_efi_file_stat
+
 - name: generate grub config
   when: grub2_pass is defined and grub2_pass != 'Empty'
   command: /usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg
 
+- name: generate grub-efi config
+  command: /usr/sbin/grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
+  when:
+    - grub2_pass is defined and grub2_pass != 'Empty'
+    - grub_efi_file_stat.stat.exists == true
+
 #
 #Setting the noexec option to the /dev/shm mount dir
 #