feat(synapse): add deployment type podman

This commit is contained in:
transcaffeine 2024-09-22 17:52:01 +02:00
parent 72834ea4dd
commit edcad0094a
Signed by: transcaffeine
GPG Key ID: 03624C433676E465
4 changed files with 52 additions and 10 deletions

View File

@ -18,12 +18,12 @@ The following variables need to be populated:
## Deployment methods
### Docker
- `docker`
- `podman`
Set `synapse_deployment_method: docker` to deploy synapse in docker container(s).
This is currently the default.
Set `synapse_deployment_method` to one of the supported deployment methods.
The current default is `docker`.
### Planned methods
### Planned deployment methods
- virtual env + systemd
- podman
- `venv` - Python virtual env supervised with `systemd`

View File

@ -18,10 +18,14 @@ synapse_container_image_repository: >-2
synapse_container_image_source: pull
synapse_container_image_tag: ~
synapse_container_env: {}
synapse_container_user: >-
synapse_container_user: >-2
{{ ((synapse_user_info is defined) and ('uid' in synapse_user_info))
| ternary(synapse_user_info.uid, synapse_user) }}
synapse_container_group: ~
synapse_container_group: >-2
{{ ((synapse_user_info is defined) and ('group' in synapse_user_info))
| ternary(synapse_user_info.group, synapse_user) }}
synapse_container_groups:
- "{{ synapse_container_group }}"
synapse_container_ports: ~
synapse_container_labels: ~
synapse_container_ulimits: ~
@ -32,8 +36,14 @@ synapse_container_etc_hosts: ~
synapse_container_memory: ~
synapse_container_memory_reservation: ~
synapse_container_memory_swap: ~
synapse_container_state: "started"
synapse_container_restart_policy: "unless-stopped"
synapse_container_state: >-2
{{ (synapse_state == 'present')
| ternary('started', 'absent') }}
synapse_container_restart_policy: >-2
{{ (synapse_deployment_method == 'docker')
| ternary('unless-stopped', ((synapse_deployment_method == 'podman')
| ternary('on-failure', 'always')))
}}
synapse_container_volumes: ~
synapse_container_default_volumes:

View File

@ -0,0 +1,31 @@
---
- name: Ensure container image '{{ synapse_container_image }}' is {{ synapse_state }} on host
containers.podman.podman_image:
name: "{{ synapse_container_image }}"
state: "{{ synapse_state }}"
pull: "{{ synapse_container_image_source == 'pull' }}"
force: "{{ synapse_container_image_tag | default(false, true) | bool }}"
register: synapse_container_image_info
until: synapse_container_image_info is success
retries: 5
delay: 3
- name: Ensure synapse container '{{ synapse_container_name }}' is {{ synapse_container_state }}
containers.podman.podmain_container:
name: "{{ synapse_container_name }}"
image: "{{ synapse_container_image }}"
env: "{{ synapse_container_env | default(omit, true) }}"
user: "{{ synapse_container_user | default(omit, true) }}"
groups: "{{ synapse_container_groups | default(omit, true) }}"
ports: "{{ synapse_container_ports | default(omit, true) }}"
labels: "{{ synapse_container_labels | default(omit, true) }}"
ulimits: "{{ synapse_container_ulimits | default(omit, true) }}"
volumes: "{{ synapse_container_all_volumes }}"
network: "{{ synapse_container_networks | default(omit, true) }}"
dns_servers: "{{ synapse_container_dns_servers | default(omit, true) }}"
etc_hosts: "{{ synapse_container_etc_hosts | default(omit, true) }}"
memory: "{{ synapse_container_memory | default(omit, true) }}"
memory_reservation: "{{ synapse_container_memory_reservation | default(omit, true) }}"
memory_swap: "{{ synapse_container_memory_swap | default(omit, true) }}"
restart_policy: "{{ synapse_container_restart_policy }}"
state: "{{ synapse_container_state }}"

View File

@ -5,6 +5,7 @@ synapse_states:
synapse_deployment_methods:
- docker
- podman
synapse_required_variables:
- synapse_domain