Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
eeeb44a
init
May 15, 2025
3eb1719
updated and refactored power into power.go
May 15, 2025
e2ee94e
archived python
May 15, 2025
78aa1b5
bazinga
May 15, 2025
939f55b
minor shimmy
May 15, 2025
0cf095f
bazinga
May 15, 2025
449793e
minor bazinga refactor
May 15, 2025
224c10f
created API docs
May 15, 2025
9ad3362
Added API Docs in TOC
May 15, 2025
6d39239
Containerised controller
May 15, 2025
27f1503
Create Server struct with power helper methods
NoSpawnn May 16, 2025
351ec4f
Rename Server.GetPower() -> Server.GetPowerState()
NoSpawnn May 16, 2025
c1709f0
enforced consistent naming in server.go
May 16, 2025
58829b5
Added an example command to use the newly added environment variables
May 16, 2025
21c87ca
Added environment variable handling and replaced the values used for
May 16, 2025
f181d4a
Merge pull request #3 from KarmaComputing/#1-get-server-variables-fro…
denis-dysen May 16, 2025
b823560
Delete archive directory
denis-dysen May 16, 2025
883158a
Removed power endpoints as they have been removed
denis-dysen May 16, 2025
7847c63
fixed reboot loop's timing
May 16, 2025
9ac7f79
Merge branch 'main' of github.com:KarmaComputing/server-bootstrap-ncl
May 16, 2025
bdc71a8
Refactor environment variable retrieval
NoSpawnn May 17, 2025
1065fc6
Obvious refactor...
NoSpawnn May 17, 2025
ec4fd4e
Rename allowValidCert -> validCertOnly
NoSpawnn May 17, 2025
9ac77ac
Rename Server -> LOM
NoSpawnn May 18, 2025
aeba561
Shimmy folder structure and being basic bootstrap impl
NoSpawnn May 18, 2025
038ac1f
Ignore `ipxe` folder
NoSpawnn May 19, 2025
5d7cc3d
Restart -> override boot to iPXE
NoSpawnn May 19, 2025
a21711f
diagram!
May 19, 2025
c4f2b90
deleted accidental readme
May 19, 2025
8cc0d55
ignoring www
May 19, 2025
bd38d9f
created ssh keypair
May 19, 2025
904430f
Barebones containerfile for apache web server
May 19, 2025
8a2d7f6
ipxe Containerfile and embedded config
May 19, 2025
830ae12
deployment compose
May 19, 2025
00d0dca
move builders to build, minimise apache containerfile, written build.sh
May 19, 2025
5e394d4
documented how to build and deploy the project
May 19, 2025
bc9fda8
moved SSH keys to build
May 19, 2025
f608d39
added copying SSH key and using ENV variable for which input file to use
May 19, 2025
21cb899
Moved go controller's Containerfile into its directory since /container
May 19, 2025
e953372
Boot into iPXE alpine
NoSpawnn May 19, 2025
91aa0e0
Refactor into directories and fix ISO builder
NoSpawnn May 20, 2025
dbdf12a
Alpine builder container
NoSpawnn May 20, 2025
36b9df6
Move files
NoSpawnn May 20, 2025
6647f0c
Add vm-test
NoSpawnn May 20, 2025
fcde1d3
Fixe permission issue with alpine build script
NoSpawnn May 20, 2025
2c836dd
Update vm-test.ipxe
NoSpawnn May 20, 2025
d5fbe55
Rename folders
NoSpawnn May 20, 2025
833a2d7
Fix path typo
NoSpawnn May 20, 2025
5224b6e
Update port
NoSpawnn May 20, 2025
72657f9
Update README.md
NoSpawnn May 20, 2025
77c7c7e
Merge pull request #4 from KarmaComputing/improving-deployment
NoSpawnn May 20, 2025
b8c49fb
Fix typo
NoSpawnn May 20, 2025
9b498e5
Update README.md
NoSpawnn May 20, 2025
8044265
Fix boot! :D
NoSpawnn May 20, 2025
d02dc61
Add SSH keys
NoSpawnn May 20, 2025
583a876
Delete web-server.sh
NoSpawnn May 20, 2025
0975f32
Ignore generated ssh keys
NoSpawnn May 20, 2025
eed481a
Automatic SSH key generation
NoSpawnn May 20, 2025
4cad04d
Merge branch 'multiple-lom-systems-bootstrap'
NoSpawnn May 20, 2025
1aaa82c
Create Containerfile
NoSpawnn May 20, 2025
85d7ebe
Update .gitignore
NoSpawnn May 20, 2025
4d7bf3a
Theoretical SSH access success
NoSpawnn May 20, 2025
6cfd948
Fix typo
NoSpawnn May 20, 2025
77b0b91
Ensure scripts always run in the correct directory
NoSpawnn May 20, 2025
9f8b353
Automatically move private ssh go to internal/runner (TEMP)
NoSpawnn May 20, 2025
bb1cb26
Simple ansible playbook test
NoSpawnn May 20, 2025
678bbce
Further ansible testing
NoSpawnn May 21, 2025
ef60f3d
Update README.md
NoSpawnn May 21, 2025
824a62e
Refactor folder structure for compose
NoSpawnn May 21, 2025
1a1cc7a
Create feature_request.md issue template
chrisjsimpson May 22, 2025
c6cd1a8
Create git-auto-issue-branch-creation.yml
chrisjsimpson May 22, 2025
d1dc9ce
fix #7 example auto close
chrisjsimpson May 22, 2025
206f747
gitignore for repo
May 22, 2025
d8ea598
mirror script excluding everything until v3.11
May 22, 2025
d36b407
Adjusted container to embed the crontab and script. Also now excluding
May 22, 2025
06371cc
Delete mirror.sh
May 22, 2025
e007636
re-did crontabbing to allow for flexible timing
May 22, 2025
c8da002
fix #10 - add final README covering the topic
May 22, 2025
17b4eb8
Add compose environment variables
NoSpawnn May 22, 2025
1d6c411
Enable PING, IPv6, and HTTPS
NoSpawnn May 22, 2025
18e64e2
Bootstrap testing
NoSpawnn May 22, 2025
2f37d1a
Use `chain`
NoSpawnn May 22, 2025
72c3c6d
Remove `--no-cache` from `podman build`
NoSpawnn May 22, 2025
3d0c6e3
Fix SSH key generation
NoSpawnn May 22, 2025
cfc8a0f
Adjusted compose to use consistent names for docs
May 23, 2025
0d8e177
Added docs about manually triggering alpine mirro syncs
May 23, 2025
1aa6379
Added helpful echos and removed unnecessary comment
May 23, 2025
f1de7bd
Add `echo`s and include `uuid` in `chain` call
NoSpawnn May 23, 2025
00b4cab
Un-ignore `bootfile`
NoSpawnn May 23, 2025
b05e8b9
Merge pull request #12 from KarmaComputing/multiple-lom-systems-boots…
NoSpawnn May 23, 2025
1237b3a
Update alpine-mirror README
NoSpawnn May 23, 2025
6d2bf3a
Update bootfile (theoritcally, this is functional)
NoSpawnn May 23, 2025
b9d7635
Update README.md
NoSpawnn May 23, 2025
5053e76
Update bootfile
NoSpawnn May 23, 2025
7bc38e9
Update README.md
NoSpawnn May 23, 2025
37a6709
Update README.md
NoSpawnn May 23, 2025
46ec636
Update README.md
NoSpawnn May 23, 2025
56e2c67
Fix bootfile Alpine variables
NoSpawnn May 24, 2025
433dbd8
Actually fix alpine boot variables
NoSpawnn May 24, 2025
3c0ba37
Add certs to ipxe build
NoSpawnn May 24, 2025
36b3a85
Add certs to ipxe build
NoSpawnn May 24, 2025
bac5333
`set -exu` for scripts
NoSpawnn May 28, 2025
d4aec4c
Confirmed working bootfile
NoSpawnn May 28, 2025
beb259e
Add testing instructions for Alpine mirror setup
May 28, 2025
740dfc5
Update git-auto-issue-branch-creation.yml
chrisjsimpson May 29, 2025
082c4f2
Ref #15 there are no api/README.md. delete it
chrisjsimpson May 29, 2025
92ecc4a
wip #15 tidy README.md
chrisjsimpson May 29, 2025
5c13d02
Fix / improve #15
chrisjsimpson May 29, 2025
fea63ce
TOC => Table of Contents
chrisjsimpson May 29, 2025
3359944
Fix 403 forbidden when attempting to create a PR
NoSpawnn May 29, 2025
664324c
Remove test `hello.sh` script
NoSpawnn May 29, 2025
3ca5f49
Add reference to karmacomputing Alpine Mirror
NoSpawnn May 29, 2025
207da9f
wip #20 https://github.com/KarmaComputing/server-bootstrap-ncl/issues/20
chrisjsimpson May 29, 2025
72504c1
wip Fix #27 recieve bootstrap-ncl repo
chrisjsimpson May 29, 2025
4107b87
Merge remote-tracking branch 'old_origin/20-merge-karmacomputingserve…
chrisjsimpson May 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .github/workflows/git-auto-issue-branch-creation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
jobs:
create-issue-branch:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
issues: write
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -22,7 +26,7 @@ jobs:
# Given an issue title: "Fix the 2'nd bug in UI where there's a # in the form"
# Becomes:
#
# Note there is a space here, to keep both '-' and spaces ' '
# Note there is a space here, to keep both '-' and spaces ' '
echo ISSUE_BRANCH_NAME=`echo "${{ github.event.issue.title }}" | \
# Remove non alpha/numeric chars
tr -cd '[:alnum:]- ' | \
Expand All @@ -41,3 +45,12 @@ jobs:
git checkout -b "${{ steps.issue.outputs.number }}-${{ env.ISSUE_BRANCH_NAME }}"
git push -u origin HEAD

- name: Creating PR based on branch name ${{ github.ref_name }}
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/Subscribie/subscribie/pulls \
-d '{"title": "#${{ steps.issue.outputs.number }} ${{ env.ISSUE_BRANCH_NAME }}","body":"Pull request related issue: #${{ steps.issue.outputs.number }}. Please pull these awesome changes in!","head":"${{ steps.issue.outputs.number }}-${{ env.ISSUE_BRANCH_NAME }}","base":"master"}'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ node_modules
test-results/
playwright-report/
playwright/.cache/
key*
deploy/serve/www/*
!deploy/serve/www/bootfile
Empty file.
50 changes: 50 additions & 0 deletions repo-server-bootstrap-ncl-issue-20/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Overview

> [!NOTE]
> This repo & docs is very much in flux.
> For project purpose see [Server Bootstrap Project Concise project summary & deliverables](https://docs.google.com/document/d/15YR0hAkHfq8g_2rFzpKjpKf1mytyygREyR7a1ZWfzhE/edit?usp=sharing)
> For background reading also see [https://github.com/KarmaComputing/server-bootstrap](https://github.com/KarmaComputing/server-bootstrap)

![diagram](docs/diagram.drawio.png)


## Table of contents

- [Alpine Mirroring](./deploy/alpine-mirror/README.md)



## Run for debugging

- In `internal/runner`

```sh
URL=https://192.168.0.230 USERNAME=Administrator PASSWORD=A0F7HKUU VALIDCERT=false WIPEINTERVAL=300 go run .
```

## Full deploy

1. Build
- Building ipxe.iso image
- Use new/existing iPXE config file in `deploy/build/ipxe/scripts`
- Input its name as FILE variable in `deploy/scripts/build-ipxe-iso.sh`
- Run `deploy/scripts/build-ipxe-iso.sh`
- `ipxe.iso` is placed in `deploy/serve/www`
- Building alpine-netboot image
- Run `deploy/scripts/build-alpine.sh`
- Files are placed in `deploy/serve/www/iso`
- SSH keys
- An SSH keypair is automatically generated upon building an `ipxe.iso` image with the above command
- The **private** key is placed at `deploy/ssh/key`
- The **public** key is placed at `deploy/serve/www/ssh/key.pub`
- Up **re**building the `ipxe.iso`, the script will prompt to replace these keys or not

2. Run stack
- Ensure the files are correctly placed from step 1
- `podman compose up -d` in repository root

3. !! VM FOR TESTING !!
- Ensure `qemu` is installed and runnable
- Ensure web server is accessible at whatever address is defined in the iPXE boot script
- `qemu-system-x86_64 -cdrom <ipxe.iso> -net nic -net user,hostfwd=tcp::2223-:22 -m 3072 -smp $(nproc)`
- VM can be accessed over SSH at `localhost:2223`
21 changes: 21 additions & 0 deletions repo-server-bootstrap-ncl-issue-20/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:
controller:
build: ./internal/runner
# ports:
# - 8081:8080
volumes:
- ./deploy/ssh/key:/app/key:z
- ./deploy/ansible:/app/ansible:z
environment:
- LC_ALL=en_US.UTF-8
- USERNAME=Administrator
- PASSWORD=A0F7HKUU
- URL=https://192.168.0.230
- VALIDCERT=false
- WIPEINTERVAL=300
apache:
build: ./deploy/serve
volumes:
- ./deploy/serve/www:/usr/local/apache2/htdocs:z
ports:
- 8080:80
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM docker.io/library/alpine:3.20

RUN apk add rsync

COPY ./synchroniser /app
RUN cat /app/crontab >> /etc/crontabs/root

RUN chmod +x /app/mirror.sh

CMD ["crond", "-f"]
23 changes: 23 additions & 0 deletions repo-server-bootstrap-ncl-issue-20/deploy/alpine-mirror/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# How to Use

- Adjust `synchroniser/crontab` for desired schedule of synchronising
- Adjust `synchroniser/mirror.sh` for which repos to exclude, etc.
- The container image must be re-built when `crontab` or `mirror.sh` are changed
- Run by `<podman|docker> compose up`

# Notes

- [Alpine Wiki - How to setup a Mirror](https://wiki.alpinelinux.org/wiki/How_to_setup_a_Alpine_Linux_mirror)
- You can trigger the syncs manually via
- `<podman|docker> exec -it alpine-mirror-sync /app/mirror.sh`

# How I've Tested It

1. `git clone [email protected]:KarmaComputing/server-bootstrap-ncl.git`
2. `cd server-bootstrap-ncl/deploy/alpine-mirror`
3. `sudo docker compose up`
4. `sudo docker run --rm -it --network host alpine:3.21 sh`
- `echo -e "http://localhost/v3.21/main\nhttp://localhost/v3.21/community" > /etc/apk/repositories`
- `apk update`
- Feel free to install anything to test, with `apk add`
- e.g. `apk add fastfetch` and `fastfetch`
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
services:
sync:
container_name: alpine-mirror-sync
build: .
volumes:
- ./repo:/site:z
server:
container_name: alpine-mirror-server
image: docker.io/library/httpd:alpine
volumes:
- ./repo:/usr/local/apache2/htdocs:z
ports:
- 8080:80
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# every 5 days
* * */5 * * sh /app/mirror.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

# make sure we never run 2 rsync at the same time
lockfile="/tmp/alpine-mirror.lock"
if [ -z "$flock" ] ; then
exec env flock=1 flock -n $lockfile "$0" "$@"
fi

src=rsync://rsync.alpinelinux.org/alpine/
dest=/site

exclude="--exclude v2.* --exclude v3.0 --exclude v3.1 --exclude v3.2 --exclude v3.3 --exclude v3.4 --exclude v3.5 --exclude v3.6 --exclude v3.7 --exclude v3.8 --exclude v3.9 --exclude v3.10 --exclude v3.11 --exclude v3.12 --exclude v3.13 --exclude v3.14 --exclude v3.15 --exclude v3.16 --exclude v3.17"

echo "--- Starting Sync ---"

mkdir -p "$dest"
/usr/bin/rsync \
--archive \
--update \
--hard-links \
--delete \
--delete-after \
--delay-updates \
--timeout=600 \
$exclude \
"$src" "$dest"

echo "--- Finished Sync ---"
13 changes: 13 additions & 0 deletions repo-server-bootstrap-ncl-issue-20/deploy/ansible/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: Test
hosts: all
gather_facts: false

tasks:
- name: Install python
raw: test -e /usr/bin/python3 || apk add --no-cache python3

- name: Gather facts
setup:
vars:
ansible_python_interpreter: /usr/bin/python3
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM alpine:latest

RUN apk update && apk add --no-cache alpine-sdk \
build-base \
apk-tools \
busybox \
fakeroot \
syslinux \
xorriso \
squashfs-tools \
sudo \
git \
grub \
grub-efi

WORKDIR /build
COPY build.sh .

RUN chmod +x build.sh

CMD ["sh", "/build/build.sh"]
62 changes: 62 additions & 0 deletions repo-server-bootstrap-ncl-issue-20/deploy/build/alpine/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/sh

#
# !!!!!
# THIS SCRIPT IS NOT MEANT TO BE MANUALLY RUN, USE THE ADJACENT CONTAINERFILE
# !!!!!
#

# https://github.com/KarmaComputing/server-bootstrap/blob/main/build-alpine-netboot-zfs.sh
# Purpose:
# Build netboot image with zfs kernel module included

set -x

# Note we now build alpine-conf from source (rather than doing apk add alpine-conf)
# due to issue https://github.com/KarmaComputing/server-bootstrap/issues/20

# Clone and build latest alpine-conf
git clone https://gitlab.alpinelinux.org/alpine/alpine-conf.git
cd alpine-conf
make
make install
cd -

# Start build
adduser build --disabled-password -G abuild
# Set password non interactively
echo -e "password\npassword" | passwd build
echo "build ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/abuild

su - build << 'EOF'
set -x
SUDO=sudo abuild-keygen -n -i -a
# aports contains build utilities such as mkimage.sh
git clone --depth 1 https://gitlab.alpinelinux.org/alpine/aports.git
cd aports

# Create & build alpine netboot profile with zfs kernel module enabled
cat > ./scripts/mkimg.zfsnetboot.sh << 'EOFINNER'

profile_zfsnetboot() {
profile_standard
kernel_cmdline="overlay_size=0 console=tty0 console=ttyS0,115200"
syslinux_serial="0 115200"
kernel_addons="zfs"
apks="$apks zfs-scripts zfs zfs-utils-py python3 mkinitfs syslinux util-linux linux-firmware"
initfs_features="base network squashfs usb virtio"
output_format="netboot"
image_ext="tar.gz"
}
EOFINNER

cat ./scripts/mkimg.zfsnetboot.sh
echo Running mkimage.sh
./scripts/mkimage.sh --arch x86_64 --repository https://dl-cdn.alpinelinux.org/alpine/v3.20/main --profile zfsnetboot
EOF

ls -la /home/build/aports
cp /home/build/aports/alpine-zfsnetboot-*.tar.gz /output --force
tar -xvf /home/build/aports/alpine-zfsnetboot-*.tar.gz --directory /output
chmod 0644 /output/boot/* # fix permissions, specifically for initramfs for some reason
exit
34 changes: 34 additions & 0 deletions repo-server-bootstrap-ncl-issue-20/deploy/build/ipxe/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM alpine:latest

RUN apk update && apk add --no-cache build-base \
git \
gcc \
binutils \
make \
perl \
xz-dev \
mtools \
syslinux \
xorriso \
curl \
openssl \
coreutils

WORKDIR /build

RUN git clone https://github.com/ipxe/ipxe.git
WORKDIR /build/ipxe/src

RUN curl -s http://ca.ipxe.org/ca.crt > ca.pem &&\
curl -s https://letsencrypt.org/certs/isrgrootx1.pem > isrgrootx1.pem &&\
curl -s https://letsencrypt.org/certs/lets-encrypt-r3.pem > lets-encrypt-r3.pem

RUN sed -i 's$//#define PING_CMD$#define PING_CMD$g' config/general.h &&\
sed -i 's$//#define NET_PROTO_IPV6$#define NET_PROTO_IPV6$g' config/general.h &&\
sed -i 's/undef.*DOWNLOAD_PROTO_HTTPS/define DOWNLOAD_PROTO_HTTPS/g' config/general.h

CMD make -j${ISO_MAKE_THREADS} bin/ipxe.iso EMBED=/input/${FILE} \
DEBUG=tls,httpcore,x509,certstore \
CERT=ca.pem,isrgrootx1.pem,lets-encrypt-r3.pem \
TRUST=ca.pem,isrgrootx1.pem,lets-encrypt-r3.pem \
&& mv bin/ipxe.iso /output/ipxe.iso
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!ipxe

echo Setting temporary DHCP address to chain into bootfile
dhcp

set chain-url http://192.168.0.170:8080/bootfile
echo Chaining to ${chain_url}
chain ${chain-url}?uuid=${uuid}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!ipxe

# The iPXE script below is based on:
# https://boot.alpinelinux.org/boot.ipxe

dhcp

set console console=tty0
set cmdline modules=loop,squashfs nomodeset
set branch v3.20
set flavor lts
set arch x86_64

set serverip 192.168.1.29:8080
set server-url http://${serverip}
set base-url ${server-url}/iso/alpine-netboot/boot
set repo-url http://dl-cdn.alpinelinux.org/alpine/${branch}/main
set sshkey-url ${server-url}/ssh/key.pub

imgfree
kernel ${base-url}/vmlinuz-${flavor} ${cmdline} ${console} ip=dhcp alpine_repo=${repo-url} modloop=${base-url}/modloop-${flavor} alpine_dev=tmpfs ssh_key=${sshkey-url}
initrd ${base-url}/initramfs-${flavor}
boot
18 changes: 18 additions & 0 deletions repo-server-bootstrap-ncl-issue-20/deploy/scripts/build-alpine.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
cd "$(dirname "$0")"

set -exu

PODMAN_IMAGE_NAME="alpine_builder"
WWW_DIR="../serve/www/iso/alpine-netboot"
BUILD_DIR="../build/alpine"

echo "--- Creating directory at ${WWW_DIR} ---"
mkdir -p ${WWW_DIR}

echo "--- Building ${PODMAN_IMAGE_NAME} ---"
podman build --tag ${PODMAN_IMAGE_NAME} ${BUILD_DIR}

echo "--- Running ${PODMAN_IMAGE_NAME} ---"
podman run --rm -v ${WWW_DIR}:/output:z \
localhost/${PODMAN_IMAGE_NAME}:latest
Loading
Loading