chimera-pyinfra/README.md
2024-12-09 09:29:39 +10:00

88 lines
3 KiB
Markdown

# Chimera pyinfra Config
Goal: Point these [pyinfra] operations at a machine booted into the Chimera live
CD and install [Chimera Linux] to a bootable base state.
These scripts are intended for quick, automated installation of Chimera Linux
on virtual machines. They've been used against local VMs in [virt-manager] as
well as the web-based VNC console provided by some VPC hosts.
## Setup
Initial setup to install [pyinfra] in a virtual env.
UNIX-like:
```shell
python -m venv .venv
. .venv/bin/activate
pip install --require-virtualenv -r requirements.txt
```
Windows:
```powershell
python -m venv .venv
.venv\Scripts\Activate.ps1
pip install --require-virtualenv -r requirements.txt
powershell -Command { $env:VCPKG_ROOT="D:\Source\vcpkg"; pip install -r .\requirements.txt }
```
## Configuration
EFI systems will use `install.py`, BIOS systems will use `install-bios.py`.
Edit files before running.
<!-- TODO: Make this inventory data -->
1. Add your SSH public key to the `user_ssh_key` variable.
1. Review the 'Add swap' step and adjust the amount of swap if desired.
## Install
1. Boot from the Chimera base live CD
1. Log into the console as root
1. Bootstrap SSH access with [xdotool]; replace `<key> your-public-ssh-key` with your public SSH key:
* `xdotool windowfocus --sync $(xdotool selectwindow) type 'dinitctl start sshd && mkdir ~/.ssh && echo "<key> your-public-ssh-key" > ~/.ssh/authorized_keys && ip addr && fdisk -l'`
1. Note IP address above
1. Note the name of the disk to install to from above `fdisk` output
1. For EFI based systems run the `install.py` operation against the IP noted in step 5: `pyinfra -vvv --user root IP install.py`
1. For BIOS based systems run the `install-bios.py` operation against the IP noted in step 5: `pyinfra -vvv --user root IP install-bios.py`
1. At the beginning of the run after the disk device confirmation note the root password that is printed
1. Reboot: `pyinfra --user root IP exec reboot`
1. Log in and set passwd for regular user (if `doas` access is required)
## Post Install
Perform these steps either manually or by writing pyinfra code.
- https://chimera-linux.org/docs/configuration/post-installation
- https://chimera-linux.org/docs/configuration/microcode
## Troubleshooting
### Remount root
If something goes wrong and you want to remount a previous attempt (replace `/dev/vda2` as necessary):
xdotool windowfocus --sync $(xdotool selectwindow) type 'mkdir /media/root && mount /dev/vda2 /media/root && mount /dev/vda1 /media/root/boot'
### Dropped Characters With Typing With xdotool
Add `--delay 100` to the `xdotool type` command.
## Maintenance Status
I'm publishing this code in the hope it's useful to others but maintenance will
be limited. I'm unlikely to implement feature requests, but will review smaller
contributions and bug reports.
## Licence
This code is licenced under terms of the [Zero-Clause BSD licence](LICENSE).
[xdotool]: https://github.com/jordansissel/xdotool
[Chimera Linux]: https://chimera-linux.org/
[pyinfra]: https://pyinfra.com/
[virt-manager]: https://virt-manager.org/