21 feat add new silverbullet role (#23)
### Description This PR adds a new silvetbullet role that configures and starts the silverbullet container Changes - Creates required silverbullet `space` directory - creates silverbullet `.container` file - starts new and updated `.container` files ### Related Issue Closes #21 ### Testing Done - [x] [e.g., Ran local unit tests] - [x] [e.g., Verified service starts under Podman] - [x] [e.g., Manual check of configuration file output] ### Checklist - [x] My code follows the project's style guidelines. - [x] I have performed a self-review of my own code. - [x] I have updated the documentation (if necessary). --------- Co-authored-by: Jordan Del Pilar <[email protected]> Reviewed-on: #23
This commit was merged in pull request #23.
This commit is contained in:
+4
-1
@@ -34,4 +34,7 @@ all:
|
|||||||
new-bark:
|
new-bark:
|
||||||
ntfy_servers:
|
ntfy_servers:
|
||||||
hosts:
|
hosts:
|
||||||
new-bark:
|
new-bark:
|
||||||
|
silverbullet_servers:
|
||||||
|
hosts:
|
||||||
|
new-bark:
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
# Role: SilverBullet Server
|
||||||
|
Sets up and deploys SilverBullet container
|
||||||
|
For more information about SilverBullet check out [their website](https://silverbullet.md/)
|
||||||
|
|
||||||
|
## Tags
|
||||||
|
- silverbullet
|
||||||
|
- docs
|
||||||
|
|
||||||
|
## Required Variables
|
||||||
|
Below is an annotated breakdown of the required variables and their structure for this role
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Any variable marked `# !SENSITIVE` **should not** be stored in plain text under any circumstance
|
||||||
|
|
||||||
|
### SilverBullet Info
|
||||||
|
Defines settings for the SilverBullet Server.
|
||||||
|
Most of these variables are optional, and have predefined defaults in the role itself, however it is possible to define custom variables in `host_vars` files.
|
||||||
|
Any variable marked as optional has a default value defined in `defaults/main.yaml` for this role
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# (optional): Name of the silverbullet container
|
||||||
|
# This name is also the name of the service created by the quadlet file,
|
||||||
|
# as well as the name of the .container file
|
||||||
|
# default: silverbullet
|
||||||
|
# format: snake_case
|
||||||
|
silverbullet_name:
|
||||||
|
|
||||||
|
# (optional): Image of the silverbullet container
|
||||||
|
# This can be any image from any register that podman supports
|
||||||
|
# default: ghcr.io/silverbulletmd/silverbullet:latest
|
||||||
|
# format: URL
|
||||||
|
silverbullet_image:
|
||||||
|
|
||||||
|
# (optional): Port of the silverbullet webui
|
||||||
|
# this is used for traefik labels to allow for access to the webui
|
||||||
|
# the default value is defined by the silverbullet container itself. For information on changing it, view the documentation for your image
|
||||||
|
# default: 3000
|
||||||
|
# format: int
|
||||||
|
silverbullet_port:
|
||||||
|
|
||||||
|
# (optional): Username of the silverbullet user
|
||||||
|
# this is the default user created for silverbullet
|
||||||
|
# note, this value has a default, but it is highly recommended to change it via `host_vars`
|
||||||
|
# default: jdelpilar
|
||||||
|
# format: username
|
||||||
|
silverbullet_user:
|
||||||
|
|
||||||
|
# (optional): password for the above created user
|
||||||
|
# note, this value has a default, but it is highly recommended to change it via `host_vars`
|
||||||
|
# !SENSITIVE
|
||||||
|
# default: generated password
|
||||||
|
# format: password
|
||||||
|
silverbullet_pass:
|
||||||
|
|
||||||
|
# (optional): url of the silverbullet instance
|
||||||
|
# this is used to set the url in traefik
|
||||||
|
# default: silverbullet.delpilar.net
|
||||||
|
# format: url
|
||||||
|
silverbullet_url:
|
||||||
|
```
|
||||||
|
|
||||||
|
## Templates
|
||||||
|
|
||||||
|
### silverbullet.container.j2
|
||||||
|
This template creates a `.container` file for silverbullet
|
||||||
|
By default this template supports the following additional variables not listed above.
|
||||||
|
- silver_bullet_volumes: used to define additional mounted volumes
|
||||||
|
- format: <host_path>:<container_path>
|
||||||
|
- silver_bullet_env: used to define additional environment variables used by the container
|
||||||
|
- format: dict(<key>:<value>)
|
||||||
|
|
||||||
|
## Execution
|
||||||
|
> [!NOTE]
|
||||||
|
> This role restarts any containers where the `.container` file is changed. As such, please ensure that all work is saved and all users are made aware of any potential downtime.
|
||||||
|
|
||||||
|
To run this role without running any other roles, please use this command
|
||||||
|
```bash
|
||||||
|
ansible-playbook site.yaml --tags silverbullet
|
||||||
|
```
|
||||||
|
|
||||||
|
To run all roles with the `docs` tag at once, please use this command
|
||||||
|
```bash
|
||||||
|
ansible-playbook site.yaml --tags docs
|
||||||
|
```
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
silverbullet_name: silverbullet
|
||||||
|
silverbullet_image: ghcr.io/silverbulletmd/silverbullet:latest
|
||||||
|
silverbullet_port: 3000
|
||||||
|
silverbullet_user: jdelpilar
|
||||||
|
silverbullet_pass: !vault |
|
||||||
|
$ANSIBLE_VAULT;1.1;AES256
|
||||||
|
37643331363732343135383232666363326464313534316264316261613161333633306239336365
|
||||||
|
3430613632323734616233303336363331646364303530660a373639323639656664336236303837
|
||||||
|
35613464313563303565666638643463326431616665613837353264346132636133396636383232
|
||||||
|
6430343764626363310a323033333662656532386131663734613436663665356164396662613636
|
||||||
|
38383863313064313563306439653434646533353363373338306633393562373235
|
||||||
|
silverbullet_enable_traefik: true
|
||||||
|
silverbullet_url: silverbullet.delpilar.net
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
- name: Restart changed Silverbullet Services
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: "{{ silverbullet_name }}"
|
||||||
|
state: restarted
|
||||||
|
scope: user
|
||||||
|
daemon_reload: true
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
- name: Create SilverBullet Directory
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ podman_config_base_dir }}/{{ silverbullet_name }}/space"
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
- name: Create SilverBullet Quadlet
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: silverbullet.container.j2
|
||||||
|
dest: "{{ podman_quadlet_base_dir }}/services/{{ silverbullet_name }}.container"
|
||||||
|
owner: "{{ ansible_user }}"
|
||||||
|
mode: "644"
|
||||||
|
notify: Restart changed Silverbullet Services
|
||||||
|
|
||||||
|
- name: Flush Handlers
|
||||||
|
ansible.builtin.meta: flush_handlers
|
||||||
|
|
||||||
|
- name: Start SilverBullet
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: "{{ silverbullet_name }}"
|
||||||
|
state: started
|
||||||
|
scope: user
|
||||||
|
daemon_reload: true
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
# {{ ansible_managed }}
|
||||||
|
[Unit]
|
||||||
|
After=network-online.target
|
||||||
|
|
||||||
|
StartLimitBurst=10
|
||||||
|
StartLimitIntervalSec=120
|
||||||
|
|
||||||
|
[Container]
|
||||||
|
ContainerName={{ silverbullet_name }}
|
||||||
|
Image={{ silverbullet_image }}
|
||||||
|
|
||||||
|
Network=services-net
|
||||||
|
PublishPort={{ silverbullet_port }}:3000
|
||||||
|
|
||||||
|
AutoUpdate=registry
|
||||||
|
|
||||||
|
Label=category=management
|
||||||
|
Label=owner={{ container_owner | default('jdelpilar') }}
|
||||||
|
|
||||||
|
{% if silverbullet_enable_traefik %}
|
||||||
|
Label=traefik.enable=true
|
||||||
|
Label=traefik.http.routers.{{ silverbullet_name }}.rule=Host(`{{ silverbullet_url | default(silverbullet_name + "." + base_domain, true) }}`)
|
||||||
|
Label=traefik.http.routers.{{ silverbullet_name }}.entrypoints={{ traefik_entrypoint | default('websecure', true) }}
|
||||||
|
Label=traefik.http.routers.{{ silverbullet_name }}.tls.certresolver={{ traefik_resolver | default('cloudflare', true) }}
|
||||||
|
Label=traefik.http.services.{{ silverbullet_name }}.loadbalancer.server.port={{ silverbullet_port | default(3000, true) }}
|
||||||
|
Label=traefik.docker.network=services-net
|
||||||
|
Label=traefik.http.routers.{{ silverbullet_name }}.tls=true
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
Volume={{ podman_config_base_dir }}/{{ silverbullet_name }}/space:/space
|
||||||
|
{% if silverbullet_volumes is defined %}
|
||||||
|
{% for volume in silverbullet_volumes %}
|
||||||
|
Volume={{ volume }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
Environment=TZ={{ timezone | default('America/Los_Angeles') }}
|
||||||
|
Environment=SB_USER={{ silverbullet_user }}:{{ silverbullet_pass }}
|
||||||
|
{% if silverbullet_env is defined %}
|
||||||
|
{% for key, value in silverbullet_env.items() | sort %}
|
||||||
|
Environment={{ key }}={{ value }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
||||||
Reference in New Issue
Block a user