diff --git a/.gitlab-ci-build.yml.in b/.gitlab-ci-build.yml.in index 864d5c5..759c732 100644 --- a/.gitlab-ci-build.yml.in +++ b/.gitlab-ci-build.yml.in @@ -1,12 +1,25 @@ # vim: set ft=yaml: stages: - build + - release .build: stage: build cache: - paths: - - /var/lib/gitlab-runner/.config/packer/plugins/ + - key: + files: + - sources/build.pkr.hcl + paths: + - ./packer_config/ + - paths: + - packer_cache/*.iso + rules: + - if: $CI_COMMIT_TAG + variables: + EXCEPT: '' + - if: $CI_COMMIT_TAG =~ "/^$/" + variables: + EXCEPT: '-except=upload' needs: - pipeline: $PARENT_PIPELINE_ID job: distros @@ -17,21 +30,23 @@ stages: tags: - ${tag} variables: &variables - PACKER_LOG: 1 + PACKER_CONFIG_DIR: ./packer_config/ + PACKER_LOG: 0 COMMAND: > packer build ${only} -var-file="${distro}" -var build=${BUILD} -var cpus=2 -var memory=4096 - -except=upload + ${EXCEPT} sources before_script: - packer init sources - echo $COMMAND script: + - export EFI_DIR="$(dirname "$(find /nix/store -name OVMF_VARS.fd | head -1)")/" - echo $COMMAND > build.sh - - bash build.sh + - bash build.sh || exit 1 qemu.amd64: extends: .build @@ -50,6 +65,10 @@ virtualbox-iso.amd64: tag: vbox parallel: matrix: [] + after_script: |- + if [ "$CI_JOB_STATUS" == "success" ]; then + xonsh test.xsh + fi hyperv-iso.amd64: extends: .build @@ -59,9 +78,28 @@ hyperv-iso.amd64: tag: hyperv parallel: matrix: [] - cache: - paths: - - C:\Users\gregh\AppData\Roaming\packer.d\plugins\ script: - echo $env:COMMAND > build.ps1 - - powershell .\build.ps1 \ No newline at end of file + - echo 'if (-not $?) { throw "Error in build"}' >> build.ps1 + - pwsh .\build.ps1 + after_script: |- + if ( "$CI_JOB_STATUS" -eq "success" ) { + xonsh test.xsh + } + +"Create release": + stage: release + image: registry.gitlab.com/gitlab-org/release-cli:latest + rules: + - if: $CI_COMMIT_TAG + script: echo "Tagging as released" + needs: + - pipeline: $PARENT_PIPELINE_ID + job: distros + artifacts: true + release: + tag_name: '$CI_COMMIT_TAG' + description: >- + Release $CI_COMMIT_TAG, found on [Vagrant Cloud](https://app.vagrantup.com/boxen/) + as version v${BUILD} + diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1825853..ef9f66b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,7 +27,7 @@ validate: packer validate -except=upload -var-file=${vars} sources/ done -shell: +shellcheck: stage: lint script: |- shellcheck --version @@ -35,6 +35,7 @@ shell: distros: stage: generate + image: python:3.11 artifacts: reports: dotenv: build.env diff --git a/README.box.md b/README.box.md index 2fafec7..62d8c52 100644 --- a/README.box.md +++ b/README.box.md @@ -3,7 +3,7 @@ * Arch: ${arch} * Build: ${build} * Date: ${formatdate("DD MMM YYYY", timestamp())} -* Bugs: [vms](https://github.com/greg-hellings/vms/issues) +* Bugs: [vms](https://src.thehellings.com/greg/vms/-/issues) A bare-minimum installation of the guest OS. diff --git a/README.md b/README.md index 5eb8a85..75bead3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Building on Windows +# Building on Windows Host for Hyper-V machines It's probably a good idea to have Windows Terminal installed, if you don't already. While it's not strictly necessary, it does provide a @@ -8,7 +8,8 @@ much better interface than the standard command prompt interface. * Get ahead of the curve and create an external switch called `packer-amd64` that connects directly to the external network 1. Install [Chocolatey](https://chocolatey.org/install) * Use Chocolatey to install packer `choco install packer` - * Use Chooolatey to install the Windows Assessment and Development Kit's CD tooling `choco install windows-adk-oscdimg` + * Use Chocolatey to install the Windows Assessment and Development Kit's CD tooling `choco install windows-adk-oscdimg` + * Use Chocolately to install cURL `choco install curl` 1. Install Python * From a PowerShell prompt type `python`. If it is not already installed on your system, then your Windows Store will prompt you to install it. This might require you to be in an Administrator terminal 1. Create a venv `python -m venv .venv` @@ -17,7 +18,7 @@ much better interface than the standard command prompt interface. 1. Try a build * You can execute directly with the `packer` executable, if you want * If you want to wrap up standard options, or build multiple versions/distros at once, use the `build.xsh` file - * `xonsh build.xsh -d -b hyperv-iso.amd64 -v` + * `xonsh build.xsh -d -b hyperv-iso.amd64 -v ` * You can substitute out any of the options with `-a` to build "all" targets that match ### Troubleshooting diff --git a/TODO.txt b/TODO.txt index 673e4d0..e1c2995 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,12 +1,21 @@ Distros: * Arch -- Done * NixOS -- Done +* Alpine * SuSE +* PopOS +* Mint +* Rocky +* Alma +* Oracle +* Gentoo +* Elementary OS +* Manjaro Providers: * VMWare -- Done * Parallels -- Requires money -* Hyper-V +* Hyper-V -- Done Architecture: * arm64 diff --git a/Vagrantfile.in b/Vagrantfile.in index ad40a1f..9f9d9a3 100644 --- a/Vagrantfile.in +++ b/Vagrantfile.in @@ -30,9 +30,13 @@ Vagrant.configure("2") do |config| # # Customize the amount of memory on the VM: # vb.memory = "1024" # end + config.vm.provider "libvirt" do |lv| + + end - config.vm.provider "hyperv" do |hv| - config.vm.network "private_network", bridge: "packer-amd64" + config.vm.provider "hyperv" do |hv, over| + over.vm.network "private_network", bridge: "packer-amd64" + #config.vm.network "private_network", bridge: "packer-amd64" end # diff --git a/ansible/ansible-lint.yml b/ansible/ansible-lint.yml deleted file mode 100644 index 5d63c88..0000000 --- a/ansible/ansible-lint.yml +++ /dev/null @@ -1,10 +0,0 @@ -exclude_paths: - - ../.cache/ - - .cache/ - # Must not be relatively anchored - - /**/molecule/*/*.yml - -skip_list: - - "204" - - yaml -use_default_rules: true diff --git a/ansible/molecule.yml b/ansible/molecule.yml deleted file mode 100644 index 2b02ef2..0000000 --- a/ansible/molecule.yml +++ /dev/null @@ -1,20 +0,0 @@ -dependency: - name: galaxy - options: - role-file: ../requirements.yml # relative to the role dir - requirements-file: ../requirements.yml -provisioner: - name: ansible - playbooks: # These paths are relative to scenario dir - prepare: ../shared/prepare.yml - converge: ../shared/playbook.yml - cleanup: ../shared/cleanup.yml - config_options: - defaults: - stdout_callback: yaml - force_color: true - remote_tmp: /tmp/${USER}/ansible -verifier: - name: ansible - additional_files_or_dirs: - - ../../shared/tests # relative to the scenario tests dir diff --git a/ansible/playbook.yml b/ansible/playbook.yml deleted file mode 100644 index 52e2a23..0000000 --- a/ansible/playbook.yml +++ /dev/null @@ -1,33 +0,0 @@ -- name: install guest additions - hosts: default - vars: - ansible_remote_tmp: /tmp - no_touchy: - - NixOS - pre_tasks: - - name: Pause for a moment in case we need cloud-init to finish - ansible.builtin.pause: - seconds: 20 - - - name: Help with debugging - ansible.builtin.debug: - msg: "Detected distro: {{ ansible_facts['distribution'] }}" - roles: - - role: devroles.system.epel - - - role: virtualbox - when: - - packer_builder_type == 'virtualbox-iso' - - - role: vmware - when: - - packer_builder_type == 'vmware-iso' - - ansible_facts.distribution not in no_touchy - - - role: qemu - when: - - packer_builder_type == 'qemu' - - - role: cleanup - when: - - ansible_facts.distribution not in no_touchy diff --git a/ansible/requirements.yml b/ansible/requirements.yml deleted file mode 100644 index 219cac7..0000000 --- a/ansible/requirements.yml +++ /dev/null @@ -1,3 +0,0 @@ -collections: - - name: devroles.system - version: "3.0.0" diff --git a/ansible/roles/cleanup/tasks/CentOS.yml b/ansible/roles/cleanup/tasks/CentOS.yml deleted file mode 100644 index a8cbc02..0000000 --- a/ansible/roles/cleanup/tasks/CentOS.yml +++ /dev/null @@ -1,8 +0,0 @@ -- name: clean yum history - become: true - ansible.builtin.shell: |- - set -e - yum clean all - yum history new - truncate -c -s 0 /var/log/yum.log - changed_when: false diff --git a/ansible/roles/cleanup/tasks/CentOS_7.yml b/ansible/roles/cleanup/tasks/CentOS_7.yml deleted file mode 100644 index 3146a5c..0000000 --- a/ansible/roles/cleanup/tasks/CentOS_7.yml +++ /dev/null @@ -1,12 +0,0 @@ -- name: remove unnecessesary packages - become: true - ansible.builtin.package: - name: - - make - - perl - - gcc - - kernel-devel - - kernel-headers - - bzip2 - - epel-release - state: absent diff --git a/ansible/roles/cleanup/tasks/Fedora.yml b/ansible/roles/cleanup/tasks/Fedora.yml deleted file mode 100644 index 800f6ed..0000000 --- a/ansible/roles/cleanup/tasks/Fedora.yml +++ /dev/null @@ -1,5 +0,0 @@ -- name: clean up Fedora - become: true - ansible.builtin.command: dnf clean all # noqa command-instead-of-module - when: ansible_facts.pkg_mgr not in ['atomic_container'] - changed_when: false diff --git a/ansible/roles/cleanup/tasks/Ubuntu.yml b/ansible/roles/cleanup/tasks/Ubuntu.yml deleted file mode 100644 index 490a189..0000000 --- a/ansible/roles/cleanup/tasks/Ubuntu.yml +++ /dev/null @@ -1,4 +0,0 @@ -- name: clean apt files - become: true - ansible.builtin.command: apt-get clean # noqa command-instead-of-module - changed_when: false diff --git a/ansible/roles/cleanup/tasks/main.yml b/ansible/roles/cleanup/tasks/main.yml deleted file mode 100644 index cf210d5..0000000 --- a/ansible/roles/cleanup/tasks/main.yml +++ /dev/null @@ -1,8 +0,0 @@ -- name: cleanup - include_tasks: "{{ distro }}" - loop: - - "{{ role_path }}/tasks/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}.yml" - - "{{ role_path }}/tasks/{{ ansible_facts['distribution'] }}.yml" - when: distro is file - loop_control: - loop_var: distro diff --git a/ansible/roles/init/tasks/main.yml b/ansible/roles/init/tasks/main.yml deleted file mode 100644 index 4f72541..0000000 --- a/ansible/roles/init/tasks/main.yml +++ /dev/null @@ -1,16 +0,0 @@ -- name: load version information - ansible.builtin.include_vars: "{{ item }}" - loop: - - "{{ role_path }}/vars/{{ ansible_facts['os_family'] }}.yml" - - "{{ role_path }}/vars/{{ ansible_facts['distribution'] }}.yml" - - "{{ role_path }}/vars/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}.yml" - - "{{ role_path }}/vars/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_version'] }}.yml" - when: item is file - -- name: modify init file - become: true - ansible.builtin.replace: - path: "{{ init_file }}" - replace: "{{ init_replace }}" - regexp: "{{ init_regexp }}" - when: init_file is defined diff --git a/ansible/roles/init/vars/CentOS_6.yml b/ansible/roles/init/vars/CentOS_6.yml deleted file mode 100644 index 493e5d7..0000000 --- a/ansible/roles/init/vars/CentOS_6.yml +++ /dev/null @@ -1,3 +0,0 @@ -init_file: /etc/sysconfig/init -init_regexp: "^ACTIVE_CONSOLES=.*$" -init_replace: ACTIVE_CONSOLES=/dev/tty1 diff --git a/ansible/roles/init/vars/Ubuntu.yml b/ansible/roles/init/vars/Ubuntu.yml deleted file mode 100644 index fb5217a..0000000 --- a/ansible/roles/init/vars/Ubuntu.yml +++ /dev/null @@ -1,3 +0,0 @@ -init_file: /etc/default/console-setup -init_regexp: '^(ACTIVE_CONSOLES="/dev/tty).*"' -init_replace: \g<1>1" diff --git a/ansible/roles/latest/tasks/Archlinux.yml b/ansible/roles/latest/tasks/Archlinux.yml deleted file mode 100644 index ebb5ba1..0000000 --- a/ansible/roles/latest/tasks/Archlinux.yml +++ /dev/null @@ -1,6 +0,0 @@ -- name: Update on Arch - become: true - community.general.pacman: - upgrade: true - update_cache: true - state: latest diff --git a/ansible/roles/latest/tasks/Silverblue.yml b/ansible/roles/latest/tasks/Silverblue.yml deleted file mode 100644 index ac308a7..0000000 --- a/ansible/roles/latest/tasks/Silverblue.yml +++ /dev/null @@ -1,7 +0,0 @@ -- name: Update atomic things - become: true - ansible.builtin.command: rpm-ostree upgrade - changed_when: false - register: _update_atomic - retries: 3 - until: _update_atomic is success diff --git a/ansible/roles/latest/tasks/default.yml b/ansible/roles/latest/tasks/default.yml deleted file mode 100644 index 8c12dc0..0000000 --- a/ansible/roles/latest/tasks/default.yml +++ /dev/null @@ -1,9 +0,0 @@ -- name: Update all the things - become: true - ansible.builtin.package: # noqa package-latest - name: "*" - state: latest - update_cache: true - register: _update_all - retries: 3 - until: _update_all is success diff --git a/ansible/roles/latest/tasks/main.yml b/ansible/roles/latest/tasks/main.yml deleted file mode 100644 index 760f548..0000000 --- a/ansible/roles/latest/tasks/main.yml +++ /dev/null @@ -1,25 +0,0 @@ -- name: Load update sciprt for proper distro - ansible.builtin.include_tasks: - file: "{{ item }}" - with_first_found: - - files: - - "{{ role_path }}/tasks/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_version'] }}.yml" - - "{{ role_path }}/tasks/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}.yml" - - "{{ role_path }}/tasks/{{ ansible_facts['distribution'] }}.yml" - - "{{ role_path }}/tasks/{{ ansible_facts['os_family'] }}.yml" - - "{{ role_path }}/tasks/default.yml" - -- name: Reboot, but don't care if it doesn't - block: - - name: Restart the machine - become: true - ansible.builtin.reboot: - failed_when: false # This module is buggy and can't always understand a reboot - - - name: Wait for reboot to finish - ansible.builtin.wait_for_connection: - delay: 15 - rescue: - - name: Reboot failed? lol - ansible.builtin.debug: - msg: Reboot failed. lol. diff --git a/ansible/roles/locale/tasks/main.yml b/ansible/roles/locale/tasks/main.yml deleted file mode 100644 index 181deed..0000000 --- a/ansible/roles/locale/tasks/main.yml +++ /dev/null @@ -1,11 +0,0 @@ -- name: update locale info - become: true - ansible.builtin.shell: | - set -exo pipefail - localedef --list-archive | ( grep -a -v en_US.utf8 || printf '' ) | xargs -r sudo localedef --delete-from-archive - cp /usr/lib/locale/locale-archive{,.tmpl} - build-locale-archive - when: > - ( ansible_facts['distribution'] in ['CentOS'] ) and - ( ansible_facts['distribution_major_version'] is version('8', '<') ) - changed_when: false diff --git a/ansible/roles/qemu/handlers/main.yml b/ansible/roles/qemu/handlers/main.yml deleted file mode 100644 index 2b2814b..0000000 --- a/ansible/roles/qemu/handlers/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -- name: Rebuild nixos - become: true - ansible.builtin.command: nixos-rebuild switch diff --git a/ansible/roles/qemu/tasks/main.yml b/ansible/roles/qemu/tasks/main.yml deleted file mode 100644 index 20eda97..0000000 --- a/ansible/roles/qemu/tasks/main.yml +++ /dev/null @@ -1,43 +0,0 @@ -- name: Load version information - ansible.builtin.include_vars: "{{ item }}" - loop: - - "{{ role_path }}/vars/{{ ansible_facts['os_family'] }}.yml" - - "{{ role_path }}/vars/{{ ansible_facts['distribution'] }}.yml" - - "{{ role_path }}/vars/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}.yml" - - "{{ role_path }}/vars/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_version'] }}.yml" - when: item is file - -- name: Install qemu-guest-agent - become: true - ansible.builtin.package: - name: - - qemu-guest-agent - state: present - when: ansible_facts.distribution != 'NixOS' - -############################################################################### -############################################################################### -############################################################################### -############################################################################### -############################################################################### - -- when: ansible_facts.distribution == 'NixOS' - block: - - name: Tell the configuration to pick up guest agent - ansible.builtin.replace: - path: /etc/nixos/configuration.nix - regexp: "\\./hardware-configuration\\.nix" - replace: | - ./hardware-configuration.nix - ./guest-agent.nix - - - name: Create guest additions configuration - ansible.builtin.copy: - dest: /etc/nixos/guest-agent.nix - owner: vagrant - content: | - {...}: - { - services.qemuGuest.enable = true; - } - notify: Rebuild nixos diff --git a/ansible/roles/vagrant/tasks/main.yml b/ansible/roles/vagrant/tasks/main.yml deleted file mode 100644 index a7e4539..0000000 --- a/ansible/roles/vagrant/tasks/main.yml +++ /dev/null @@ -1,65 +0,0 @@ -- name: load vars, if needed - ansible.builtin.include_vars: "{{ item }}" - loop: - - "{{ role_path }}/vars/default.yml" - - "{{ role_path }}/vars/{{ ansible_facts.distribution }}.yml" - - "{{ role_path }}/vars/{{ ansible_facts.distribution }}_{{ ansible_facts.distribution_major_version }}.yml" - when: item is file - -- name: remove cloud-init - become: true - ansible.builtin.package: - name: cloud-init - state: absent - when: ansible_facts.pkg_mgr not in ['atomic_container'] - -- name: create .ssh directory - ansible.builtin.file: - path: "{{ ansible_user_dir }}/.ssh" - state: directory - mode: "0700" - -- name: fetch authorized_keys - ansible.builtin.get_url: - mode: "0600" - dest: "{{ ansible_user_dir }}/.ssh/authorized_keys" - url: https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub - register: _fetch_authorized_keys - retries: 3 - until: _fetch_authorized_keys is success - -- name: Sudo commands - block: - - name: configure sshd - ansible.builtin.lineinfile: - line: UseDNS no - path: /etc/ssh/sshd_config - - - name: check for the sshd_config.d directory - ansible.builtin.stat: - path: /etc/ssh/sshd_config.d - register: _vagrant_sshd_config_d - - - name: be sure that sshd is configured properly to accept the pubkey - ansible.builtin.copy: - content: PubkeyAcceptedKeyTypes +ssh-rsa - mode: "0600" - owner: root - group: root - dest: /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf - when: _vagrant_sshd_config_d.stat.exists - - - name: enable sshd - ansible.builtin.service: - name: "{{ vagrant_ssh_service_name }}" - state: started - enabled: true - # Fedora 31 has a bug in systemd with kernel >= 5.8 that makes us - # unable to determine state of the service. However, if we were able - # to connect to it to run this Ansible, then we clearly are up - # and running and we can safely ignore this error - # noqa ignore-errors - ignore_errors: >- - {{ ansible_facts.distribution == 'Fedora' and - ansible_facts.distribution_major_version == '31' }} - become: true diff --git a/ansible/roles/vagrant/vars/Ubuntu.yml b/ansible/roles/vagrant/vars/Ubuntu.yml deleted file mode 100644 index 6b4aaa1..0000000 --- a/ansible/roles/vagrant/vars/Ubuntu.yml +++ /dev/null @@ -1 +0,0 @@ -vagrant_ssh_service_name: ssh diff --git a/ansible/roles/vagrant/vars/default.yml b/ansible/roles/vagrant/vars/default.yml deleted file mode 100644 index 93b0cd5..0000000 --- a/ansible/roles/vagrant/vars/default.yml +++ /dev/null @@ -1 +0,0 @@ -vagrant_ssh_service_name: sshd diff --git a/ansible/roles/virtualbox/tasks/main.yml b/ansible/roles/virtualbox/tasks/main.yml deleted file mode 100644 index cc91bf0..0000000 --- a/ansible/roles/virtualbox/tasks/main.yml +++ /dev/null @@ -1,94 +0,0 @@ -- name: Load version information - ansible.builtin.include_vars: "{{ item }}" - loop: - - "{{ role_path }}/vars/{{ ansible_facts['os_family'] }}.yml" - - "{{ role_path }}/vars/{{ ansible_facts['distribution'] }}.yml" - - "{{ role_path }}/vars/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}.yml" - - "{{ role_path }}/vars/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_version'] }}.yml" - when: item is file - -- when: ansible_facts.distribution != 'NixOS' - block: - - name: Install build deps for virtualbox addons - become: true - ansible.builtin.package: - name: "{{ virtualbox_packages }}" - state: present - update_cache: true - register: _pkg_install - retries: 3 - until: _pkg_install is success - - - name: Start services - become: true - ansible.builtin.service: - name: "{{ item }}" - state: started - enabled: true - loop: "{{ virtualbox_services }}" - - - name: Run commands to install from ISO - when: virtualbox_from_iso - become: true - block: - - name: Mount ISO file - ansible.posix.mount: - fstype: auto - path: /mnt - src: "{{ virtualbox_iso_location }}" - state: mounted - boot: false - opts: loop - - - name: Install additions - ansible.builtin.shell: /mnt/VBoxLinuxAdditions.run install 2>&1 > /root/vbox_addon_install.log - changed_when: false - failed_when: _cmd.rc not in [0, 2] - register: _cmd - - - name: Unmount ISO file - ansible.posix.mount: - path: /mnt - state: absent - - - name: Remove packages - become: true - ansible.builtin.package: - name: "{{ virtualbox_remove_packages | default([]) }}" - state: absent - when: virtualbox_remove_packages - - - name: Remove file - ansible.builtin.file: - path: "{{ virtualbox_iso_location }}" - state: absent - -############################################################################### -############################################################################### -############################################################################### -############################################################################### -############################################################################### - -- when: ansible_facts.distribution == 'NixOS' - block: - - name: Tell the configuration to pick up guest agent - ansible.builtin.replace: - path: /etc/nixos/configuration.nix - regexp: "\\./hardware-configuration\\.nix" - replace: | - ./hardware-configuration.nix - ./guest-agent.nix - - - name: Create guest additions configuration - ansible.builtin.copy: - dest: /etc/nixos/guest-agent.nix - owner: vagrant - content: | - {...}: - { - virtualisation.virtualbox.guest = { - enable = true; - x11 = false; - }; - } - notify: Rebuild nixos diff --git a/ansible/roles/virtualbox/vars/Archlinux.yml b/ansible/roles/virtualbox/vars/Archlinux.yml deleted file mode 100644 index 90c3619..0000000 --- a/ansible/roles/virtualbox/vars/Archlinux.yml +++ /dev/null @@ -1,6 +0,0 @@ -virtualbox_packages: - - virtualbox-guest-utils-nox -virtualbox_services: - - vboxservice -virtualbox_from_iso: false -virtualbox_remove_packages: [] diff --git a/ansible/roles/virtualbox/vars/CentOS.yml b/ansible/roles/virtualbox/vars/CentOS.yml deleted file mode 100644 index 55a796d..0000000 --- a/ansible/roles/virtualbox/vars/CentOS.yml +++ /dev/null @@ -1,11 +0,0 @@ -virtualbox_packages: - - bzip2 - - dkms - - kernel-devel - - kernel-headers - - make - - perl - - gcc -virtualbox_services: - - dkms -virtualbox_from_iso: true diff --git a/ansible/roles/virtualbox/vars/Debian.yml b/ansible/roles/virtualbox/vars/Debian.yml deleted file mode 100644 index cc82b9b..0000000 --- a/ansible/roles/virtualbox/vars/Debian.yml +++ /dev/null @@ -1,4 +0,0 @@ -virtualbox_packages: - - linux-image-amd64 -virtualbox_services: [] -virtualbox_from_iso: false diff --git a/ansible/roles/virtualbox/vars/Debian_10.yml b/ansible/roles/virtualbox/vars/Debian_10.yml deleted file mode 100644 index fdcf9e1..0000000 --- a/ansible/roles/virtualbox/vars/Debian_10.yml +++ /dev/null @@ -1,7 +0,0 @@ -virtualbox_packages: - - dkms - - bzip2 - - linux-headers-amd64 - - make -virtualbox_services: [] -virtualbox_from_iso: true diff --git a/ansible/roles/virtualbox/vars/Debian_9.yml b/ansible/roles/virtualbox/vars/Debian_9.yml deleted file mode 100644 index fdcf9e1..0000000 --- a/ansible/roles/virtualbox/vars/Debian_9.yml +++ /dev/null @@ -1,7 +0,0 @@ -virtualbox_packages: - - dkms - - bzip2 - - linux-headers-amd64 - - make -virtualbox_services: [] -virtualbox_from_iso: true diff --git a/ansible/roles/virtualbox/vars/Fedora.yml b/ansible/roles/virtualbox/vars/Fedora.yml deleted file mode 100644 index 9265a94..0000000 --- a/ansible/roles/virtualbox/vars/Fedora.yml +++ /dev/null @@ -1,5 +0,0 @@ -virtualbox_packages: - - virtualbox-guest-additions -virtualbox_services: [] -virtualbox_from_iso: false -virtualbox_pre_commands: [] diff --git a/ansible/roles/virtualbox/vars/Ubuntu.yml b/ansible/roles/virtualbox/vars/Ubuntu.yml deleted file mode 100644 index 5dab71c..0000000 --- a/ansible/roles/virtualbox/vars/Ubuntu.yml +++ /dev/null @@ -1,5 +0,0 @@ -virtualbox_packages: - - dkms - - virtualbox-guest-dkms -virtualbox_services: [] -virtualbox_from_iso: false diff --git a/ansible/roles/virtualbox/vars/Ubuntu_22.04.yml b/ansible/roles/virtualbox/vars/Ubuntu_22.04.yml deleted file mode 100644 index 96df7de..0000000 --- a/ansible/roles/virtualbox/vars/Ubuntu_22.04.yml +++ /dev/null @@ -1,8 +0,0 @@ -virtualbox_packages: - - virtualbox-guest-utils - - bzip2 - - tar - - build-essential -virtualbox_services: [] -virtualbox_from_iso: false -virtualbox_remove_packages: [] diff --git a/ansible/roles/virtualbox/vars/main.yml b/ansible/roles/virtualbox/vars/main.yml deleted file mode 100644 index 2ad8786..0000000 --- a/ansible/roles/virtualbox/vars/main.yml +++ /dev/null @@ -1 +0,0 @@ -virtualbox_iso_location: "{{ ansible_user_dir }}/VBoxGuestAdditions.iso" diff --git a/ansible/roles/vmware/tasks/has_package.yml b/ansible/roles/vmware/tasks/has_package.yml deleted file mode 100644 index 3a6a715..0000000 --- a/ansible/roles/vmware/tasks/has_package.yml +++ /dev/null @@ -1,6 +0,0 @@ -- name: create hgfs dir - become: true - ansible.builtin.file: - state: directory - path: /mnt/hgfs - mode: 0700 diff --git a/ansible/roles/vmware/tasks/legacy.yml b/ansible/roles/vmware/tasks/legacy.yml deleted file mode 100644 index 204de52..0000000 --- a/ansible/roles/vmware/tasks/legacy.yml +++ /dev/null @@ -1,48 +0,0 @@ -- name: create mount point - become: true - ansible.builtin.file: - path: /mnt/vmware - state: directory - mode: 0700 - -- name: mount iso file - become: true - ansible.builtin.command: mount -o loop,ro {{ ansible_user_dir }}/linux.iso /mnt/vmware # noqa command-instead-of-module - changed_when: false - -- name: create tmp dir - ansible.builtin.file: - path: /tmp/vmware - state: directory - mode: 0700 - -- name: untar tools - ansible.builtin.command: | - set -ex - tar zxf /mnt/vmware/VMWareTools-*.tar.gz -C /tmp/vmware - sudo /tmp/vmware/vmware-tools-distrib/vmware-install.pl --default --force-install - rm -r /tmp/vmware - sudo umount /mnt/vmware - changed_when: false - -- name: remove files - become: true - ansible.builtin.file: - path: "{{ item }}" - state: absent - loop: - - /mnt/vmware - - "{{ ansible_user_dir }}/linux.iso" - -- name: add content to /etc/vmware-tools/locations - ansible.builtin.blockinfile: - block: | - remove_answer ENABLE_VGAUTH - answer ENABLE_VGAUTH no - remove_answer ENABLE_VMBLOCK - answer ENABLE_VMBLOCK no - -- name: finish up installs - become: true - ansible.builtin.command: /usr/bin/vmware-config-tools.pl --default --skip-stop-abort - changed_when: false diff --git a/ansible/roles/vmware/tasks/main.yml b/ansible/roles/vmware/tasks/main.yml deleted file mode 100644 index ec1dde7..0000000 --- a/ansible/roles/vmware/tasks/main.yml +++ /dev/null @@ -1,25 +0,0 @@ -- name: read variables - ansible.builtin.include_vars: "{{ item }}" - loop: - - "{{ role_path }}/vars/{{ ansible_facts.distribution }}.yml" - - "{{ role_path }}/vars/{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml" - when: item is file - -- name: install vmware related packages - become: true - ansible.builtin.package: - name: "{{ vmware_packages }}" - state: present - -- name: modern systems - ansible.builtin.import_tasks: has_package.yml - when: >- - ansible_facts.distribution == 'fedora' or - (ansible_facts.distribution == 'debian' and - ansible_facts.distribution_major_version > 8) - -- name: legacy builds - ansible.builtin.import_tasks: legacy.yml - when: - - ansible_facts.distribution == 'debian' - - ansible_facts.distribution_major_version <= '8' diff --git a/ansible/roles/vmware/vars/CentOS-6.yml b/ansible/roles/vmware/vars/CentOS-6.yml deleted file mode 100644 index 60814d9..0000000 --- a/ansible/roles/vmware/vars/CentOS-6.yml +++ /dev/null @@ -1,6 +0,0 @@ -vmware_packages: - - perl - - net-tools - - make - - gcc - - kernel-devel diff --git a/ansible/roles/vmware/vars/Debian-8.yml b/ansible/roles/vmware/vars/Debian-8.yml deleted file mode 100644 index c5ba0a0..0000000 --- a/ansible/roles/vmware/vars/Debian-8.yml +++ /dev/null @@ -1,4 +0,0 @@ -vmware_packages: - - perl - - make - - linux-headers-{{ ansible_architecture }} diff --git a/ansible/roles/vmware/vars/main.yml b/ansible/roles/vmware/vars/main.yml deleted file mode 100644 index 2dbdb60..0000000 --- a/ansible/roles/vmware/vars/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -vmware_packages: - - open-vm-tools diff --git a/ansible/yamllint.yml b/ansible/yamllint.yml deleted file mode 100644 index 6112d47..0000000 --- a/ansible/yamllint.yml +++ /dev/null @@ -1,18 +0,0 @@ -extends: default - -rules: - line-length: - max: 120 - level: warning - document-start: - present: false - level: error - comments: - require-starting-space: false - truthy: disable # user-data files have lots of palces where the correct response is yes/no - -ignore: | - .tox - samples/ - .cache - plugins/ceph_ansible diff --git a/modify_timeout.sh b/attic/modify_timeout.sh old mode 100755 new mode 100644 similarity index 100% rename from modify_timeout.sh rename to attic/modify_timeout.sh diff --git a/build_all.xsh b/build_all.xsh deleted file mode 100755 index 3b360d8..0000000 --- a/build_all.xsh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env xonsh -import argparse -source ./test.xsh - - -parser = argparse.ArgumentParser("Build all") -parser.add_argument("--provider", choices=get_providers(), default="qemu.amd64") -args = parser.parse_args() - - -for f in g`distros/**/build.xsh`: - ./@(f) --provider @(args.provider) diff --git a/del_boxes.xsh b/del_boxes.xsh index de2479c..ce0816b 100755 --- a/del_boxes.xsh +++ b/del_boxes.xsh @@ -2,5 +2,5 @@ virsh -q vol-list default | awk '{print $1}' | xargs -r -L 1 virsh vol-delete --pool default sudo virsh -q vol-list default | awk '{print $1}' | sudo xargs -r -L 1 virsh vol-delete --pool default -vagrant box list | awk '{print $1}' | sort -u | xargs -l vagrant box remove --provider virtualbox --force -vagrant box list | awk '{print $1}' | sort -u | xargs -l vagrant box remove --provider libvirt --force +vagrant box list | grep virtualbox | awk '{print $1}' | sort -u | xargs -l vagrant box remove --provider virtualbox --force +vagrant box list | grep libvirt | awk '{print $1}' | sort -u | xargs -l vagrant box remove --provider libvirt --force diff --git a/distros/archlinux/rolling/amd64.pkrvars.hcl b/distros/archlinux/rolling/amd64.pkrvars.hcl index bb47c09..07bd2b1 100644 --- a/distros/archlinux/rolling/amd64.pkrvars.hcl +++ b/distros/archlinux/rolling/amd64.pkrvars.hcl @@ -5,11 +5,11 @@ iso = { checksum = "477f50617d648e46d6e326549aa56ab92115a29a97f2ca364e944cea06970608" } boot_command = [ - " net.ifnames=0 biosdevnames=0", - "", # Wait for system to come up? - "curl -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.sh", + "e net.ifnames=0 biosdevnames=0", + "", # Wait for system to come up? + "curl -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.sh", "", - "/usr/bin/bash /tmp/install.sh {{ .HTTPPort }} {{ .HTTPIP }}" + "/usr/bin/bash /tmp/install.sh {{ .HTTPPort }} {{ .HTTPIP }}" ] http_directory = "distros/archlinux/rolling/http/" boot_wait = "10s" diff --git a/distros/archlinux/rolling/http/in-chroot.sh b/distros/archlinux/rolling/http/in-chroot.sh index 463a06b..a41cd93 100644 --- a/distros/archlinux/rolling/http/in-chroot.sh +++ b/distros/archlinux/rolling/http/in-chroot.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -ex -disk="${1}" +#disk="${1}" # Set locale info to reasonable defaults ln -sf /usr/share/zoneinfo/UTC /etc/localtime @@ -27,10 +27,10 @@ systemctl enable NetworkManager # Configure and install grub sed -i -E -e 's/GRUB_CMDLINE_LINUX="(.*)"/GRUB_CMDLINE_LINUX="\1 net.ifnames=0 biosdevnames=0"/' /etc/default/grub -grub-install --target=i386-pc "${disk}" +grub-install --target=x86_64-efi --efi-directory /boot +grub-install --target=x86_64-efi --efi-directory /boot --removable grub-mkconfig -o /boot/grub/grub.cfg - # Create and configure the vagrant user groupadd vagrant useradd vagrant -g vagrant -G wheel -m @@ -48,4 +48,4 @@ if [ "${virt}" == "microsoft" ]; then systemctl enable hv_fcopy_daemon systemctl enable hv_kvp_daemon systemctl enable hv_vss_daemon -fi \ No newline at end of file +fi diff --git a/distros/archlinux/rolling/http/install.sh b/distros/archlinux/rolling/http/install.sh index edaf383..50e08aa 100644 --- a/distros/archlinux/rolling/http/install.sh +++ b/distros/archlinux/rolling/http/install.sh @@ -17,29 +17,33 @@ fi # The sed bit is just to strip out the extra fluff, like comments sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk ${disk} - o # create new GPT partition table + g # create new GPT partition table n # new - p # primary partition - 1 # part number + # default partition number # default start + +512M # size + t # set type + 1 # EFI system partition + n # second partition + # default partition number + # start at first free sector # default to full disk p # print, for debugging w # write the partition table and exit EOF -sleep 10 # Let me at least read it! - #t # set partition type - #1 # on partition 1 - #4 # BIOS boot - # Format and mount partitions -mkfs.ext4 "${disk}1" +mkfs.vfat "${disk}1" +mkfs.ext4 "${disk}2" -mount "${disk}1" /mnt +mount "${disk}2" /mnt +mkdir -p /mnt/boot +mount "${disk}1" /mnt/boot # Bootstrap system -pacstrap -K /mnt base linux nano sudo networkmanager openssh grub python3 +pacstrap -K /mnt base linux nano sudo networkmanager openssh grub python3 efibootmgr genfstab -L /mnt >> /mnt/etc/fstab +cat /mnt/etc/fstab # Run stuff in the chroot curl -o /mnt/in-chroot.sh "http://${host}:${port}/in-chroot.sh" diff --git a/distros/centos-stream/8/amd64.pkrvars.hcl.sh b/distros/centos-stream/8/amd64.pkrvars.hcl.sh index a604aaa..28dadf3 100755 --- a/distros/centos-stream/8/amd64.pkrvars.hcl.sh +++ b/distros/centos-stream/8/amd64.pkrvars.hcl.sh @@ -19,9 +19,10 @@ iso = { checksum = "${sha}" } boot_command = [ - "", - "inst.text inst.ks=cdrom:/ks.cfg console=tty0", - "" + "e", + "", + " inst.text inst.ks=cdrom:/ks.cfg", + "x" ] cd_files = [ "distros/centos-stream/8/disc/*" ] HERPDERP diff --git a/distros/centos-stream/8/disc/ks.cfg b/distros/centos-stream/8/disc/ks.cfg index fa97a68..566b340 100644 --- a/distros/centos-stream/8/disc/ks.cfg +++ b/distros/centos-stream/8/disc/ks.cfg @@ -16,7 +16,7 @@ services --enabled=vmtoolsd bootloader --timeout=1 --append="no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop" zerombr clearpart --all -part / --fstype=xfs --asprimary --size=1024 --grow +autopart --type=plain user --name=vagrant --plaintext --password=vagrant diff --git a/distros/centos-stream/9/amd64.pkrvars.hcl.sh b/distros/centos-stream/9/amd64.pkrvars.hcl.sh index 310b79a..63cdc08 100755 --- a/distros/centos-stream/9/amd64.pkrvars.hcl.sh +++ b/distros/centos-stream/9/amd64.pkrvars.hcl.sh @@ -21,9 +21,10 @@ iso = { checksum = "${sha}" } boot_command = [ - "", - "inst.text inst.ks=cdrom:/ks.cfg console=tty0", - "" + "e", + "", + " inst.text inst.ks=cdrom:/ks.cfg", + "x" ] cd_files = [ "distros/centos-stream/9/disc/*" ] HERPDERP \ No newline at end of file diff --git a/distros/centos-stream/9/disc/ks.cfg b/distros/centos-stream/9/disc/ks.cfg index b1dd882..c9c0f9f 100644 --- a/distros/centos-stream/9/disc/ks.cfg +++ b/distros/centos-stream/9/disc/ks.cfg @@ -14,18 +14,9 @@ services --enabled=vmtoolsd # The biosdevname and ifnames options ensure we get "eth0" as our interface # even in environments like virtualbox that emulate a real NW card bootloader --timeout=1 --append="no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop" +clearpart --all +autopart --type=plain zerombr -%include /tmp/disks.ks - -%pre --interpreter /bin/bash --log /tmp/greg -if [ -e /dev/vda ]; then - disk="vda" -else - disk="sda" -fi -echo "clearpart --all --drives=$disk" > /tmp/disks.ks -echo "part / --fstype=ext4 --asprimary --size=1024 --grow --ondisk=$disk" >> /tmp/disks.ks -%end user --name=vagrant --plaintext --password=vagrant diff --git a/distros/centos/7/amd64.pkrvars.hcl b/distros/centos/7/amd64.pkrvars.hcl index 00eec9f..f35f2fd 100644 --- a/distros/centos/7/amd64.pkrvars.hcl +++ b/distros/centos/7/amd64.pkrvars.hcl @@ -5,8 +5,9 @@ iso = { checksum = "b79079ad71cc3c5ceb3561fff348a1b67ee37f71f4cddfec09480d4589c191d6" } boot_command = [ - "", - " inst.ks=cdrom:/ks.cfg console=tty0", - "" + "e", + "", + " inst.ks=cdrom:/ks.cfg", + "x" ] cd_files = ["distros/centos/7/disc/*"] diff --git a/distros/centos/7/disc/ks.cfg b/distros/centos/7/disc/ks.cfg index 783093c..e68c971 100644 --- a/distros/centos/7/disc/ks.cfg +++ b/distros/centos/7/disc/ks.cfg @@ -36,11 +36,9 @@ libselinux-python %pre # In Hyper-V this needs a re-do for some reason -virt="$(systemd-detect-virt)" -if [ "${virt}" == "microsoft" ]; then - nmcli c down eth0 - nmcli c up eth0 -fi +set -ex +nmcli dev connect eth0 +nmcli c %end %post --erroronfail diff --git a/distros/centos/supports.yml b/distros/centos/supports.yml index 5c1deca..6409bc4 100644 --- a/distros/centos/supports.yml +++ b/distros/centos/supports.yml @@ -5,4 +5,5 @@ provider: virtualbox-iso - arch: amd64 provider: vmware-iso - # Hyper-V, I have been thus far unable to have it bring up its network automatically + - arch: amd64 + provider: hyperv-iso \ No newline at end of file diff --git a/distros/debian/10/amd64.pkrvars.hcl b/distros/debian/10/amd64.pkrvars.hcl index f2f6b47..8117cce 100644 --- a/distros/debian/10/amd64.pkrvars.hcl +++ b/distros/debian/10/amd64.pkrvars.hcl @@ -5,12 +5,17 @@ iso = { checksum = "75aa64071060402a594dcf1e14afd669ca0f8bf757b56d4c9c1a31b8f7c8f931" } boot_command = [ - "", - "auto ", - "DEBIAN_FRONTEND=text ", - "preseed/url=http://{{.HTTPIP}}:{{ .HTTPPort }}/preseed.cfg ", - "console=tty0 ", - "--- net.ifnames=0 biosdevnames=0 ", - "" + "e", + "auto ", + "preseed/url=http://{{.HTTPIP}}:{{ .HTTPPort }}/preseed.cfg ", + "ipv6.disable=1 ", + "debian-installer=en_US locale=en_US kbd-chooser/method=us ", + "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ", + "keyboard-configuration/variant=USA console-setup/ask_detect=false ", + "keyboard-configuration/xkb-keymap=us ", + "debconf/frontend=noninteractive ", + "hostname={{.Name}} ", + "domain=vagrant ", + "" ] http_directory = "distros/debian/10/http/" diff --git a/distros/debian/10/finalize.sh b/distros/debian/10/finalize.sh index 207b063..358224e 100644 --- a/distros/debian/10/finalize.sh +++ b/distros/debian/10/finalize.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash set -ex -apt autoremove -y +# 5 minute way to acquire package lock +apt-get -o DPkg::Lock::Timeout=600 autoremove -y # Configure sshd to be faster sed -i -E -e 's,^.*(UseDNS).*$,\1 No,' /etc/ssh/sshd_config @@ -12,8 +13,8 @@ apt-get clean virt="$(systemd-detect-virt)" if [ "${virt}" == "microsoft" ]; then - yum install -y hyperv-daemons - systemctl enable hpervfcopyd - systemctl enable hypervkvpd - systemctl enable hypervvssd + apt-get install -y hyperv-daemons + systemctl enable hyperv-daemons.hv-fcopy-daemon + systemctl enable hyperv-daemons.hv-kvp-daemon + systemctl enable hyperv-daemons.hv-vss-daemon fi \ No newline at end of file diff --git a/distros/debian/10/http/preseed.cfg b/distros/debian/10/http/preseed.cfg index 2c62675..fb67199 100644 --- a/distros/debian/10/http/preseed.cfg +++ b/distros/debian/10/http/preseed.cfg @@ -11,39 +11,36 @@ d-i passwd/user-password-again password vagrant d-i time/zone string UTC d-i partman-auto/method string regular -d-i partman-auto/expert_recipe string \ - scheme :: \ - 200 0 200 ext4 \ - $primary{ } \ - $bootable{ } \ - method{ format } \ - format{ } \ - use_filesystem{ } \ - filesystem{ ext4 } \ - mountpoint{ /boot } . \ - 200% 0 200% linux-swap \ - $primary{ } \ - method{ swap } \ - format{ } . \ - 1 0 -1 ext4 \ - $primary{ } \ - method{ format } \ - format{ } \ - use_filesystem{ } \ - filesystem{ ext4 } \ - mountpoint{ / } . +d-i partman-auto/choose_recipe select atomic d-i partman-partitioning/confirm_write_new_label boolean true d-i partman/choose_partition select finish d-i partman/confirm boolean true d-i partman/confirm_nooverwrite boolean true +# Network settings +d-i netcfg/enable boolean true +d-i netcfg/use_autoconfig boolean true +d-i netcfg/hostname string vagrant +d-i netcfg/domain string vagrant + +# Settings for package manager d-i apt-setup/non-free boolean true d-i apt-setup/contrib boolean true +d-i apt-setup/cdrom/set-first boolean false +d-i apt-setup/cdrom/set-next boolean false +d-i apt-setup/cdrom/set-failed boolean false +d-i mirror/country string manual +d-i mirror/http/hostname string httpredir.debian.org +d-i mirror/http/directory string /debian +d-i mirror/http/proxy string +# Package selection tasksel tasksel/first multiselect -d-i pkgsel/include string curl openssh-server sudo python3 hyperv-daemons +d-i pkgsel/include string curl openssh-server sudo python3 network-manager +popularity-contest popularity-contest/participate boolean false d-i grub-installer/bootdev string default +d-i grub-installer/force-efi-extra-removable boolean true d-i finish-install/reboot_in_progress note @@ -57,4 +54,5 @@ d-i preseed/late_command string echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /target/etc/sudoers.d/vagrant; \ chmod 440 /target/etc/sudoers.d/vagrant; \ in-target apt-get update; \ - in-target apt-get upgrade -y \ No newline at end of file + in-target apt-get upgrade -y; \ + in-target bash -c 'if [ "$(systemd-detect-virt)" == "microsoft" ]; then apt-get install -y hyperv-daemons; fi' \ No newline at end of file diff --git a/distros/debian/11/amd64.pkrvars.hcl b/distros/debian/11/amd64.pkrvars.hcl index 15ab70f..ecac4dd 100644 --- a/distros/debian/11/amd64.pkrvars.hcl +++ b/distros/debian/11/amd64.pkrvars.hcl @@ -5,12 +5,17 @@ iso = { checksum = "d7a74813a734083df30c8d35784926deaa36bc41e5c0766388e9f591ab056b72" } boot_command = [ - "", - "auto ", - "DEBIAN_FRONTEND=text ", - "preseed/url=http://{{.HTTPIP}}:{{ .HTTPPort }}/preseed.cfg ", - "console=tty0 ", - "--- net.ifnames=0 biosdevnames=0 ", - "" + "e", + "auto ", + "preseed/url=http://{{.HTTPIP}}:{{ .HTTPPort }}/preseed.cfg ", + "ipv6.disable=1 ", + "debian-installer=en_US locale=en_US kbd-chooser/method=us ", + "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ", + "keyboard-configuration/variant=USA console-setup/ask_detect=false ", + "keyboard-configuration/xkb-keymap=us ", + "debconf/frontend=noninteractive ", + "hostname={{.Name}} ", + "domain=vagrant ", + "" ] http_directory = "distros/debian/11/http/" diff --git a/distros/debian/11/finalize.sh b/distros/debian/11/finalize.sh index 8e33511..943aaa8 100644 --- a/distros/debian/11/finalize.sh +++ b/distros/debian/11/finalize.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash set -ex -apt autoremove -y +# 5 minute wait for the lock timeout +apt-get -o DPkg::Lock::Timeout=600 autoremove -y # Configure sshd to be faster cat << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf @@ -14,8 +15,8 @@ apt-get clean virt="$(systemd-detect-virt)" if [ "${virt}" == "microsoft" ]; then - yum install -y hyperv-daemons - systemctl enable hpervfcopyd - systemctl enable hypervkvpd - systemctl enable hypervvssd + apt-get install -y hyperv-daemons + systemctl enable hv-fcopy-daemon + systemctl enable hv-kvp-daemon + systemctl enable hv-vss-daemon fi \ No newline at end of file diff --git a/distros/debian/11/http/preseed.cfg b/distros/debian/11/http/preseed.cfg index f4c4133..9c06bbe 100644 --- a/distros/debian/11/http/preseed.cfg +++ b/distros/debian/11/http/preseed.cfg @@ -11,39 +11,30 @@ d-i passwd/user-password-again password vagrant d-i time/zone string UTC d-i partman-auto/method string regular -d-i partman-auto/expert_recipe string \ - scheme :: \ - 200 0 200 ext4 \ - $primary{ } \ - $bootable{ } \ - method{ format } \ - format{ } \ - use_filesystem{ } \ - filesystem{ ext4 } \ - mountpoint{ /boot } . \ - 200% 0 200% linux-swap \ - $primary{ } \ - method{ swap } \ - format{ } . \ - 1 0 -1 ext4 \ - $primary{ } \ - method{ format } \ - format{ } \ - use_filesystem{ } \ - filesystem{ ext4 } \ - mountpoint{ / } . +d-i partman-auto/choose_recipe select atomic d-i partman-partitioning/confirm_write_new_label boolean true d-i partman/choose_partition select finish d-i partman/confirm boolean true d-i partman/confirm_nooverwrite boolean true +# Settings for package manager d-i apt-setup/non-free boolean true d-i apt-setup/contrib boolean true +d-i apt-setup/cdrom/set-first boolean false +d-i apt-setup/cdrom/set-next boolean false +d-i apt-setup/cdrom/set-failed boolean false +d-i mirror/country string manual +d-i mirror/http/hostname string httpredir.debian.org +d-i mirror/http/directory string /debian +d-i mirror/http/proxy string +# Package selection tasksel tasksel/first multiselect -d-i pkgsel/include string curl openssh-server sudo python3 +d-i pkgsel/include string curl openssh-server sudo python3 network-manager +popularity-contest popularity-contest/participate boolean false d-i grub-installer/bootdev string default +d-i grub-installer/force-efi-extra-removable boolean true d-i finish-install/reboot_in_progress note @@ -58,9 +49,4 @@ d-i preseed/late_command string chmod 440 /target/etc/sudoers.d/vagrant; \ sed -i -e 's/ens3/ens5/g' /target/etc/network/interfaces; \ in-target apt-get update; \ - in-target apt-get upgrade -y - -#echo '[Match]' >> /target/etc/systemd/network/dhcp.network; \ -#echo 'Name=en*' >> /target/etc/systemd/network/dhcp.network; \ -#echo '[Network]' >> /target/etc/systemd/network/dhcp.network; \ -#echo 'DHCP=yes' >> /target/etc/systemd/network/dhcp.network; \ + in-target apt-get upgrade -y \ No newline at end of file diff --git a/distros/debian/12/amd64.pkrvars.hcl b/distros/debian/12/amd64.pkrvars.hcl index 118f7ef..8cf1a0e 100644 --- a/distros/debian/12/amd64.pkrvars.hcl +++ b/distros/debian/12/amd64.pkrvars.hcl @@ -5,12 +5,17 @@ iso = { checksum = "64d727dd5785ae5fcfd3ae8ffbede5f40cca96f1580aaa2820e8b99dae989d94" } boot_command = [ - "", - "auto ", - "DEBIAN_FRONTEND=text ", - "preseed/url=http://{{.HTTPIP}}:{{ .HTTPPort }}/preseed.cfg ", - "console=tty0 ", - "--- net.ifnames=0 biosdevnames=0 ", - "" + "e", + "auto ", + "preseed/url=http://{{.HTTPIP}}:{{ .HTTPPort }}/preseed.cfg ", + "ipv6.disable=1 ", + "debian-installer=en_US locale=en_US kbd-chooser/method=us ", + "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ", + "keyboard-configuration/variant=USA console-setup/ask_detect=false ", + "keyboard-configuration/xkb-keymap=us ", + "debconf/frontend=noninteractive ", + "hostname={{.Name}} ", + "domain=vagrant ", + "" ] http_directory = "distros/debian/12/http/" diff --git a/distros/debian/12/finalize.sh b/distros/debian/12/finalize.sh index 8e33511..e8a9a28 100644 --- a/distros/debian/12/finalize.sh +++ b/distros/debian/12/finalize.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash set -ex -apt autoremove -y +# 5 minute timeout for the package lock to arrive +apt-get -o DPkg::Lock::Timeout=600 autoremove -y # Configure sshd to be faster cat << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf @@ -14,8 +15,8 @@ apt-get clean virt="$(systemd-detect-virt)" if [ "${virt}" == "microsoft" ]; then - yum install -y hyperv-daemons - systemctl enable hpervfcopyd - systemctl enable hypervkvpd - systemctl enable hypervvssd + apt-get install -y hyperv-daemons + systemctl enable hv-fcopy-daemon + systemctl enable hv-kvp-daemon + systemctl enable hv-vss-daemon fi \ No newline at end of file diff --git a/distros/debian/12/http/preseed.cfg b/distros/debian/12/http/preseed.cfg index 9f6abef..a15e0d7 100644 --- a/distros/debian/12/http/preseed.cfg +++ b/distros/debian/12/http/preseed.cfg @@ -1,5 +1,3 @@ -d-i auto-install/enable boolean true -d-i apt-setup/disable-cdrom-entries boolean true d-i debian-installer/locale string en_US d-i keyboard-configuration/xkb-keymap select us @@ -15,14 +13,12 @@ d-i time/zone string UTC d-i partman-auto/method string regular d-i partman-auto/expert_recipe string \ scheme :: \ - 200 0 200 ext4 \ + 512 50 512 fat32 \ $primary{ } \ $bootable{ } \ - method{ format } \ + method{ efi } \ format{ } \ - use_filesystem{ } \ - filesystem{ ext4 } \ - mountpoint{ /boot } . \ + mountpoint{ /boot/efi } . \ 200% 0 200% linux-swap \ $primary{ } \ method{ swap } \ @@ -39,13 +35,24 @@ d-i partman/choose_partition select finish d-i partman/confirm boolean true d-i partman/confirm_nooverwrite boolean true +# Settings for package manager d-i apt-setup/non-free boolean true d-i apt-setup/contrib boolean true +d-i apt-setup/cdrom/set-first boolean false +d-i apt-setup/cdrom/set-next boolean false +d-i apt-setup/cdrom/set-failed boolean false +d-i mirror/country string manual +d-i mirror/http/hostname string httpredir.debian.org +d-i mirror/http/directory string /debian +d-i mirror/http/proxy string +# Package selection tasksel tasksel/first multiselect -d-i pkgsel/include string curl openssh-server sudo python3 +d-i pkgsel/include string curl openssh-server sudo python3 network-manager +popularity-contest popularity-contest/participate boolean false d-i grub-installer/bootdev string default +d-i grub-installer/force-efi-extra-removable boolean true d-i finish-install/reboot_in_progress note @@ -55,8 +62,9 @@ d-i preseed/early_command string -e "/in-target/i echo 'discover=d' >> /target/etc/discover-pkginstall.conf" \ /usr/lib/pre-pkgsel.d/20install-hwpackages d-i preseed/late_command string \ - echo 'Defaults:vagrant !nrequiretty' > /target/etc/sudoers.d/vagrant; \ + echo 'Defaults:vagrant !requiretty' > /target/etc/sudoers.d/vagrant; \ echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /target/etc/sudoers.d/vagrant; \ chmod 440 /target/etc/sudoers.d/vagrant; \ + sed -i -e 's/ens3/ens5/g' /target/etc/network/interfaces; \ in-target apt-get update; \ - in-target apt-get upgrade -y + in-target apt-get upgrade -y \ No newline at end of file diff --git a/distros/debian/supports.yml b/distros/debian/supports.yml index ba157fd..9865444 100644 --- a/distros/debian/supports.yml +++ b/distros/debian/supports.yml @@ -5,6 +5,13 @@ provider: virtualbox-iso - arch: amd64 provider: vmware-iso + - arch: amd64 + provider: hyperv-iso 11: *supp -12: *supp -#9: *supp # EOL +12: + - arch: amd64 + provider: qemu + - arch: amd64 + provider: vmware-iso + - arch: amd64 + provider: hyperv-iso \ No newline at end of file diff --git a/distros/fedora/37/x86_64.ks b/distros/fedora/37/amd64-ks.cfg similarity index 96% rename from distros/fedora/37/x86_64.ks rename to distros/fedora/37/amd64-ks.cfg index e0467fc..53fece2 100644 --- a/distros/fedora/37/x86_64.ks +++ b/distros/fedora/37/amd64-ks.cfg @@ -99,6 +99,14 @@ else exit 1 fi +virt="$(systemd-detect-virt)" +if [ "${virt}" == "microsoft" ]; then + dnf install -y hyperv-daemons + systemctl enable hpervfcopyd + systemctl enable hypervkvpd + systemctl enable hypervvssd +fi + if [ "$(arch)" = "x86_64" ]; then # Set up legacy BIOS boot if we booted from UEFI grub2-install --target=i386-pc "${device}" diff --git a/distros/fedora/37/amd64.pkrvars.hcl b/distros/fedora/37/amd64.pkrvars.hcl index 55c88d2..2be02d2 100644 --- a/distros/fedora/37/amd64.pkrvars.hcl +++ b/distros/fedora/37/amd64.pkrvars.hcl @@ -6,8 +6,8 @@ iso = { } boot_command = [ "e ", - "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/x86_64.ks console=tty0" + "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/amd64-ks.cfg console=tty0" ] cd_files = [ - "distros/fedora/37/*.ks" + "distros/fedora/37/*.cfg" ] diff --git a/distros/fedora/38/x86_64.ks b/distros/fedora/38/amd64-ks.cfg similarity index 96% rename from distros/fedora/38/x86_64.ks rename to distros/fedora/38/amd64-ks.cfg index e08e699..d72575e 100644 --- a/distros/fedora/38/x86_64.ks +++ b/distros/fedora/38/amd64-ks.cfg @@ -91,6 +91,13 @@ else exit 1 fi +virt="$(systemd-detect-virt)" +if [ "${virt}" == "microsoft" ]; then + dnf install -y hyperv-daemons + systemctl enable hpervfcopyd + systemctl enable hypervkvpd + systemctl enable hypervvssd +fi if [ "$(arch)" = "x86_64" ]; then # Set up legacy BIOS boot if we booted from UEFI diff --git a/distros/fedora/38/amd64.pkrvars.hcl b/distros/fedora/38/amd64.pkrvars.hcl index 2a1687a..78b1318 100644 --- a/distros/fedora/38/amd64.pkrvars.hcl +++ b/distros/fedora/38/amd64.pkrvars.hcl @@ -6,8 +6,8 @@ iso = { } boot_command = [ "e ", - "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/x86_64.ks console=tty0" + "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/amd64-ks.cfg console=tty0" ] cd_files = [ - "distros/fedora/38/*.ks" + "distros/fedora/38/*.cfg" ] diff --git a/distros/fedora/39/x86_64.ks b/distros/fedora/39/amd64-ks.cfg similarity index 96% rename from distros/fedora/39/x86_64.ks rename to distros/fedora/39/amd64-ks.cfg index c29c9d4..90ed9f8 100644 --- a/distros/fedora/39/x86_64.ks +++ b/distros/fedora/39/amd64-ks.cfg @@ -98,6 +98,13 @@ else exit 1 fi +virt="$(systemd-detect-virt)" +if [ "${virt}" == "microsoft" ]; then + dnf install -y hyperv-daemons + systemctl enable hpervfcopyd + systemctl enable hypervkvpd + systemctl enable hypervvssd +fi if [ "$(arch)" = "x86_64" ]; then # Set up legacy BIOS boot if we booted from UEFI diff --git a/distros/fedora/39/amd64.pkrvars.hcl b/distros/fedora/39/amd64.pkrvars.hcl index 660d7b3..75d2dfe 100644 --- a/distros/fedora/39/amd64.pkrvars.hcl +++ b/distros/fedora/39/amd64.pkrvars.hcl @@ -6,8 +6,8 @@ iso = { } boot_command = [ "e ", - "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/x86_64.ks console=tty0" + "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/amd64-ks.cfg console=tty0" ] cd_files = [ - "distros/fedora/39/*.ks" + "distros/fedora/39/*.cfg" ] diff --git a/distros/fedora/rawhide/x86_64.ks b/distros/fedora/rawhide/amd64-ks.cfg similarity index 96% rename from distros/fedora/rawhide/x86_64.ks rename to distros/fedora/rawhide/amd64-ks.cfg index 731fb7a..ccbb7d9 100644 --- a/distros/fedora/rawhide/x86_64.ks +++ b/distros/fedora/rawhide/amd64-ks.cfg @@ -33,7 +33,7 @@ url --mirrorlist=https://mirrors.fedoraproject.org/mirrorlist?repo=rawhide&arch= reboot ##### begin package list ############################################# -%packages --instLangs=en +%packages --inst-langs=en # Include packages for the cloud-server-environment group @^cloud-server-environment @@ -97,6 +97,13 @@ else exit 1 fi +virt="$(systemd-detect-virt)" +if [ "${virt}" == "microsoft" ]; then + dnf install -y hyperv-daemons + systemctl enable hpervfcopyd + systemctl enable hypervkvpd + systemctl enable hypervvssd +fi if [ "$(arch)" = "x86_64" ]; then # Set up legacy BIOS boot if we booted from UEFI diff --git a/distros/fedora/rawhide/amd64.pkrvars.hcl.sh b/distros/fedora/rawhide/amd64.pkrvars.hcl.sh index 5ae75ee..ffb98f5 100755 --- a/distros/fedora/rawhide/amd64.pkrvars.hcl.sh +++ b/distros/fedora/rawhide/amd64.pkrvars.hcl.sh @@ -35,10 +35,10 @@ iso = { } boot_command = [ "e", - "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/x86_64.ks console=tty0 console=ttyS0" + "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/amd64-ks.cfg console=tty0 console=ttyS0" ] cd_files = [ - "distros/fedora/rawhide/*.ks" + "distros/fedora/rawhide/*.cfg" ] EOF diff --git a/distros/nixos/23.05/amd64.pkrvars.hcl.sh b/distros/nixos/23.05/amd64.pkrvars.hcl.sh index 7015a4d..70f42c6 100755 --- a/distros/nixos/23.05/amd64.pkrvars.hcl.sh +++ b/distros/nixos/23.05/amd64.pkrvars.hcl.sh @@ -29,14 +29,12 @@ iso = { checksum = "${sha}" } boot_command = [ - " net.ifnames=0 biosdevnames=0", - "", # Wait for system to come up? - "curl -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.sh", - "", - "sudo bash /tmp/install.sh {{ .HTTPPort }} {{ .HTTPIP }}" + "curl -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.sh", + "", + "sudo bash /tmp/install.sh {{ .HTTPPort }} {{ .HTTPIP }}" ] http_directory = "distros/nixos/23.05/http/" -boot_wait = "5s" +boot_wait = "60s" EOF rm -r "${tmp}" diff --git a/distros/nixos/23.05/http/configuration.nix b/distros/nixos/23.05/http/configuration.nix index 4bea79e..6d769e0 100644 --- a/distros/nixos/23.05/http/configuration.nix +++ b/distros/nixos/23.05/http/configuration.nix @@ -3,7 +3,7 @@ { imports = [ ./hardware-configuration.nix - #PROVIDER_PLACEHOLDER + ./guest-agent.nix ]; system.stateVersion = "23.05"; @@ -37,9 +37,11 @@ } ]; - boot.loader.grub = { - enable = true; - devices = [ "@BOOT_DEVICE@" ]; + boot.loader = { + systemd-boot = { + enable = true; + }; + efi.canTouchEfiVariables = true; }; networking = { hostName = "vagrant"; diff --git a/distros/nixos/23.05/http/ga-kvm.nix b/distros/nixos/23.05/http/ga-kvm.nix new file mode 120000 index 0000000..15276b3 --- /dev/null +++ b/distros/nixos/23.05/http/ga-kvm.nix @@ -0,0 +1 @@ +ga-qemu.nix \ No newline at end of file diff --git a/distros/nixos/23.05/http/ga-microsoft.nix b/distros/nixos/23.05/http/ga-microsoft.nix new file mode 100644 index 0000000..a477797 --- /dev/null +++ b/distros/nixos/23.05/http/ga-microsoft.nix @@ -0,0 +1,4 @@ +{...}: +{ + virtualisation.hypervGuest.enable = true; +} \ No newline at end of file diff --git a/distros/nixos/23.05/http/ga-oracle.nix b/distros/nixos/23.05/http/ga-oracle.nix new file mode 100644 index 0000000..06bc077 --- /dev/null +++ b/distros/nixos/23.05/http/ga-oracle.nix @@ -0,0 +1,7 @@ +{...}: +{ + virtualisation.virtualbox.guest = { + enable = true; + x11 = false; + }; +} \ No newline at end of file diff --git a/distros/nixos/23.05/http/ga-qemu.nix b/distros/nixos/23.05/http/ga-qemu.nix new file mode 100644 index 0000000..7389b6d --- /dev/null +++ b/distros/nixos/23.05/http/ga-qemu.nix @@ -0,0 +1,4 @@ +{...}: +{ + services.qemuGuest.enable = true; +} \ No newline at end of file diff --git a/distros/nixos/23.05/http/ga-vmware.nix b/distros/nixos/23.05/http/ga-vmware.nix new file mode 100644 index 0000000..8599f81 --- /dev/null +++ b/distros/nixos/23.05/http/ga-vmware.nix @@ -0,0 +1,7 @@ +{...}: +{ + virtualisation.vmware.guest = { + enable = true; + headless = false; + } +} \ No newline at end of file diff --git a/distros/nixos/23.05/http/install.sh b/distros/nixos/23.05/http/install.sh index d0f2270..abd1c6c 100644 --- a/distros/nixos/23.05/http/install.sh +++ b/distros/nixos/23.05/http/install.sh @@ -15,30 +15,42 @@ fi # The sed bit is just to strip out the extra fluff, like comments sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk ${disk} - o # create new DOS partition table + g # create new GPT partition table n # new - p # primary partition - 1 # part number + # default partition number # default start + +512M # size + t # set type + 1 # EFI system partition + n # second partition + # default partition number + # start at first free sector # default to full disk p # print, for debugging w # write the partition table and exit EOF + +sleep 10 # Let me at least read it! #t # set partition type #1 # on partition 1 #4 # BIOS boot # Format and mount partitions -mkfs.ext4 -L root "${disk}1" +mkfs.vfat "${disk}1" +mkfs.ext4 "${disk}2" -mount "${disk}1" /mnt +mount "${disk}2" /mnt +mkdir -p /mnt/boot +mount "${disk}1" /mnt/boot # Bootstrap system +virt="$(systemd-detect-virt)" nixos-generate-config --root /mnt curl -o /mnt/etc/nixos/configuration.nix "http://${host}:${port}/configuration.nix" curl -o /mnt/etc/nixos/flake.nix "http://${host}:${port}/flake.nix" +curl -o /mnt/etc/nixos/guest-agent.nix "http://${host}:${port}/ga-${virt}.nix" sed -i -E -e "s,@BOOT_DEVICE@,${disk}," /mnt/etc/nixos/configuration.nix -sed -i -E -e 's,(.*device = "/dev/disk/).*(".*),\1by-label/root\2,' /mnt/etc/nixos/hardware-configuration.nix + nixos-install --no-root-password --flake "/mnt/etc/nixos/#vagrant" # Run stuff in the chroot @@ -46,4 +58,7 @@ curl -o /mnt/root/in-chroot.sh "http://${host}:${port}/in-chroot.sh" nixos-enter --root /mnt -c 'bash /root/in-chroot.sh' rm /mnt/root/in-chroot.sh -reboot +umount /mnt/boot +umount /mnt +efibootmgr --bootnext "$(efibootmgr | grep Linux | awk '{print $1}' | sed -E 's/[^0-9]//g')" +reboot \ No newline at end of file diff --git a/distros/nixos/23.11/amd64.pkrvars.hcl.sh b/distros/nixos/23.11/amd64.pkrvars.hcl.sh index a824cd6..ab21028 100755 --- a/distros/nixos/23.11/amd64.pkrvars.hcl.sh +++ b/distros/nixos/23.11/amd64.pkrvars.hcl.sh @@ -29,14 +29,12 @@ iso = { checksum = "${sha}" } boot_command = [ - " net.ifnames=0 biosdevnames=0", - "", # Wait for system to come up? - "curl -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.sh", + "curl -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.sh", "", - "sudo bash /tmp/install.sh {{ .HTTPPort }} {{ .HTTPIP }}" + "sudo bash /tmp/install.sh {{ .HTTPPort }} {{ .HTTPIP }}" ] -http_directory = "distros/nixos/23.05/http/" -boot_wait = "5s" +http_directory = "distros/nixos/23.11/http/" +boot_wait = "60s" EOF rm -r "${tmp}" diff --git a/distros/nixos/23.11/http/configuration.nix b/distros/nixos/23.11/http/configuration.nix index 037c852..69667f4 100644 --- a/distros/nixos/23.11/http/configuration.nix +++ b/distros/nixos/23.11/http/configuration.nix @@ -3,7 +3,7 @@ { imports = [ ./hardware-configuration.nix - #PROVIDER_PLACEHOLDER + ./guest-agent.nix ]; system.stateVersion = "23.11"; @@ -37,9 +37,11 @@ } ]; - boot.loader.grub = { - enable = true; - devices = [ "@BOOT_DEVICE@" ]; + boot.loader = { + systemd-boot = { + enable = true; + }; + efi.canTouchEfiVariables = true; }; networking = { hostName = "vagrant"; diff --git a/distros/nixos/23.11/http/ga-kvm.nix b/distros/nixos/23.11/http/ga-kvm.nix new file mode 120000 index 0000000..15276b3 --- /dev/null +++ b/distros/nixos/23.11/http/ga-kvm.nix @@ -0,0 +1 @@ +ga-qemu.nix \ No newline at end of file diff --git a/distros/nixos/23.11/http/ga-microsoft.nix b/distros/nixos/23.11/http/ga-microsoft.nix new file mode 100644 index 0000000..a477797 --- /dev/null +++ b/distros/nixos/23.11/http/ga-microsoft.nix @@ -0,0 +1,4 @@ +{...}: +{ + virtualisation.hypervGuest.enable = true; +} \ No newline at end of file diff --git a/distros/nixos/23.11/http/ga-oracle.nix b/distros/nixos/23.11/http/ga-oracle.nix new file mode 100644 index 0000000..06bc077 --- /dev/null +++ b/distros/nixos/23.11/http/ga-oracle.nix @@ -0,0 +1,7 @@ +{...}: +{ + virtualisation.virtualbox.guest = { + enable = true; + x11 = false; + }; +} \ No newline at end of file diff --git a/distros/nixos/23.11/http/ga-qemu.nix b/distros/nixos/23.11/http/ga-qemu.nix new file mode 100644 index 0000000..7389b6d --- /dev/null +++ b/distros/nixos/23.11/http/ga-qemu.nix @@ -0,0 +1,4 @@ +{...}: +{ + services.qemuGuest.enable = true; +} \ No newline at end of file diff --git a/distros/nixos/23.11/http/ga-vmware.nix b/distros/nixos/23.11/http/ga-vmware.nix new file mode 100644 index 0000000..8599f81 --- /dev/null +++ b/distros/nixos/23.11/http/ga-vmware.nix @@ -0,0 +1,7 @@ +{...}: +{ + virtualisation.vmware.guest = { + enable = true; + headless = false; + } +} \ No newline at end of file diff --git a/distros/nixos/23.11/http/install.sh b/distros/nixos/23.11/http/install.sh index d0f2270..abd1c6c 100644 --- a/distros/nixos/23.11/http/install.sh +++ b/distros/nixos/23.11/http/install.sh @@ -15,30 +15,42 @@ fi # The sed bit is just to strip out the extra fluff, like comments sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk ${disk} - o # create new DOS partition table + g # create new GPT partition table n # new - p # primary partition - 1 # part number + # default partition number # default start + +512M # size + t # set type + 1 # EFI system partition + n # second partition + # default partition number + # start at first free sector # default to full disk p # print, for debugging w # write the partition table and exit EOF + +sleep 10 # Let me at least read it! #t # set partition type #1 # on partition 1 #4 # BIOS boot # Format and mount partitions -mkfs.ext4 -L root "${disk}1" +mkfs.vfat "${disk}1" +mkfs.ext4 "${disk}2" -mount "${disk}1" /mnt +mount "${disk}2" /mnt +mkdir -p /mnt/boot +mount "${disk}1" /mnt/boot # Bootstrap system +virt="$(systemd-detect-virt)" nixos-generate-config --root /mnt curl -o /mnt/etc/nixos/configuration.nix "http://${host}:${port}/configuration.nix" curl -o /mnt/etc/nixos/flake.nix "http://${host}:${port}/flake.nix" +curl -o /mnt/etc/nixos/guest-agent.nix "http://${host}:${port}/ga-${virt}.nix" sed -i -E -e "s,@BOOT_DEVICE@,${disk}," /mnt/etc/nixos/configuration.nix -sed -i -E -e 's,(.*device = "/dev/disk/).*(".*),\1by-label/root\2,' /mnt/etc/nixos/hardware-configuration.nix + nixos-install --no-root-password --flake "/mnt/etc/nixos/#vagrant" # Run stuff in the chroot @@ -46,4 +58,7 @@ curl -o /mnt/root/in-chroot.sh "http://${host}:${port}/in-chroot.sh" nixos-enter --root /mnt -c 'bash /root/in-chroot.sh' rm /mnt/root/in-chroot.sh -reboot +umount /mnt/boot +umount /mnt +efibootmgr --bootnext "$(efibootmgr | grep Linux | awk '{print $1}' | sed -E 's/[^0-9]//g')" +reboot \ No newline at end of file diff --git a/distros/nixos/23.11/qemu.sh b/distros/nixos/23.11/qemu.sh index b55b32d..087d718 100644 --- a/distros/nixos/23.11/qemu.sh +++ b/distros/nixos/23.11/qemu.sh @@ -1,12 +1,2 @@ #!/usr/bin/env bash -set -ex - -sed -i -e 's,#PROVIDER_PLACEHOLDER,./guest-agent.nix,' /etc/nixos/configuration.nix -cat << EOF > /etc/nixos/guest-agent.nix -{...}: -{ - services.qemuGuest.enable = true; -} -EOF -chown vagrant:vagrant /etc/nixos/guest-agent.nix -nixos-rebuild switch +set -ex \ No newline at end of file diff --git a/distros/nixos/23.11/virtualbox.sh b/distros/nixos/23.11/virtualbox.sh index 33feaec..087d718 100644 --- a/distros/nixos/23.11/virtualbox.sh +++ b/distros/nixos/23.11/virtualbox.sh @@ -1,15 +1,2 @@ #!/usr/bin/env bash -set -ex - -sed -i -e 's,#PROVIDER_PLACEHOLDER,./guest-agent.nix,' /etc/nixos/configuration.nix -cat << EOF > /etc/nixos/guest-agent.nix -{...}: -{ - virtualisation.virtualbox.guest = { - enable = true; - x11 = false; - }; -} -EOF -chown vagrant:vagrant /etc/nixos/guest-agent.nix -nixos-rebuild switch +set -ex \ No newline at end of file diff --git a/distros/nixos/23.11/vmware.sh b/distros/nixos/23.11/vmware.sh index e3b0b6e..087d718 100644 --- a/distros/nixos/23.11/vmware.sh +++ b/distros/nixos/23.11/vmware.sh @@ -1,15 +1,2 @@ #!/usr/bin/env bash -set -ex - -sed -i -e 's,#PROVIDER_PLACEHOLDER,./guest-agent.nix,' /etc/nixos/configuration.nix -cat << EOF > /etc/nixos/guest-agent.nix -{...}: -{ - virtualisation.vmware.guest = { - enable = true; - headless = false; - }; -} -EOF -chown vagrant:vagrant /etc/nixos/guest-agent.nix -nixos-rebuild switch +set -ex \ No newline at end of file diff --git a/distros/ubuntu/20.04/amd64.pkrvars.hcl b/distros/ubuntu/20.04/amd64.pkrvars.hcl index baeacd6..0472927 100644 --- a/distros/ubuntu/20.04/amd64.pkrvars.hcl +++ b/distros/ubuntu/20.04/amd64.pkrvars.hcl @@ -6,13 +6,13 @@ iso = { } boot_wait = "3s" boot_command = [ - "", + "e", "console=tty0 ", "fsck.mode=skip ", "locale=en_US ", "auto=true ", "priority=critical ", - "autoinstall ds=nocloud" + "autoinstall ds=nocloud" ] cd_files = [ "distros/ubuntu/20.04/disc/*" diff --git a/distros/ubuntu/20.04/disc/user-data b/distros/ubuntu/20.04/disc/user-data index e02cbf8..06c2aa6 100644 --- a/distros/ubuntu/20.04/disc/user-data +++ b/distros/ubuntu/20.04/disc/user-data @@ -28,12 +28,22 @@ autoinstall: allow-pw: yes user-data: disable_root: false - package_update: false # These will be done by Ansible after install + package_update: false package_upgrade: false late-commands: - echo 'Defaults:vagrant !requiretty' > /target/etc/sudoers.d/vagrant - echo 'vagrant ALL=(ALL) NOPASSWD:ALL' >> /target/etc/sudoers.d/vagrant - chmod 440 /target/etc/sudoers.d/vagrant + - >- + curtin in-target --target=/target -- + bash -c 'if [ "$(systemd-detect-virt)" == "microsoft" ]; then + apt-get update; + apt-get install -y linux-azure; + fi' + # There is no efibootmgr in the install CD, so we need in-target to fetch the data first + - |- + TARGET="$(curtin in-target --target=/target -- efibootmgr | grep -i ubuntu | awk '{print $1}' | sed -E 's/[^0-9]//g')" + curtin in-target --target=/target -- efibootmgr --bootnext "${TARGET}" - curtin in-target --target=/target -- logger "finished late-commands" packages: - ca-certificates diff --git a/distros/ubuntu/20.04/finalize.sh b/distros/ubuntu/20.04/finalize.sh index 19345a6..f79a717 100644 --- a/distros/ubuntu/20.04/finalize.sh +++ b/distros/ubuntu/20.04/finalize.sh @@ -6,9 +6,6 @@ apt remove cloud-init -y apt update apt upgrade -y -# Do some magic with init -sed -i -E -e 's,^(ACTIVE_CONSOLES="/dev/tty).*",\11,' /etc/default/console-setup - # Make sshd faster cat << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf UseDNS no diff --git a/distros/ubuntu/22.04/amd64.pkrvars.hcl b/distros/ubuntu/22.04/amd64.pkrvars.hcl index c4f4049..a15717d 100644 --- a/distros/ubuntu/22.04/amd64.pkrvars.hcl +++ b/distros/ubuntu/22.04/amd64.pkrvars.hcl @@ -6,12 +6,12 @@ iso = { } boot_command = [ "e", - "console=tty0 ", - "fsck.mode=skip ", - "locale=en_US ", - "auto=true ", - "priority=critical ", - "autoinstall", + "console=tty0 ", + "fsck.mode=skip ", + "locale=en_US ", + "auto=true ", + "priority=critical ", + "autoinstall", "", ] cd_files = [ diff --git a/distros/ubuntu/22.04/disc/user-data b/distros/ubuntu/22.04/disc/user-data index 2c5cc4e..06c2aa6 100644 --- a/distros/ubuntu/22.04/disc/user-data +++ b/distros/ubuntu/22.04/disc/user-data @@ -34,6 +34,16 @@ autoinstall: - echo 'Defaults:vagrant !requiretty' > /target/etc/sudoers.d/vagrant - echo 'vagrant ALL=(ALL) NOPASSWD:ALL' >> /target/etc/sudoers.d/vagrant - chmod 440 /target/etc/sudoers.d/vagrant + - >- + curtin in-target --target=/target -- + bash -c 'if [ "$(systemd-detect-virt)" == "microsoft" ]; then + apt-get update; + apt-get install -y linux-azure; + fi' + # There is no efibootmgr in the install CD, so we need in-target to fetch the data first + - |- + TARGET="$(curtin in-target --target=/target -- efibootmgr | grep -i ubuntu | awk '{print $1}' | sed -E 's/[^0-9]//g')" + curtin in-target --target=/target -- efibootmgr --bootnext "${TARGET}" - curtin in-target --target=/target -- logger "finished late-commands" packages: - ca-certificates diff --git a/distros/ubuntu/22.04/finalize.sh b/distros/ubuntu/22.04/finalize.sh index 19345a6..f79a717 100644 --- a/distros/ubuntu/22.04/finalize.sh +++ b/distros/ubuntu/22.04/finalize.sh @@ -6,9 +6,6 @@ apt remove cloud-init -y apt update apt upgrade -y -# Do some magic with init -sed -i -E -e 's,^(ACTIVE_CONSOLES="/dev/tty).*",\11,' /etc/default/console-setup - # Make sshd faster cat << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf UseDNS no diff --git a/distros/ubuntu/23.10/amd64.pkrvars.hcl b/distros/ubuntu/23.10/amd64.pkrvars.hcl index 75ca28f..04f1b55 100644 --- a/distros/ubuntu/23.10/amd64.pkrvars.hcl +++ b/distros/ubuntu/23.10/amd64.pkrvars.hcl @@ -6,12 +6,12 @@ iso = { } boot_command = [ "e", - "console=tty0 ", - "fsck.mode=skip ", - "locale=en_US ", - "auto=true ", - "priority=critical ", - "autoinstall", + "console=tty0 ", + "fsck.mode=skip ", + "locale=en_US ", + "auto=true ", + "priority=critical ", + "autoinstall", "", ] cd_files = [ diff --git a/distros/ubuntu/23.10/disc/user-data b/distros/ubuntu/23.10/disc/user-data index 2c5cc4e..4b96996 100644 --- a/distros/ubuntu/23.10/disc/user-data +++ b/distros/ubuntu/23.10/disc/user-data @@ -34,6 +34,12 @@ autoinstall: - echo 'Defaults:vagrant !requiretty' > /target/etc/sudoers.d/vagrant - echo 'vagrant ALL=(ALL) NOPASSWD:ALL' >> /target/etc/sudoers.d/vagrant - chmod 440 /target/etc/sudoers.d/vagrant + - >- + curtin in-target --target=/target -- + bash -c 'if [ "$(systemd-detect-virt)" == "microsoft" ]; then + apt-get update; + apt-get install -y linux-azure; + fi' - curtin in-target --target=/target -- logger "finished late-commands" packages: - ca-certificates diff --git a/distros/ubuntu/23.10/finalize.sh b/distros/ubuntu/23.10/finalize.sh index 19345a6..f79a717 100644 --- a/distros/ubuntu/23.10/finalize.sh +++ b/distros/ubuntu/23.10/finalize.sh @@ -6,9 +6,6 @@ apt remove cloud-init -y apt update apt upgrade -y -# Do some magic with init -sed -i -E -e 's,^(ACTIVE_CONSOLES="/dev/tty).*",\11,' /etc/default/console-setup - # Make sshd faster cat << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf UseDNS no diff --git a/distros/ubuntu/supports.yml b/distros/ubuntu/supports.yml index b4be4ea..80525fb 100644 --- a/distros/ubuntu/supports.yml +++ b/distros/ubuntu/supports.yml @@ -7,6 +7,7 @@ provider: vmware-iso - arch: amd64 provider: hyperv-iso + # linux-azure package broken in 20.04 22.04: *supp "23.10": *supp #18.04: *supp # EOL diff --git a/sources/build.pkr.hcl b/sources/build.pkr.hcl index d03c3eb..78d6dbf 100644 --- a/sources/build.pkr.hcl +++ b/sources/build.pkr.hcl @@ -68,6 +68,20 @@ build { compression_level = 9 output = "output/{{ .Provider }}/${local.name}.box" vagrantfile_template = "vagrant/${var.arch}.rb" + only = ["qemu.amd64"] + include = [ + "${var.efi_dir}/OVMF_CODE.fd", + "${var.efi_dir}/OVMF_VARS.fd", + "output/libvirt/${local.name}/efivars.fd" + ] + } + + post-processor "vagrant" { + keep_input_artifact = true + compression_level = 9 + output = "output/{{ .Provider }}/${local.name}.box" + vagrantfile_template = "vagrant/${var.arch}.rb" + except = ["qemu.amd64"] } post-processor "vagrant-cloud" { diff --git a/sources/hyperv-iso.pkr.hcl b/sources/hyperv-iso.pkr.hcl index 220e6c5..1d1691d 100644 --- a/sources/hyperv-iso.pkr.hcl +++ b/sources/hyperv-iso.pkr.hcl @@ -11,7 +11,7 @@ source "hyperv-iso" "amd64" { ssh_password = local.ssh.password ssh_handshake_attempts = local.ssh.handshake_attempts ssh_private_key_file = local.ssh.private_key_file - ssh_host = "10.42.2.254" + #ssh_host = "10.42.2.254" vm_name = "packer-${local.name}" disk_size = "${local.disk_size}000" @@ -19,7 +19,8 @@ source "hyperv-iso" "amd64" { memory = local.memory headless = var.headless switch_name = "packer-amd64" - mac_address = "0000deadbeef" + #mac_address = "0000deadbeef" + generation = 2 http_content = var.http_files http_directory = var.http_directory diff --git a/sources/inputs.pkr.hcl b/sources/inputs.pkr.hcl index 5e9c317..68300c4 100644 --- a/sources/inputs.pkr.hcl +++ b/sources/inputs.pkr.hcl @@ -99,6 +99,11 @@ variable "memory" { default = 8192 } +variable "efi_dir" { + type = string + default = env("EFI_DIR") +} + locals { name = "${var.distro}-${var.version}" description = templatefile("../README.box.md", { diff --git a/sources/qemu.pkr.hcl b/sources/qemu.pkr.hcl index f1d482a..ec70ccc 100644 --- a/sources/qemu.pkr.hcl +++ b/sources/qemu.pkr.hcl @@ -25,6 +25,9 @@ source "qemu" "amd64" { disk_cache = "writeback" format = "qcow2" cpu_model = var.cpu_model + efi_boot = true + efi_firmware_code = "${var.efi_dir}OVMF_CODE.fd" + efi_firmware_vars = "${var.efi_dir}OVMF_VARS.fd" qemuargs = [ #["-chardev", "stdio,id=char0,logfile=serial-output-qemu-${var.arch}-${var.distro}-${var.version},signal=off"], diff --git a/sources/virtualbox-iso.pkr.hcl b/sources/virtualbox-iso.pkr.hcl index cdd8133..eefa28c 100644 --- a/sources/virtualbox-iso.pkr.hcl +++ b/sources/virtualbox-iso.pkr.hcl @@ -18,6 +18,7 @@ source "virtualbox-iso" "amd64" { cpus = local.cpus memory = local.memory headless = var.headless + firmware = "efi" guest_os_type = "Linux_64" guest_additions_url = "http://download.virtualbox.org/virtualbox/7.0.10/VBoxGuestAdditions_7.0.10.iso" guest_additions_sha256 = "bbabd89b8fff38a257bab039a278f0c4dc4426eff6e4238c1db01edb7284186a" diff --git a/test.xsh b/test.xsh index 98d6b7b..64c2e5f 100755 --- a/test.xsh +++ b/test.xsh @@ -58,7 +58,11 @@ def get_parser(args, unsupported=set()): def main(): # Equivalent of `set -e` in Bash - #$RAISE_SUBPROC_ERROR = True + $RAISE_SUBPROC_ERROR = True + if len(sys.argv) == 2: + dry_run = True + else: + dry_run = False for box in g`output/**/*.box`: p = pathlib.Path(box) with open("Vagrantfile.in", "r") as fr: @@ -67,16 +71,17 @@ def main(): content = content.replace("@@BOX_NAME@@", p.name) with open("Vagrantfile", "w") as fw: fw.write(content) - vagrant box add @(box) --name @(p.name) - if str(p.parent.name) in ["virtualbox", "libvirt", "vmware", "hyperv"]: - vagrant up --provider @(p.parent.name) - else: - print(f"Now whatcha wanna go and do that for? {box}") - continue - vagrant destroy -f - vag_folder = pathlib.Path(".vagrant") - if vag_folder.exists(): - rmtree(vag_folder) + if not dry_run: + vagrant box add @(box) --name @(p.name) --force + if str(p.parent.name) in ["virtualbox", "libvirt", "vmware", "hyperv"]: + vagrant up --provider @(p.parent.name) + else: + print(f"Now whatcha wanna go and do that for? {box}") + continue + vagrant destroy -f + vag_folder = pathlib.Path(".vagrant") + if vag_folder.exists(): + rmtree(vag_folder) if __name__ == '__main__': diff --git a/vagrant/amd64.rb b/vagrant/amd64.rb index 2bdde38..4bcc976 100644 --- a/vagrant/amd64.rb +++ b/vagrant/amd64.rb @@ -1,13 +1,13 @@ Vagrant.configure('2') do |c| - c.vm.synced_folder ".", "/vagrant", type: "rsync" # Set some basic overrides c.vm.provider :libvirt do |v, override| v.driver = 'kvm' v.connect_via_ssh = false - #v.username = 'root' v.memory = 2048 # QEmu Guest Agent channel v.qemu_use_agent = true + v.loader = File.join(__dir__, 'OVMF_CODE.fd') + v.nvram = File.join(__dir__, 'efivars.fd') end c.vm.provider :virtualbox do |v| v.gui = false