From: Christian Pointner <equinox@realraum.at>
Date: Thu, 10 Jan 2019 00:07:16 +0000 (+0100)
Subject: make kernel command line options configurable.
X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=655d3a9bee11c8d66d281a9f7e144825b9b935d4;p=noc.git

make kernel command line options configurable.

fixes #51
---

diff --git a/ansible/host_vars/gnocchi0/main.yml b/ansible/host_vars/gnocchi0/main.yml
index d1fc949..5022f02 100644
--- a/ansible/host_vars/gnocchi0/main.yml
+++ b/ansible/host_vars/gnocchi0/main.yml
@@ -11,3 +11,6 @@ network:
 install:
   disks:
     primary: /dev/disk/by-id/ata-KINGSTON_SMS200S360G_50026B726A0002A2
+  kernel_cmdline:
+    vga: "off"
+    console: "ttyS0,115200n8"
diff --git a/ansible/host_vars/gnocchi1/main.yml b/ansible/host_vars/gnocchi1/main.yml
index 008bc57..8bbda9b 100644
--- a/ansible/host_vars/gnocchi1/main.yml
+++ b/ansible/host_vars/gnocchi1/main.yml
@@ -11,3 +11,6 @@ network:
 install:
   disks:
     primary: /dev/disk/by-id/ata-KINGSTON_SMS200S360G_50026B726A00DFF4
+  kernel_cmdline:
+    vga: "off"
+    console: "ttyS0,115200n8"
diff --git a/ansible/roles/base/tasks/07grub.yml b/ansible/roles/base/tasks/07grub.yml
new file mode 100644
index 0000000..dbc9b32
--- /dev/null
+++ b/ansible/roles/base/tasks/07grub.yml
@@ -0,0 +1,7 @@
+---
+- name: set kernel command line options
+  lineinfile:
+    path: /etc/default/grub
+    regexp: '^#?GRUB_CMDLINE_LINUX='
+    line: 'GRUB_CMDLINE_LINUX="{% for opt,val in (install.kernel_cmdline | default({})).items() %}{{ opt }}={{ val }}{% if not loop.last %} {% endif %}{% endfor %}"'
+  when: install is defined and install.kernel_cmdline is defined
diff --git a/ansible/roles/base/tasks/main.yml b/ansible/roles/base/tasks/main.yml
index cff0d6a..124fa74 100644
--- a/ansible/roles/base/tasks/main.yml
+++ b/ansible/roles/base/tasks/main.yml
@@ -6,3 +6,4 @@
   import_tasks: 04systemd.yml
 - import_tasks: 05tools.yml
 - import_tasks: 06net.yml
+- import_tasks: 07grub.yml
diff --git a/ansible/usb-install.yml b/ansible/usb-install.yml
index 7469fe2..bf4ce64 100644
--- a/ansible/usb-install.yml
+++ b/ansible/usb-install.yml
@@ -49,7 +49,7 @@
               LABEL linux
                KERNEL linux
                INITRD initrd.preseed.gz
-               APPEND install vga=off console=ttyS0,115200n8
+               APPEND install{% for opt,val in (install.kernel_cmdline | default({})).items() %} {{ opt }}={{ val }}{% endfor %}
 
         - name: Make the USB disk bootable
           pause: