-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5237e6
commit 33c831e
Showing
4 changed files
with
69 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,38 +16,80 @@ the following sane open-source solution. | |
|
||
## How it works | ||
|
||
### For local machine | ||
First you need a build script for image building, for now we create a dummy. | ||
|
||
File: `build.py` | ||
```python | ||
#!/usr/bin/env python3 | ||
import os | ||
import shutil | ||
import sys | ||
|
||
project_path = "" | ||
try: | ||
project_path = os.environ["RUN_DEPLOY_PROJECT_PATH"] | ||
except KeyError: | ||
print("RUN_DEPLOY_PROJECT_PATH is missing", file=sys.stderr) | ||
exit(1) | ||
``` | ||
Give it execute right `chmod 755 build.py` | ||
|
||
```shell | ||
#!/bin/sh | ||
Now we need to create the following | ||
File: `create_image.toml` | ||
```toml | ||
#!/usr/bin/env run-deploy-image-toml | ||
|
||
# Create the image | ||
image_location=$(./create_image.py) | ||
# Image name | ||
name = "example" | ||
# The location is relative to toml file | ||
build_script = "./build.py" | ||
|
||
# Deploy the image | ||
run-deploy $image_location | ||
# It will move the image to `/opt/run-deploy/image/{image_dir}` | ||
# The hostname has to match the hostname of where it getting deployed | ||
[manifest.hostname] | ||
# Name of incus container | ||
incus_name = "example" | ||
``` | ||
Give it execute right `chmod 755 create_image.toml` | ||
You can also test the image building by running `./create_image.toml` | ||
|
||
### For remote machine | ||
Now we the toml file for deploy, this is for the local machine | ||
|
||
```shell | ||
#!/bin/sh | ||
File: `deploy_local.toml` | ||
```toml | ||
#!/usr/bin/env run-deploy-local-toml | ||
|
||
# Image creation script to execute | ||
create_image_script = "./create_image.toml" | ||
|
||
# Create the image (on Local Machine) | ||
image_location=$(./create_image.py) | ||
incus = "example" | ||
image = "example" | ||
``` | ||
Give it execute right `chmod 755 deploy_local.toml` | ||
Let deploy to local machine by running `./deploy_local.toml` | ||
|
||
# Sign the image (on Local Machine) | ||
minisign -Sm $image_location | ||
For remote deploy we need to create the following TOML. | ||
|
||
# Upload the image and signature | ||
scp $image_location ${image_location}.minisig "[email protected]:/tmp/run-deploy" | ||
File: `deploy_remote.toml` | ||
```toml | ||
#!/usr/bin/env run-deploy-remote-toml | ||
|
||
# Deploy the image, | ||
ssh [email protected] -- doas /opt/run-deploy/bin/run-deploy "/tmp/run-deploy/$(basename $image_location)" "$(whoami)@$(hostname)" | ||
# Image creation script to execute | ||
create_image_script = "./create_image.toml" | ||
|
||
# "$(whoami)@$(hostname)" is used as public key and permission references. | ||
# Image name (Mandatory) | ||
image = "example" | ||
|
||
# SSH Config, at least one is required | ||
[ssh.'username@deploy.example-1.com'] | ||
# Mandatory for remote-incus | ||
incus = "example" | ||
``` | ||
Give it execute right `chmod 755 deploy_remote.toml` | ||
Let deploy to remote machine by running `./deploy_remote.toml` | ||
|
||
That is the jist of it. Really clean and elegant isn't it? =D | ||
|
||
[Click here for more detail on toml-util](toml-util/README.md) | ||
|
||
## Image Manifest | ||
|
||
|
@@ -108,6 +150,10 @@ Run `client/install.py` as root | |
|
||
Run `local-incus/install.py` as root | ||
|
||
### toml-util | ||
|
||
Run `toml-util/install.py` as root | ||
|
||
### For servers | ||
|
||
Run `create_server_installer.py`, first it will open a toml file in the default text editor, edit it, add the ssh | ||
|
@@ -287,4 +333,6 @@ In quirk mode, the squashfs exec will also need to do a symlink swap. You will n | |
cd /opt/run-deploy/image/example | ||
ln -sf example-2024-12-12.squashfs example.squashfs | ||
/opt/run-deploy/script/deploy/example | ||
``` | ||
``` | ||
|
||
Strict mode will write it own script and is the default, Quirk mode will let you write you own script that is stored in the image, not recommended as it will run the script in root. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.