From 5e86cd5768b5ac85a189d9df856ee7c0b0f65c7d Mon Sep 17 00:00:00 2001 From: zsdc Date: Tue, 10 Oct 2023 12:38:38 +0300 Subject: vyos_install: T5220: Copy the whole config folder during installation In case a user needs to add more material to the configuration (keys, scripts, etc.) we need to be sure that this material will be copied to a persistent storage during installation. This commit replaces copying of only a `config.boot` file to copying the whole `config` folder, which should satisfy all types of configurations. --- cloudinit/config/cc_vyos_install.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'cloudinit') diff --git a/cloudinit/config/cc_vyos_install.py b/cloudinit/config/cc_vyos_install.py index 4e40b2d9..b41403c3 100644 --- a/cloudinit/config/cc_vyos_install.py +++ b/cloudinit/config/cc_vyos_install.py @@ -340,13 +340,13 @@ def handle(name: str, cfg: dict, cloud: Cloud, _: Logger, args: list) -> None: f'partiton {install_target}{part_prefix}2 mouted to {DIR_DST_ROOT}/boot/efi' ) + # copy config # a config dir. It is the deepest one, so the comand will # create all the rest in a single step - target_config_dir: str = f'{DIR_DST_ROOT}/boot/{image_name}/rw/opt/vyatta/etc/config/' + target_config_dir: str = f'{DIR_DST_ROOT}/boot/{image_name}/rw/opt/vyatta/etc/' Path(target_config_dir).mkdir(parents=True) - # copy config - copy('/opt/vyatta/etc/config/config.boot', target_config_dir) - Path(f'{target_config_dir}/.vyatta_config').touch() + # we must use Linux cp command, because Python cannot preserve ownership + run(['cp', '-pr', '/opt/vyatta/etc/config', target_config_dir]) LOG.info('configuration copied from running system') # create a persistence.conf -- cgit v1.2.3 From 58c09bf858ab354dbadd890dfee53c5c933f70f4 Mon Sep 17 00:00:00 2001 From: zsdc Date: Tue, 10 Oct 2023 13:25:41 +0300 Subject: vyos_install: T5220: Fixed GRUB template Without at least one space at the beginning of the line with `linux`, it cannot be parsed by the `show system image` command. --- cloudinit/config/cc_vyos_install.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'cloudinit') diff --git a/cloudinit/config/cc_vyos_install.py b/cloudinit/config/cc_vyos_install.py index b41403c3..c544c336 100644 --- a/cloudinit/config/cc_vyos_install.py +++ b/cloudinit/config/cc_vyos_install.py @@ -264,23 +264,23 @@ def grub_configure(grub_dir: str, vyos_version: str, terminal_input --append serial console menuentry "VyOS { vyos_version } (KVM console)" {{ - linux /boot/{ vyos_version }/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{ vyos_version } console=tty0 - initrd /boot/{ vyos_version }/initrd.img + linux /boot/{ vyos_version }/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{ vyos_version } console=tty0 + initrd /boot/{ vyos_version }/initrd.img }} menuentry "VyOS { vyos_version } (Serial console)" {{ - linux /boot/{ vyos_version }/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{ vyos_version } console=ttyS{boot_params['serial_console_num']},{boot_params['serial_console_speed']} - initrd /boot/{ vyos_version }/initrd.img + linux /boot/{ vyos_version }/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{ vyos_version } console=ttyS{boot_params['serial_console_num']},{boot_params['serial_console_speed']} + initrd /boot/{ vyos_version }/initrd.img }} menuentry "VyOS { vyos_version } - password reset (KVM console)" {{ - linux /boot/{ vyos_version }/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{ vyos_version } console=tty0 init=/opt/vyatta/sbin/standalone_root_pw_reset - initrd /boot/{ vyos_version }/initrd.img + linux /boot/{ vyos_version }/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{ vyos_version } console=tty0 init=/opt/vyatta/sbin/standalone_root_pw_reset + initrd /boot/{ vyos_version }/initrd.img }} menuentry "VyOS { vyos_version } - password reset (Serial console)" {{ - linux /boot/{ vyos_version }/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{ vyos_version } console=ttyS{boot_params['serial_console_num']},{boot_params['serial_console_speed']} init=/opt/vyatta/sbin/standalone_root_pw_reset - initrd /boot/{ vyos_version }/initrd.img + linux /boot/{ vyos_version }/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{ vyos_version } console=ttyS{boot_params['serial_console_num']},{boot_params['serial_console_speed']} init=/opt/vyatta/sbin/standalone_root_pw_reset + initrd /boot/{ vyos_version }/initrd.img }} ''') -- cgit v1.2.3 From 0b136dd5beaa5b813ea4037f5c65f0c6090a4ff5 Mon Sep 17 00:00:00 2001 From: zsdc Date: Tue, 10 Oct 2023 14:01:43 +0300 Subject: vyos_install: T5220: Removed excessive code Removed an excessive call to `find_disk()`. --- cloudinit/config/cc_vyos_install.py | 1 - 1 file changed, 1 deletion(-) (limited to 'cloudinit') diff --git a/cloudinit/config/cc_vyos_install.py b/cloudinit/config/cc_vyos_install.py index c544c336..a7c73af4 100644 --- a/cloudinit/config/cc_vyos_install.py +++ b/cloudinit/config/cc_vyos_install.py @@ -307,7 +307,6 @@ def handle(name: str, cfg: dict, cloud: Cloud, _: Logger, args: list) -> None: for dev_type in ['nvme', 'mmcblk']: if dev_type in install_target: part_prefix = 'p' - install_target, target_size = find_disk() LOG.info( f'system will be installed to {install_target} ({target_size} bytes)') -- cgit v1.2.3 From 1ecd15c9392ac57fdf4b922f74effa6a67c91150 Mon Sep 17 00:00:00 2001 From: zsdc Date: Fri, 27 Oct 2023 14:15:20 +0300 Subject: vyos_install: T5220: Added `cmdline_extra` option In some platforms, the kernel may need extra options in cmdline to boot properly. The new option allows adding extra parameters to the cmdline: ``` vyos_install: boot_params: cmdline_extra: nosmt mitigations=off # extra parameters for kernel cmdline ``` --- cloudinit/config/cc_vyos_install.py | 14 +++++++++----- config/cloud.cfg.d/20_vyos_install.cfg | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'cloudinit') diff --git a/cloudinit/config/cc_vyos_install.py b/cloudinit/config/cc_vyos_install.py index a7c73af4..2c3629f8 100644 --- a/cloudinit/config/cc_vyos_install.py +++ b/cloudinit/config/cc_vyos_install.py @@ -250,6 +250,8 @@ def grub_configure(grub_dir: str, vyos_version: str, default_boot = 0 elif boot_params['console_type'] == 'serial': default_boot = 1 + if boot_params['cmdline_extra']: + cmdline_extra = f' {boot_params["cmdline_extra"]}' grub_cfg_content: str = dedent(f''' # load EFI video modules if [ "${{grub_platform}}" == "efi" ]; then @@ -264,22 +266,22 @@ def grub_configure(grub_dir: str, vyos_version: str, terminal_input --append serial console menuentry "VyOS { vyos_version } (KVM console)" {{ - linux /boot/{ vyos_version }/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{ vyos_version } console=tty0 + linux /boot/{ vyos_version }/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{ vyos_version } console=tty0{cmdline_extra} initrd /boot/{ vyos_version }/initrd.img }} menuentry "VyOS { vyos_version } (Serial console)" {{ - linux /boot/{ vyos_version }/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{ vyos_version } console=ttyS{boot_params['serial_console_num']},{boot_params['serial_console_speed']} + linux /boot/{ vyos_version }/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{ vyos_version } console=ttyS{boot_params['serial_console_num']},{boot_params['serial_console_speed']}{cmdline_extra} initrd /boot/{ vyos_version }/initrd.img }} menuentry "VyOS { vyos_version } - password reset (KVM console)" {{ - linux /boot/{ vyos_version }/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{ vyos_version } console=tty0 init=/opt/vyatta/sbin/standalone_root_pw_reset + linux /boot/{ vyos_version }/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{ vyos_version } console=tty0 init=/opt/vyatta/sbin/standalone_root_pw_reset{cmdline_extra} initrd /boot/{ vyos_version }/initrd.img }} menuentry "VyOS { vyos_version } - password reset (Serial console)" {{ - linux /boot/{ vyos_version }/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{ vyos_version } console=ttyS{boot_params['serial_console_num']},{boot_params['serial_console_speed']} init=/opt/vyatta/sbin/standalone_root_pw_reset + linux /boot/{ vyos_version }/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{ vyos_version } console=ttyS{boot_params['serial_console_num']},{boot_params['serial_console_speed']} init=/opt/vyatta/sbin/standalone_root_pw_reset{cmdline_extra} initrd /boot/{ vyos_version }/initrd.img }} ''') @@ -379,7 +381,9 @@ def handle(name: str, cfg: dict, cloud: Cloud, _: Logger, args: list) -> None: 'serial_console_speed': get_cfg_by_path(cfg, 'vyos_install/boot_params/serial_console_speed', - '9600') + '9600'), + 'cmdline_extra': + get_cfg_by_path(cfg, 'vyos_install/boot_params/cmdline_extra', '') } grub_configure(f'{DIR_DST_ROOT}/boot/grub', image_name, boot_params) LOG.info('GRUB configured') diff --git a/config/cloud.cfg.d/20_vyos_install.cfg b/config/cloud.cfg.d/20_vyos_install.cfg index 0083af68..da9eda07 100644 --- a/config/cloud.cfg.d/20_vyos_install.cfg +++ b/config/cloud.cfg.d/20_vyos_install.cfg @@ -8,3 +8,4 @@ # console_type: serial # type of console: kvm, serial. Default: kvm # serial_console_num: 1 # serial console number. Default: 0 # serial_console_speed: 115200 # serial console speed. Default: 9600 +# cmdline_extra: nosmt mitigations=off # add extra parameters for kernel cmdline -- cgit v1.2.3