1
0
mirror of https://github.com/funkypenguin/geek-cookbook/ synced 2025-12-22 22:21:56 +00:00

Add WIP docs on how to ansiblize recipes for premix

Signed-off-by: David Young <davidy@funkypenguin.co.nz>
This commit is contained in:
David Young
2022-09-02 13:13:22 +12:00
parent 9326ca6140
commit 9d6139a9fb
18 changed files with 211 additions and 947 deletions

View File

@@ -0,0 +1,10 @@
# Ansiblizing
!!! warning "This section is under construction :hammer:"
This section is a serious work-in-progress, and reflects the current development on the [sponsors](https://github.com/sponsors/funkypenguin)' "premix" repository
So... There may be errors and inaccuracies. Jump into [Discord](http://chat.funkypenguin.co.nz) in the #premium-support channel if you're encountering issues 😁
So you want to add a recipe to the the premix playbook which is not yet an Ansible role? Read on for details...
1. [Ansiblizing for Docker Swarm](/premix/ansiblizing/swarm/)
2. [Ansiblizing for Kubernetes (flux)](/premix/ansiblizing/kubernetes/)

View File

@@ -0,0 +1,41 @@
# Ansiblizing a recipe for Kubernetes
!!! warning "This section is under construction :hammer:"
This section is a serious work-in-progress, and reflects the current development on the [sponsors](https://github.com/sponsors/funkypenguin)' "premix" repository
So... There may be errors and inaccuracies. Jump into [Discord](http://chat.funkypenguin.co.nz) in the #premium-support channel if you're encountering issues 😁
## Update deploy.yml
Edit `ansible/deploy.yml`, and find the kubernetes section, starting with:
```yaml
# Create flux manifests using localhost
- hosts: localhost
```
Add an `import_role` task like this (*alphabeticized*) at the bottom:
```yaml
# Traefik
- { import_role: { name: flux-repo }, vars: { recipe: traefik, config: traefik }, tags: [ traefik ], when: combined_config.traefik.enabled | bool }
```
## Update config
Edit `ansible/group_vars/all/main.yml`, and edit the `recipe_default_config` dictionary, adding the necessary values, like this:
```yaml
traefik:
enabled: true
helm_chart_namespace: traefik
helm_chart_name: traefik
helm_chart_repo: traefik
helm_chart_repo_url: https://helm.traefik.io/traefik
helm_chart_version: latest
```
## That's it!
What, that's all? So easy?
Yes, but remember all they playbook does in the case of a flux deployment is to create the necessary files for the user to customize themselves, since it's impractical to try to contain any chart config within our playbook!

View File

@@ -0,0 +1,44 @@
# Ansiblizing a recipe for Swarm
!!! warning "This section is under construction :hammer:"
This section is a serious work-in-progress, and reflects the current development on the [sponsors](https://github.com/sponsors/funkypenguin)' "premix" repository
So... There may be errors and inaccuracies. Jump into [Discord](http://chat.funkypenguin.co.nz) in the #premium-support channel if you're encountering issues 😁
## Update deploy.yml
Edit `ansible/deploy.yml`, and find the swarm section, starting with:
```yaml
### non-critical swarm recipes start here, alphabeticized
```
Add an `import_role` task like this (*alphabeticized*) at the bottom:
```yaml
# Setup immich
- { import_role: { name: docker-stack }, vars: { recipe: immich }, tags: [ immich ], when: combined_config.immich.enabled | bool }
```
## Update config
Edit `ansible/group_vars/all/main.yml`, and edit the `recipe_default_config` dictionary, adding the necessary values, like this:
```yaml
immich:
enabled: false #(1)!
run_pre_deploy: | #(2)!
mkdir -p /var/data/immich/database-dump
mkdir -p /var/data/immich/upload
mkdir -p /var/data/runtime/immich/database
run_post_deploy: | #(3)!
echo "this is just an example to show that it's possible to run tasks post-deploy!"
```
1. We disable all non-essential services by default - that way, the user can opt into them in their own config, which is later merged with this master config.
2. Add as many pre-deploy commands as necessary - typically these will create the necessary data directories. `/var/data/config/<recipe>` will be created automatically.
3. Likewise, add any necessary post-deployment commands
## Ensure the recipe files are valid
The playbook assumes that `/<recipe-name>/<recipe-name>.yml` and `/<recipe-name>/<recipe-name>.env-sample` exist. Without these (*and any other supporting files, ending in `-sample`*), unpleasant things will happen!