During an automated VyOS installation process using a script to install GRUB and its configuration, the execution failed with an AttributeError. The script attempted to call a method sort_inodes on the vinstall.grub module, which apparently does not exist in the current context. This error occurred while executing the vyos_unattended_installer.py script within a chroot environment.
Steps to Reproduce:
- Run an automated installation process
- Observe the script execution fails during the GRUB configuration phase.
Expected Result:
The script should successfully configure GRUB without errors, allowing the installation process to continue.
Actual Result:
The script execution failed with the following error message:
Traceback (most recent call last): File "/tmp/vyos_unattended_installer.py", line 43, in <module> vinstall.grub.sort_inodes(f"/boot/{vinstall.grub.GRUB_DIR_VYOS}") AttributeError: module 'vyos.system.grub' has no attribute 'sort_inodes'
ansible returns:
TASK [install-grub-v2 : Install GRUB and configuration] ********************************************************************************** fatal: [localhost]: FAILED! => {"changed": true, "cmd": ["chroot", "/mnt/inst_root", "python3", "/tmp/vyos_unattended_installer.py"], "delta": "0:00:07.627822", "end": "2024-03-16 15:18:06.541185", "msg": "non-zero return code", "rc": 1, "start": "2024-03-16 15:17:58.913363", "stderr": "Traceback (most recent call last):\n File \"/tmp/vyos_unattended_installer.py\", line 43, in <module>\n vinstall.grub.sort_inodes(f\"/boot/{vinstall.grub.GRUB_DIR_VYOS}\")\n ^^^^^^^^^^^^^^^^^^^^^^^^^\nAttributeError: module 'vyos.system.grub' has no attribute 'sort_inodes'", "stderr_lines": ["Traceback (most recent call last):", " File \"/tmp/vyos_unattended_installer.py\", line 43, in <module>", " vinstall.grub.sort_inodes(f\"/boot/{vinstall.grub.GRUB_DIR_VYOS}\")", " ^^^^^^^^^^^^^^^^^^^^^^^^^", "AttributeError: module 'vyos.system.grub' has no attribute 'sort_inodes'"], "stdout": "Installing GRUB configuration files", "stdout_lines": ["Installing GRUB configuration files"]}
Environment:
- VyOS version: 1.4.0-epa2
- Installation method docker : https://github.com/vyos/vyos-vm-images/tree/current
wget https://raw.githubusercontent.com/vyos/vyos-vm-images/current/Dockerfile docker build --tag vyos-vm-images:latest -f ./Dockerfile . docker run --rm -it --privileged -v $(pwd):/vm-build -v $(pwd)/images:/images -w /vm-build vyos-vm-images:latest bash # inside docker git clone https://github.com/vyos/vyos-vm-images.git && cd vyos-vm-images sed -i '/download-iso/s/^/#/' /opt/vyos-build/vyos-vm-images/qemu.yml; wget https://cdn.vyos.io/1.4.0-epa2/40606014-e088-11ee-924b-0b62234b6ad0/vyos-1.4.0-epa2-amd64.iso -O /tmp/vyos.iso ansible-playbook qemu.yml -e guest_agent=qemu -e cloud_init=true -e cloud_init_ds=NoCloud,ConfigDrive,None -e grub_console=serial -e enable_ssh=true -e iso_local=/tmp/vyos.iso
Possible Causes:
The sort_inodes method might have been removed or renamed in the vinstall.grub module without updating all references to it.
The environment within the chroot might not have all necessary modules or versions for the installation script to execute correctly.
Suggested Fix:
Investigate the vinstall.grub module to confirm the presence of the sort_inodes method. If the method has been removed or renamed, update the vyos_unattended_installer.py script accordingly. Additionally, ensure that the environment, especially within the chroot, has all the necessary dependencies for the installation script.
Workaround:
None.