Skip to content
This repository has been archived by the owner on May 4, 2023. It is now read-only.

Permit disabling serial console if there is none #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ grub_consoles:
- tty0
- 'ttyS0,{{ grub_serial.speed }}'

grub_serial_enabled: True

# grub serial command settings
grub_serial:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this one. In my mind it makes more sense to add grub_serial_enabled to the grub_serial-block:

Suggested change
grub_serial:
grub_serial:
enabled: True

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have actually tried this, the issue was that if you have a system with no serial console you'd actually have to override "enabled" + ALL the other elements needlessly (speed, unit, word, parity and stop) since if you only define i.e.

grub_serial:
  enabled: False

It will fail because you end up with the remaining element being undefined which trips Ansible.

speed: 115200
Expand Down
7 changes: 4 additions & 3 deletions templates/etc/default/grub.j2
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ GRUB_TIMEOUT={{ grub_timeout }}
GRUB_DISTRIBUTOR=$(lsb_release -i -s 2>/dev/null || echo {{ ansible_distribution }})
GRUB_CMDLINE_LINUX_DEFAULT="{{ grub_console }}"
GRUB_CMDLINE_LINUX="{{ grub_cmdline_linux | join(' ') }}"
{% if grub_serial | d(False) %}
{% if grub_serial_enabled %}
GRUB_SERIAL_COMMAND="serial --speed={{ grub_serial.speed }} --unit={{ grub_serial.unit }} --word={{ grub_serial.word }} --parity={{ grub_serial.parity }} --stop={{ grub_serial.stop }}"
{% endif %}

# disable graphical terminal (grub-pc only)
GRUB_TERMINAL="console serial"
{% else %}
GRUB_TERMINAL=console
{% endif %}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This endif has no corresponding if-block.

Copy link
Author

@matsimon matsimon Dec 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it should be since aa5de19