From e5a24b3078a4d70b9e5775fe8e39ce1cfedfc848 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 20 Aug 2022 18:45:13 +0200 Subject: [PATCH] cleanup --- .github/workflows/build-image.yml | 41 ++ .github/workflows/docker-build-basic.yml | 25 ++ .github/workflows/docker-build-kaniko.yml | 26 ++ .gitignore | 1 + Dockerfile | 14 + LICENSE | 21 + README.md | 164 ++++++++ image-create.sh | 443 ++++++++++++++++++++++ liveiso.drawio.svg | 279 ++++++++++++++ user-data.example | 86 +++++ 10 files changed, 1100 insertions(+) create mode 100644 .github/workflows/build-image.yml create mode 100644 .github/workflows/docker-build-basic.yml create mode 100644 .github/workflows/docker-build-kaniko.yml create mode 100644 .gitignore create mode 100755 Dockerfile create mode 100755 LICENSE create mode 100755 README.md create mode 100755 image-create.sh create mode 100755 liveiso.drawio.svg create mode 100755 user-data.example diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml new file mode 100644 index 0000000..273a9d7 --- /dev/null +++ b/.github/workflows/build-image.yml @@ -0,0 +1,41 @@ +name: Build Image Iso + +on: + push: + branches: [ "main" ] + tags: + - "v*.*.*" + +jobs: + build-image: + runs-on: ubuntu-latest + container: deserializeme/pxeless:latest + + steps: + - uses: actions/checkout@v3 + + - name: Build Iso + run: | + ./image-create.sh -a -u user-data.example -n jammy -k + ls -hal + + - name: version + run: echo "::set-output name=version::$(date)" + id: version + + - name: release + uses: actions/create-release@v1 + id: create_release + with: + draft: false + prerelease: false + release_name: ${{ steps.version.outputs.version }} + tag_name: ${{ github.ref }} + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: upload linux artifact + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: ubuntu-autoinstall.iso diff --git a/.github/workflows/docker-build-basic.yml b/.github/workflows/docker-build-basic.yml new file mode 100644 index 0000000..13ef1da --- /dev/null +++ b/.github/workflows/docker-build-basic.yml @@ -0,0 +1,25 @@ +name: basic build + +on: + push: + branches: [ "main" ] + +jobs: + build-basic: + runs-on: ubuntu-latest + + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v3 + + - name: Build the latest Docker image + run: docker build . --file Dockerfile --tag deserializeme/pxeless:latest + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Push the latest Docker image + run: docker push deserializeme/pxeless:latest diff --git a/.github/workflows/docker-build-kaniko.yml b/.github/workflows/docker-build-kaniko.yml new file mode 100644 index 0000000..d65e2e6 --- /dev/null +++ b/.github/workflows/docker-build-kaniko.yml @@ -0,0 +1,26 @@ +name: build-kaniko + +on: + push: + branches: [ "main" ] + +jobs: + build-kaniko: + runs-on: ubuntu-latest + + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - uses: int128/kaniko-action@v1 + with: + push: true + tags: deserializeme/pxeless:kaniko + labels: ${{ steps.metadata.outputs.labels }} + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..69f67bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +virtual-machines/qumu/testvm \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100755 index 0000000..5e9439b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM ubuntu:latest + +RUN apt-get -y update && \ + apt-get -y install xorriso sed curl gpg wget fdisk isolinux && \ + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys && \ + apt-get -y autoremove && \ + apt-get -y clean && \ + rm -rf /var/lib/apt/lists/* && \ + mkdir /root/.gnupg && \ + chmod 600 /root/.gnupg + +WORKDIR /app + +ENTRYPOINT [ "/bin/bash" ] \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100755 index 0000000..8b49d8d --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020/2022 covertsh, cloudymax + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100755 index 0000000..f80630c --- /dev/null +++ b/README.md @@ -0,0 +1,164 @@ +# Image Creator + +Based on [covertsh/ubuntu-autoinstall-generator](https://github.com/covertsh/ubuntu-autoinstall-generator), which generates a customized, fully-automated ISO image for installing Ubuntu onto a machine without human interaction using [cloud-init](https://cloudinit.readthedocs.io/en/latest/) and the new **autoinstall** feature of Ubuntu's Ubiquity installer. + +This spin-off project adds support for [eltorito + GPT images required for Ubuntu 20.10 and newer](https://askubuntu.com/questions/1289400/remaster-installation-image-for-ubuntu-20-10). It also keeps support for the [now depricated isolinux + MBR](https://archive.org/details/ubuntukylin2104-201214-daily) image type. In addition, the process is dockerized to make it possible to run on Mac/Windows hosts in addition to Linux. + +## Behavior + + - Find an unmodified Ubuntu ISO image, + - Download it, + - Extract it, + - Add some kernel command line parameters, + - Add our custom cloud-init config, + - Repack the data into a new ISO. + - Create a bootable USB drive (Optional) + + + + + +## How it works + +First we download the ISO of your choice - a daily build, or a release. (Daily builds are faster because they don't require as many updates/upgrades) + +By default, the source ISO image is checked for integrity and authenticity using GPG. This can be disabled with ```-k```. + +We combine an `autoistall` config from the Ubuntu [Ubiquity installer](https://wiki.ubuntu.com/Ubiquity), and a [cloud-init](https://cloudinit.readthedocs.io/en/latest/) `cloud-config` / `user-data` file. + +The resulting product is a fully-automated Ubuntu install with pre-provision capabilities for basic users, groups, packages, storage, networks etc... This serves as an easy stepping-off point to Ansible, puppet, Chef and other configuration-management tooling for enterprise users, or to personalization tools like [jessebot/onboardme](https://github.com/jessebot/onboardme) for every-day users. + +> Be aware that, while similar in schema, the Autoinstall and Cloud-Init portions of the file do not mix - the `user-data` value on line 44 marks the transition from autoinstall to cloud-init syntax. + +## References + +- Autoinstall configuration options and schema can be found [HERE](https://ubuntu.com/server/docs/install/autoinstall-reference). + +- Cloud-Init options and examples may be found [HERE](https://cloudinit.readthedocs.io/en/latest/index.html) + +- You can also refer to the provided example file [HERE](image-creator/user-data.example) + +## **Usage** + +- Build a combined `autoinstall` + `cloud-init` image by using the ```-a``` flag and providing a **user-data** file containing the autoinstall configuration and cloud-init data. +A **meta-data** file may be included if you choose. The file will be empty if it is not specified. You may read more about providing a `meta-data` file [HERE](https://cloudinit.readthedocs.io/en/latest/topics/instancedata.html) + +- With an 'all-in-one' ISO, you simply boot a machine using the ISO and the installer will do the rest. + +- This script can use an existing ISO image or download the latest daily image from the Ubuntu project. +Using a fresh ISO speeds things up because there won't be as many packages to update during the installation. + +- By default, the source ISO image is checked for integrity and authenticity using GPG. This can be disabled with `-k`. + +```bash +docker build -t iso-generator . && \ +docker run -it --mount type=bind,source="$(pwd)",target=/app iso-generator \ +ubuntu-autoinstall-generator.sh -a -u user-data.example -n jammy +``` + +## Command-line options +``` +Usage: ubuntu-autoinstall-generator.sh [-h] [-v] [-a] [-e] [-u user-data-file] [-m meta-data-file] [-k] [-c] [-r] [-s source-iso-file] [-d destination-iso-file] + +💁 This script will create fully-automated Ubuntu installation media. + +Available options: + +-h, --help Print this help and exit + +-v, --verbose Print script debug info + +-n, --code-name The Code Name of the Ubuntu release to download (bionic, focal, jammy etc...) + +-a, --all-in-one Bake user-data and meta-data into the generated ISO. By default you will + need to boot systems with a CIDATA volume attached containing your + autoinstall user-data and meta-data files. + For more information see: https://ubuntu.com/server/docs/install/autoinstall-quickstart + +-e, --use-hwe-kernel Force the generated ISO to boot using the hardware enablement (HWE) kernel. Not supported + by early Ubuntu 20.04 release ISOs. + +-u, --user-data Path to user-data file. Required if using -a + +-m, --meta-data Path to meta-data file. Will be an empty file if not specified and using -a + +-k, --no-verify Disable GPG verification of the source ISO file. By default SHA256SUMS- and + SHA256SUMS-.gpg files in the script directory will be used to verify the authenticity and integrity + of the source ISO file. If they are not present the latest daily SHA256SUMS will be + downloaded and saved in the script directory. The Ubuntu signing key will be downloaded and + saved in a new keyring in the script directory. + +-r, --use-release-iso Use the current release ISO instead of the daily ISO. The file will be used if it already + exists. + +-s, --source Source ISO file. By default the latest daily ISO for Ubuntu 20.04 will be downloaded + and saved as