feat(redis): add ansible role

This commit is contained in:
transcaffeine 2024-10-30 12:21:51 +01:00
parent 6cec7a4e8e
commit 58c5ea9321
Signed by: transcaffeine
GPG Key ID: 03624C433676E465
6 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,38 @@
---
redis_container_image_registry: docker.io
redis_container_image_namespace: ~
redis_container_image_name: redis
redis_container_image_tag: ~
redis_container_image_flavour: alpine
redis_container_image_source: pull
redis_container_image_force_source: >-2
{{ redis_container_image_tag | default(false, true) | bool }}
redis_container_image: >-2
{{
([
redis_container_image_registry | default([], true),
redis_container_image_namespace | default([], true),
redis_container_image_name,
] | flatten | join('/'))
+ ':' +
(redis_container_image_tag | default(
redis_version + (
(redis_container_image_flavour | default(false, true) | bool)
| ternary('-' + (redis_container_image_flavour | default('')), '')
),
true,
))
}}
redis_container_name: "redis{{ redis_instance_suffix }}"
redis_container_env: ~
redis_container_user: #TODO
redis_container_ports: ~
redis_container_labels: ~
redis_container_volumes: # TODO
redis_container_networks: ~
redis_container_etc_hosts: ~
redis_container_dns_servers: ~
redis_container_restart_policy: "unless-stopped"
redis_container_state: >-2
{{ (redis_state == 'present') | default('started', 'absent') }}

View File

@ -0,0 +1,13 @@
---
redis_version: "7.2.4"
redis_instance: ~
redis_instance_suffix: >-2
{{ (redis_instance | default(false, true) | bool)
| ternary('-' + (redis_instance | default('')), '') }}
redis_user: >-2
redis{{ redis_instance_suffix }}
redis_config_path: "/etc/redis"
redis_config_file: >-2
{{ redis_config_path }}/redis{{ redis_instance_suffix }}.conf
redis_data_path: "/var/lib/redis{{ redis_instance_suffix }}"

View File

View File

View File

@ -0,0 +1,7 @@
---
- name: Ensure state is valid
ansible.builtin.fail:
msg: >-2
Unsupported state '{{ redis_state }}'.
Supported states are {{ redis_states | join(', ') }}
when: redis_state not in redis_states

View File

@ -0,0 +1,4 @@
---
redis_states:
- present
- absent