depenguin-me / depenguin-run

Installer script for mfsBSD image to install FreeBSD 14.0 with zfs-on-root using qemu
MIT License
16 stars 7 forks source link

Please provide ansible playbook #40

Closed bretton closed 1 year ago

bretton commented 2 years ago

outline for an ansible playbook which can provision a host, from rescue system to end server:

doing this requires multiple stages with different usernames, and removing ssh host keys at steps:

  1. access rescue via SSH root@ip, get script from site, run it
  2. access qemu mfsbsd via ssh port 1022 mfsbsd@ip
    • configure depenguin_settings.sh with settings from inventory todo: find way to update inventory with data from provider API
    • run depenguin_bsdinstall.sh and wait for shutdown
  3. reconnect active rescue via SSH root@ip, cancel qemu, reboot
  4. wait a bit, access host user@ip for post-install setup

Ideally a drop-in role for other ansible playbooks?

click0 commented 2 years ago

There are three roles here. After pushing my roles to the github, I will probably do your first part.

click0 commented 1 year ago

There are three roles here. After pushing my roles to the github, I will probably do your first part.

I wrote the role. Linux. Running QEMU with (or without) ISO and connecting block devices (HDD/SSD) of the host machine. Using this role, you can run ISO with installers of various operating systems (including those with a graphical interface) and various service disks.

For your project, you need to add a role that first builds MfsBSD with new options, ssh keys, and archives of FreeBSD itself.

But I see the need to first create roles to create a Linux rescue ISO (based on different Linux distributions with different package managers).

bretton commented 1 year ago

awesome stuff, will have another look when I have some capacity.

I'll probably try a simpler version to gain some experience with ansible, which would connect to IP in rescue mode, download depenguin.me script and run it, then connect again to qemu instance, and run the configured unattended bsdinstall script, then reboot.

nothing needed to configure for mfsbsd or downloading ISOs, it's all configured already.

click0 commented 1 year ago

Your script mfsbsd-13.1-script/depenguinme.sh also downloads mfsbsd image: https://github.com/depenguin-me/mfsbsd-13.1-script/blob/ae8e1d3433805bf63a867475b7f59cce83237e74/depenguinme.sh#L232-L233

You are also manually trying to find block devices. https://github.com/depenguin-me/mfsbsd-13.1-script/blob/ae8e1d3433805bf63a867475b7f59cce83237e74/depenguinme.sh#L235-L244

You can use bsdinstall, but this is a manual mode that cannot be automated...

Leave the shell script mfsbsd-13.1-script/depenguinme.sh as is. Perhaps obvious issues will have to be fixed. Ansible roles will live their own separate lives. Self-written scripts for installing FreeBSD from LiveCD FreeBSD will also live their own life. Nothing prevents the authors from changing my Ansible role (click0/ansible-freebsd-install-on-zfs-lite) to fit their script options.

bretton commented 1 year ago

Your script mfsbsd-13.1-script/depenguinme.sh also downloads mfsbsd image:

yup so there's no need for ansible to do the same, just to run the script.

You are also manually trying to find block devices.

this is because a cdrom might exist on sdb in the rescue system

You can use bsdinstall, but this is a manual mode that cannot be automated...

this isn't accurate, see unattended bsdinstall https://depenguin.me/bsdinstall.html

in this case ansible would simply write values to the depenguin_settings.sh file and run depenguin_bsdinstall.sh. At least that's how I'd set it up. I wouldn't be locked into ansible, I could use same script with saltstack too.

click0 commented 1 year ago

Then I'm looking into building rescue ISOs on various Linux distributions.

And if you need my help with Ansible, you can tag me.

bretton commented 1 year ago

I have a working ansible setup here: https://github.com/depenguin-me/depenguinme-ansible

It uses the depenguin.me mfsbsd instance. Tested working with AX41, two spindle disks.

Still needs a bit of massaging to get post-install connect and updates to work.

bretton commented 1 year ago

Closing this, continue in depenguinme-ansible repo