Skip to content

Commit

Permalink
BREAKING CHANGE: migration to python3 and support for Ubuntu 20.04 (#35)
Browse files Browse the repository at this point in the history
* feat!: migration to python3 and support for Ubuntu 20.04

BREAKING CHANGE: iso build config variables had to be changed for python!

* fix: typos and leftover
  • Loading branch information
fadnincx authored Feb 14, 2023
1 parent 46bdbce commit 1345024
Show file tree
Hide file tree
Showing 15 changed files with 457 additions and 172 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.iso
*.swp
*.swp
*.iso.sha256sum
97 changes: 9 additions & 88 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,92 +1,13 @@
# Potos iso building

To create your own Linux Client based on Potos, you need to create a [config](config) directory according to the scaffolding in this repo (and the explanation in section [Config](#Config)). To build the iso yourself, you can choose between one of the following possibilities:
* [Plain Docker](#Build iso - Docker plain)
* [Docker Compose](#Build iso - Docker compose)
## Structure
This repo contains the iso builder for Potos.
* [`container`](container) contains the source for the docker image `ghcr.io/projectpotos/potos-iso-builder`
* [`config`](container) contains an example config
* [`output`](output) is the directory where using the default commands the final iso is stored into

## Build iso - Docker plain

1. Clone this repository with `git clone` or download & unzip it.
2. Adjust the files in [`config`](./config) to your client
3. Run `docker run -it -v $(pwd)/config:/config -v $(pwd)/output:/output ghcr.io/projectpotos/potos-iso-builder:latest`

## Build iso - Docker compose

1. Clone this repository with `git clone` or download & unzip it.
2. Adjust the files in [`config`](./config) to your client
3. Run `docker-compose up` in the main directory

## Build iso - Github Workflow
1. Create a new repo containing the `config` directory adjusted for your client
2. Create the following file as workflow file under `.github/workflows/isobuild.yml`
```
name: Build Iso
on:
workflow_dispatch:
pull_request:
jobs:
build:
name: Build Iso
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Run the build process with Docker
uses: addnab/docker-run-action@v3
with:
image: ghcr.io/projectpotos/potos-iso-builder:latest
run: ./build-iso
options: -v ${{ github.workspace }}:/config -v /output:/output
- name: Save iso
uses: actions/upload-artifact@v3
with:
name: potos-iso
path: /output/*.iso
retention-days: 1
```

## Build your own container image

If you wnat to build the build container image yourself, all the container relevant files are in [`container`](./container)
1. Execute `docker build container/` to build the container
2. Execute `docker build container/ -t iso-build` to build the container and assign a tag

Then to build the client, adjust the image to be used in the commands above.

## Config

### logo.png
Place your client logo in this file, if you want some customization during the setup dialogs

### config.yml
The iso build is configured using [YAML](https://en.wikipedia.org/wiki/YAML) based `config.yml` file. The file has to be located within the configuration directory mounted as volume into the build container.

> **CONVENTION**
> The *dot-notation* of a config-key like `client_name.long` means `long` property within the `client_name` section. All *dot-notation* references are absolut.
| Variable | Type | Default | Comment |
|---|---|---|---|
| client_name.long | *string* | Potos Linux Client | Define the Name of your Linux Client, e.g. "My Linux Client". |
| client_name.short | *string, lowercase, short, regex `^([0-9a-z]{1,32})$`* | potos | Define a short name of your Linux Client. Use lowercase. Will be used for example for the log folder /var/log/$POTOS_CLIENT_SHORTNAME |
| disk_encryption.enable | *boolean --> `true`\|`false`* | false | To enable autoinstall feature with disk encryption (except: /boot). You have to enter the defined password at first boot after the installation. |
| disk_encryption.init_password | *string* | install | The autoinstall feature with disk encryption (except: /boot) needs a predefined decryption password. You have to enter this password at first boot after the installation. |
| specs.url | *string, URL, trailing slash* | https://github.com/projectpotos/ | The URL to your Git Account that holds your own Potos Specs Repository. Make sure you have the trailing slash included. |
| specs.repo | *string, part of the URL* | ansible-specs-potos | The name of your own Potos Git Specs Repository, without *.git* at the End. |
| specs.branch | *string* | main | Define the branch of your specs.repo. Typical values are `main`, `master`, `develop` |
| initial_hostname | *string* | potoshostname01 | Your Linux Client based on Potos will use this predefined hostname at the installation and first boot. |
| initial_user.username | *string* | admin | An initial username is required. Will have full sudo (root) permission. Can be removed later on. |
| initial_user.password | *string* | admin *hashed* | The password in form of a hash. Create your own with `echo -n yourpasswordhere \| mkpasswd --method=SHA-512 --stdin` . |
| environment | *string* | production | Possible values are `production` and `develop`. The installation in `develop` mode is more verbose. |
| first_boot_ansible.runtype | *string* | setup | Run type of the first ansible run |
| full_unattended_install | *boolean --> `true`\|`false`* | false | Disable security question before overwrite of disk and user input from iso side to allow a fully unattended installation |
| input.iso_filename | *string* | ubuntu-22.04.1-live-server-amd64.iso | Name of the local iso file (needs to correspond with content of the SHA256SUMS file) |
| input.iso_url | *string* | https://releases.ubuntu.com/22.04/ubuntu-22.04.1-live-server-amd64.iso | Where to download the iso file if it doesn't exist locally |
| input.sha256_filename | *string* | SHA256SUMS | Name of the SHA256SUMS file |
| input.sha256_url | *string* | https://releases.ubuntu.com/22.04/SHA256SUMS | Where to download the SHA256SUMS file if it doesn't exist locally |
| output.version | *string* | current date in yyyymmddd | What string should be used as Version identifier |
| output.filename | *string* | `client_name.short`-installer-`environment`.iso | How the iso in the output directory should be named |
| preinstall_packages | *list of strings* | - python3-virtualenv<br> - linux-generic-hwe-22.04<br> - ubuntu-desktop<br> - plymouth-theme-ubuntu-logo<br> - ldap-utils<br> - yad | What packages should be installed with autoinstall. * `python3-virtualenv`: python with virtualenv is required to install ansible within it * `linux-generic-hwe-22.04`: install hwe kernel * `ubuntu-desktop`: install gnome desktop * `plymouth-theme-ubuntu-logo`: install plymouth-theme * `ldap-utils`: ldap utils used for all the ldap integration things * `yad`: used for graphical dialogs during setup |

# Potos iso installation

Boot from the previously generated Potos .iso image in your virtual or physical hardware and follow the instruction. The client is entirely defined by the `specs` repo,
# Documentation
To see the entire documentation go to [potos.dev](https://potos.dev)
* [How to build an ISO](https://potos.dev/guide/iso-build/how-to-build.html)
* [ISO build config](https://potos.dev/guide/iso-build/config.html)
15 changes: 2 additions & 13 deletions config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,7 @@ environment: "production"
first_boot_ansible:
runtype: "setup"
full_unattended_install: false
input:
iso_filename: "ubuntu-22.04.1-live-server-amd64.iso"
iso_url: "https://releases.ubuntu.com/22.04/ubuntu-22.04.1-live-server-amd64.iso"
iso_sha256_filename: "SHA256SUMS"
iso_sha256_url: "https://releases.ubuntu.com/22.04/SHA256SUMS"
os: "jammy"
output:
version: "22.04"
version: "%Y%m%d"
iso_filename: "potos-installer.iso"
preinstall_packages:
- python3-virtualenv
- linux-generic-hwe-22.04
- ubuntu-desktop
- plymouth-theme-ubuntu-logo
- ldap-utils
- yad
8 changes: 4 additions & 4 deletions container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ FROM ubuntu:22.04
WORKDIR /potos-iso

# Install ISO creation depencies
RUN apt update && apt install -y gfxboot p7zip-full xorriso wget curl libhtml-parser-perl cpio whois python3 python3-pip fdisk
RUN pip3 install j2cli
RUN wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 && chmod +x /usr/local/bin/yq
RUN apt update && apt install -y gfxboot p7zip-full xorriso wget curl libhtml-parser-perl cpio whois python3 python3-pip fdisk squashfs-tools
COPY requirements.txt .
RUN pip3 install -r requirements.txt

# Create config directory
RUN mkdir /config

ADD . /potos-iso

CMD ["./build-iso"]
CMD ["/usr/bin/python3", "build-iso.py"]
17 changes: 8 additions & 9 deletions container/autoinstall-user-data.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ autoinstall:
- arches: [default]
uri: "http://archive.ubuntu.com/ubuntu"
identity:
hostname: {{ POTOS_INITIAL_HOSTNAME | default('potoshostname01') }}
password: {{ POTOS_INITIAL_PASSWORD_HASH | default('$6$L36BiUuVCSipvlO8$oGI0C.LXZegkbftFkVDXXaasTM6zs9LM71BkqZToKw5aOZ7Yr70pkzH3P9Xz5R.n0ULJ0Zf8v5ZQ/eH8flDR7/') }}
username: {{ POTOS_INITIAL_USERNAME | default('admin') }}
hostname: {{ config['initial_hostname'] | default('potoshostname01') }}
password: {{ config['initial_user']['password'] | default('$6$L36BiUuVCSipvlO8$oGI0C.LXZegkbftFkVDXXaasTM6zs9LM71BkqZToKw5aOZ7Yr70pkzH3P9Xz5R.n0ULJ0Zf8v5ZQ/eH8flDR7/') }}
username: {{ config['initial_user']['username'] | default('admin') }}
ssh:
allow-pw: true
authorized-keys: []
Expand Down Expand Up @@ -53,7 +53,7 @@ autoinstall:
size: 1GB
preserve: false
number: 2
{% if POTOS_DISK_ENCRYPTION_ENABLE is defined and POTOS_DISK_ENCRYPTION_ENABLE == 'true' %}
{% if config['disk_encryption']['enable'] is defined and config['disk_encryption']['enable'] == 'true' %}
- id: partition_crypt
type: partition
device: disk_primary
Expand All @@ -62,7 +62,7 @@ autoinstall:
number: 3
- id: dm-crypt_0
volume: partition_crypt
key: {{ POTOS_DISK_ENCRYPTION_INITIAL_PASSWORD | default('install') }}
key: {{ config['disk_encryption']['init_password'] | default('install') }}
preserve: false
type: dm_crypt
- id: lvm_volgroup_0
Expand Down Expand Up @@ -132,8 +132,7 @@ autoinstall:
path: /
type: mount
packages:
{% set packages = POTOS_PRE_INSTALL_PACKAGES.split('\n') %}
{% for package in packages %}
{% for package in config['packages']['preinstall'] %}
- {{ package }}
{% endfor %}
late-commands:
Expand All @@ -150,10 +149,10 @@ autoinstall:
- cp /cdrom/setup/default-netplan.yml /target/etc/netplan/01-network-manager-all.yaml
- cp /cdrom/setup/gnome-sudo /target/etc/sudoers.d/01_gnome-initial-setup
- mkdir -p /target/etc/potos/ && chown 0:0 /target/etc/potos/ && chmod 0700 /target/etc/potos/
{% if POTOS_GIT_SPECS_SSH_KEY != "" %}
{% if config['specs']['ssh_key'] != "" %}
- cp /cdrom/setup/specs_key /target/etc/potos/specs_key && chown 0:0 /target/etc/potos/specs_key && chmod 0400 /target/etc/potos/specs_key
{% endif %}
{% if POTOS_GIT_SPECS_ANSIBLE_VAULT != "" %}
{% if config['specs']['ansible_vault_key_file'] != "" %}
- cp /cdrom/setup/ansible_vault_key /target/etc/potos/ansible_vault_key && chown 0:0 /target/etc/potos/ansible_vault_key && chmod 0500 /target/etc/potos/ansible_vault_key
{% endif %}
- cp -r /cdrom/setup /target/setup
Expand Down
Loading

0 comments on commit 1345024

Please sign in to comment.