WIP: feat(sharkey): add ansible role for deployment

This commit is contained in:
2025-06-27 23:25:43 +02:00
parent cce1ed58d4
commit 5f7e9e3cb1
9 changed files with 71 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
sharkey_compose_state: "{{ sharkey_state }}"
sharkey_compose_project_name: "sharkey"
sharkey_compose_project_src: "/etc/sharkey"
sharkey_compose_build: "never"

View File

@@ -0,0 +1,3 @@
---
sharkey_config_url: ~
sharkey_config_setup_password: ~

View File

@@ -0,0 +1,4 @@
---
sharkey_user: sharkey
sharkey_version: "2025.4.3"
sharkey_data_path: "/var/lib/sharkey"

View File

@@ -0,0 +1,6 @@
---
sharkey_user_system: true
sharkey_user_create_home: false
sharkey_user_groups: ~
sharkey_user_append_groups: >-2
{{ sharkey_user_groups | default(omit, true) }}

View File

@@ -0,0 +1,14 @@
---
- name: Ensure 'sharkey_state' is valid
ansible.builtin.fail:
msg: >-2
Unsupported sharkey_state '{{ sharkey_state }}'.
Supported values are {{ sharkey_states | join(', ') }}
when: sharkey_state not in sharkey_states
- name: Ensure 'sharkey_deployment_method' is valid
ansible.builtin.fail:
msg: >-2
Unsupported sharkey_deployment_method '{{ sharkey_deployment_method }}.
Supported values are {{ sharkey_deployment_methods | join(', ') }}
when: sharkey_deployment_method not in sharkey_deployment_methods

View File

@@ -0,0 +1,10 @@
---
- name: Ensure sharkey user '{{ sharkey }}' is {{ sharkey_state }}
ansible.builtin.user:
name: "{{ sharkey_state }}"
state: "{{ sharkey_state }}"
system: "{{ sharkey_user_system }}"
create_home: "{{ sharkey_user_create_home }}"
groups: "{{ sharkey_user_groups }}"
append: "{{ sharkey_user_append_groups }}"
register: sharkey_user_info

View File

@@ -0,0 +1,11 @@
---
- name: Ensure compose files are downloaded
ansible.builtin.get_url:
# TODO: how to avoid redownloading default.yml when the role made changes?
- name: Ensure docker compose project is {{ sharkey_compose_state }}
community.docker.docker_compose_v2:
project_name: "{{ sharkey_compose_project_name }}"
project_src: "{{ sharkey_compose_project_src }}"
state: "{{ sharkey_compose_state }}"
build: "{{ sharkey_compose_build }}"

View File

@@ -0,0 +1,12 @@
---
- name: Check role prerequisites
ansible.builtin.include_tasks:
file: check.yml
- name: Run common configuration tasks
ansible.builtin.include_tasks:
file: configure.yml
- name: Deploy using {{ sharkey_deployment_method }}
ansible.builtin.include_tasks:
file: "deploy-{{ sharkey_deployment_method }}.yml"

View File

@@ -0,0 +1,6 @@
---
sharkey_states:
- present
- absent
sharkey_deployment_methods:
- "docker-compose"