There are enough bootloader tweaks that splitting them off to
a separate task makes sense.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
guests/site.yml | 1 +
guests/tasks/base.yml | 53 ---------------------------------------------
guests/tasks/bootloader.yml | 53 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 54 insertions(+), 53 deletions(-)
create mode 100644 guests/tasks/bootloader.yml
diff --git a/guests/site.yml b/guests/site.yml
index 351e575..ceaaf25 100644
--- a/guests/site.yml
+++ b/guests/site.yml
@@ -17,6 +17,7 @@
# Prepare environment. None of the actions performed here might
# depend on packages being installed
- include: tasks/base.yml
+ - include: tasks/bootloader.yml
- include: tasks/compat.yml
# Install base packages
diff --git a/guests/tasks/base.yml b/guests/tasks/base.yml
index 33681b4..53cbd65 100644
--- a/guests/tasks/base.yml
+++ b/guests/tasks/base.yml
@@ -120,56 +120,3 @@
- name: Configure hostname
hostname:
name: '{{ inventory_hostname }}'
-
-- name: Look for GRUB2 configuration
- stat:
- path: /etc/default/grub
- register: grubdefault
-
-- name: Look for GRUB2 configuration
- stat:
- path: /boot/grub/grub.cfg
- register: grubcfg
-
-- name: Look for GRUB2 configuration
- stat:
- path: /boot/grub2/grub.cfg
- register: grub2cfg
-
-- name: Configure GRUB2
- lineinfile:
- path: /etc/default/grub
- regexp: '^{{ item.key }}=.*$'
- line: '{{ item.key }}="{{ item.value }}"'
- backup: yes
- with_items:
- - { key: 'GRUB_TIMEOUT', value: '1' }
- - { key: 'GRUB_CMDLINE_LINUX_DEFAULT', value: 'console=ttyS0' }
- - { key: 'GRUB_CMDLINE_LINUX', value: 'console=ttyS0' }
- - { key: 'GRUB_TERMINAL', value: 'serial' }
- - { key: 'GRUB_SERIAL_COMMAND', value: 'serial' }
- when:
- - grubdefault.stat.exists
-
-- name: Apply GRUB2 configuration
- command: 'grub-mkconfig -o /boot/grub/grub.cfg'
- when:
- - grubcfg.stat.exists
-
-- name: Apply GRUB2 configuration
- command: 'grub2-mkconfig -o /boot/grub2/grub.cfg'
- when:
- - grub2cfg.stat.exists
-
-- name: Configure the FreeBSD bootloader
- lineinfile:
- path: /boot/loader.conf
- regexp: '^{{ item.key }}=.*$'
- line: '{{ item.key }}="{{ item.value }}"'
- create: yes
- backup: yes
- with_items:
- - { key: 'console', value: 'comconsole' }
- - { key: 'autoboot_delay', value: '1' }
- when:
- - os_name == 'FreeBSD'
diff --git a/guests/tasks/bootloader.yml b/guests/tasks/bootloader.yml
new file mode 100644
index 0000000..face3dd
--- /dev/null
+++ b/guests/tasks/bootloader.yml
@@ -0,0 +1,53 @@
+---
+- name: Look for GRUB2 configuration
+ stat:
+ path: /etc/default/grub
+ register: grubdefault
+
+- name: Look for GRUB2 configuration
+ stat:
+ path: /boot/grub/grub.cfg
+ register: grubcfg
+
+- name: Look for GRUB2 configuration
+ stat:
+ path: /boot/grub2/grub.cfg
+ register: grub2cfg
+
+- name: Configure GRUB2
+ lineinfile:
+ path: /etc/default/grub
+ regexp: '^{{ item.key }}=.*$'
+ line: '{{ item.key }}="{{ item.value }}"'
+ backup: yes
+ with_items:
+ - { key: 'GRUB_TIMEOUT', value: '1' }
+ - { key: 'GRUB_CMDLINE_LINUX_DEFAULT', value: 'console=ttyS0' }
+ - { key: 'GRUB_CMDLINE_LINUX', value: 'console=ttyS0' }
+ - { key: 'GRUB_TERMINAL', value: 'serial' }
+ - { key: 'GRUB_SERIAL_COMMAND', value: 'serial' }
+ when:
+ - grubdefault.stat.exists
+
+- name: Apply GRUB2 configuration
+ command: 'grub-mkconfig -o /boot/grub/grub.cfg'
+ when:
+ - grubcfg.stat.exists
+
+- name: Apply GRUB2 configuration
+ command: 'grub2-mkconfig -o /boot/grub2/grub.cfg'
+ when:
+ - grub2cfg.stat.exists
+
+- name: Configure the FreeBSD bootloader
+ lineinfile:
+ path: /boot/loader.conf
+ regexp: '^{{ item.key }}=.*$'
+ line: '{{ item.key }}="{{ item.value }}"'
+ create: yes
+ backup: yes
+ with_items:
+ - { key: 'console', value: 'comconsole' }
+ - { key: 'autoboot_delay', value: '1' }
+ when:
+ - os_name == 'FreeBSD'
--
2.14.3