From 9c620cb28fb24adaa11b2fd91057f27b4d4670d0 Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Sat, 5 Oct 2019 17:58:44 -0500 Subject: [PATCH] Better way to handle the serial console --- roles/common/tasks/main.yaml | 6 ------ roles/grub/handlers/main.yaml | 2 ++ roles/grub/tasks/Debian.yaml | 7 +++++++ roles/grub/tasks/main.yaml | 12 ++++++++++++ roles/grub/vars/Debian.yaml | 7 +++++++ 5 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 roles/grub/handlers/main.yaml create mode 100644 roles/grub/tasks/Debian.yaml create mode 100644 roles/grub/tasks/main.yaml create mode 100644 roles/grub/vars/Debian.yaml diff --git a/roles/common/tasks/main.yaml b/roles/common/tasks/main.yaml index 953e15c..d291315 100644 --- a/roles/common/tasks/main.yaml +++ b/roles/common/tasks/main.yaml @@ -17,10 +17,4 @@ name: "{{ timezone }}" notify: restart cron -- name: enable serial console - service: - name: getty@ttyS0.service - state: started - enabled: yes - # vim:ft=yaml.ansible: diff --git a/roles/grub/handlers/main.yaml b/roles/grub/handlers/main.yaml new file mode 100644 index 0000000..c34d6c7 --- /dev/null +++ b/roles/grub/handlers/main.yaml @@ -0,0 +1,2 @@ +- name: grub-mkconfig + command: "grub-mkconfig -o {{ grub_cfg_path }}" diff --git a/roles/grub/tasks/Debian.yaml b/roles/grub/tasks/Debian.yaml new file mode 100644 index 0000000..60dc322 --- /dev/null +++ b/roles/grub/tasks/Debian.yaml @@ -0,0 +1,7 @@ +--- +- name: enable serial console + lineinfile: + path: "{{ grub_defaults_path }}" + regexp: '^GRUB_CMDLINE_LINUX=' + line: GRUB_CMDLINE_LINUX="{{ grub_cmdline_linux }}" + notify: grub-mkconfig diff --git a/roles/grub/tasks/main.yaml b/roles/grub/tasks/main.yaml new file mode 100644 index 0000000..3a2ad09 --- /dev/null +++ b/roles/grub/tasks/main.yaml @@ -0,0 +1,12 @@ +--- +- name: gather OS specific variables + include_vars: "{{ item }}" + with_first_found: + - "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yaml" + - "{{ ansible_distribution }}.yaml" + - "{{ ansible_os_family }}.yaml" + +- name: run os specific tasks + include: "{{ item }}" + with_first_found: + - "{{ ansible_os_family }}.yaml" diff --git a/roles/grub/vars/Debian.yaml b/roles/grub/vars/Debian.yaml new file mode 100644 index 0000000..c2145a6 --- /dev/null +++ b/roles/grub/vars/Debian.yaml @@ -0,0 +1,7 @@ +--- +grub_cfg_path: /boot/grub/grub.cfg +grub_defaults_path: /etc/default/grub + +# Enables serial console. +# This is helpful for libvirt guests +grub_cmdline_linux: console=ttyS0