Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for new GRUB configuration in >=1.4
Added support for the new GRUB configuration style used in VyOS 1.4 and newer.
- Loading branch information
Showing
12 changed files
with
127 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# Copyright (C) 2023 VyOS maintainers and contributors | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 2 or later as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
from importlib import util | ||
from os import environ | ||
from sys import exit | ||
|
||
spec = util.spec_from_file_location( | ||
"vinstall", "/usr/libexec/vyos/op_mode/image_installer.py" | ||
) | ||
vinstall = util.module_from_spec(spec) | ||
spec.loader.exec_module(vinstall) | ||
|
||
if __name__ == "__main__": | ||
# read configuration variables | ||
vyos_version = environ["vyos_version"] | ||
console_type = "tty" if environ["console_type"] == "kvm" else "ttyS" | ||
install_target = environ["install_target"] | ||
|
||
# install GRUB configuration files | ||
vinstall.setup_grub("/boot") | ||
vinstall.grub.version_add(vyos_version, "/boot") | ||
vinstall.grub.set_default(vyos_version, "/boot") | ||
vinstall.grub.set_console_type(console_type, "/boot") | ||
|
||
# install GRUB | ||
vinstall.grub.install(install_target, "/boot/boot", "/boot/efi") | ||
|
||
# sort inodes (to make GRUB read config files in alphabetical order) | ||
vinstall.grub.sort_inodes(f"/boot/{vinstall.grub.GRUB_DIR_VYOS}") | ||
vinstall.grub.sort_inodes(f"/boot/{vinstall.grub.GRUB_DIR_VYOS_VERS}") | ||
|
||
exit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# It is necessary to mount and bind /dev, /proc, /sys and /boot in order to execute grub-install | ||
# and install GRUB correctly within the {{ volume_drive }} using chroot | ||
|
||
# XXX: ansible mount module requires fstype so it cannot be used for binding an already | ||
# mounted location, we get to use mount directly at least for /boot | ||
- name: Mount and bind /dev /proc /sys and {{ vyos_write_root }}/boot to {{ vyos_install_root }} | ||
become: true | ||
shell: mount --bind /dev {{ vyos_install_root }}/dev && | ||
mount --bind /proc {{ vyos_install_root }}/proc && | ||
mount --bind /sys {{ vyos_install_root }}/sys && | ||
mount --bind {{ vyos_write_root }} {{ vyos_install_root }}/boot | ||
|
||
- name: Mount EFI | ||
become: true | ||
mount: | ||
src: "{{ vyos_target_drive }}p{{ partition_num_efi }}" | ||
path: "{{ vyos_install_root }}/boot/efi" | ||
fstype: vfat | ||
state: mounted | ||
boot: no | ||
when: partition_num_efi is defined | ||
|
||
- name: Pause | ||
pause: | ||
prompt: "Continue?" | ||
|
||
- name: Copy installer | ||
become: true | ||
copy: | ||
src: "files/vyos_unattended_installer.py" | ||
dest: "{{ vyos_install_root }}/tmp/vyos_unattended_installer.py" | ||
|
||
- name: Install GRUB and configuration | ||
become: true | ||
command: chroot {{ vyos_install_root }} python3 /tmp/vyos_unattended_installer.py | ||
environment: | ||
vyos_version: "{{ vyos_version }}" | ||
install_target: "{{ loop_device.stdout }}" | ||
console_type: "{{ grub_console }}" | ||
|
||
- name: Remove installer | ||
become: true | ||
file: | ||
path: "{{ vyos_install_root }}/tmp/vyos_unattended_installer.py" | ||
state: absent | ||
|
||
- name: Unmount EFI | ||
become: true | ||
mount: | ||
src: "{{ vyos_target_drive }}p{{ partition_num_efi }}" | ||
path: "{{ vyos_install_root }}/boot/efi" | ||
fstype: vfat | ||
state: absent | ||
boot: no | ||
when: partition_num_efi is defined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
localhost | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
- hosts: localhost | ||
roles: | ||
- install-grub-v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
- name: Select GRUB for installer for VyOS <=1.3 | ||
include_role: | ||
name: install-grub | ||
when: vyos_version is regex("^1\.[2-3].*$") | ||
|
||
- name: Select GRUB for installer for VyOS >=1.4 | ||
include_role: | ||
name: install-grub-v2 | ||
when: vyos_version is regex("^1\.[4-9].*$") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
localhost | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
- hosts: localhost | ||
roles: | ||
- install-grub-wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters