mirror of
https://github.com/famedly/ansible-collection-base
synced 2024-11-10 06:24:17 +00:00
chore(redis): fix lints in role
This commit is contained in:
parent
354341647f
commit
12f83dd41c
5 changed files with 49 additions and 52 deletions
|
@ -1,10 +1,8 @@
|
|||
---
|
||||
- hosts: [localhost]
|
||||
- hosts: ["localhost"]
|
||||
become: true
|
||||
collections:
|
||||
- famedly.base
|
||||
roles:
|
||||
- role: redis
|
||||
- role: "famedly.base.redis"
|
||||
vars:
|
||||
redis_secret: s3cr3t
|
||||
redis_prefix: test_
|
||||
redis_secret: "s3cr3t"
|
||||
redis_prefix: "test_"
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
---
|
||||
|
||||
redis_version: "6.2.6"
|
||||
redis_user: "{{ redis_prefix }}redis"
|
||||
redis_basepath: "/opt/redis"
|
||||
redis_data_dir: "{{ redis_basepath }}/{{ redis_prefix }}data"
|
||||
redis_config_dir: "{{ redis_basepath }}/{{redis_prefix }}config"
|
||||
redis_config_dir: "{{ redis_basepath }}/{{ redis_prefix }}config"
|
||||
redis_config_file: "{{ redis_config_dir }}/redis.conf"
|
||||
redis_secret: ~
|
||||
|
||||
|
@ -12,18 +11,17 @@ redis_config_bind_ip: "0.0.0.0"
|
|||
redis_config_unix_socket_path: ~
|
||||
redis_config_unix_socket_perm: 775
|
||||
redis_config_max_memory_mb: ~
|
||||
redis_config_max_memory_policy: ~ # allkeys-lru
|
||||
redis_config_max_memory_policy: ~ # allkeys-lru
|
||||
|
||||
# Overwrite per-instance to be able to run many instances on the same host
|
||||
# prefix should be sth like 'matrix_', modifies mapped directories, container name and uer
|
||||
redis_prefix: ""
|
||||
|
||||
redis_docker_labels: {}
|
||||
redis_docker_configpath: "/usr/local/etc/redis/redis.conf"
|
||||
redis_docker_image: "docker.io/library/redis:{{ redis_docker_tag }}"
|
||||
redis_docker_tag: "{{ redis_version }}-alpine"
|
||||
redis_docker_container_name: "{{ redis_prefix }}redis"
|
||||
redis_docker_ports: [ "6379:6379" ]
|
||||
redis_docker_ports: ["6379:6379"]
|
||||
redis_docker_networks: ~
|
||||
redis_docker_purge_networks: false
|
||||
redis_docker_volumes:
|
||||
redis_docker_volumes: ~
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
|
||||
- name: restart-redis
|
||||
docker_container:
|
||||
- name: "Restart redis container"
|
||||
community.docker.docker_container:
|
||||
name: "{{ redis_docker_container_name }}"
|
||||
state: started
|
||||
restart: yes
|
||||
state: "started"
|
||||
restart: true
|
||||
listen: "restart-redis"
|
||||
|
|
|
@ -1,60 +1,62 @@
|
|||
---
|
||||
|
||||
- name: Create redis user
|
||||
- name: "Create redis user"
|
||||
user:
|
||||
name: "{{ redis_user }}"
|
||||
create_home: no
|
||||
state: present
|
||||
register: redis_user_res
|
||||
tags: ['prepare', 'prepare-redis',
|
||||
'deploy', 'deploy-redis']
|
||||
create_home: false
|
||||
state: "present"
|
||||
register: "redis_user_res"
|
||||
tags: ["prepare", "prepare-redis", "deploy", "deploy-redis"]
|
||||
|
||||
- name: Create redis directory
|
||||
- name: "Create redis directory"
|
||||
file:
|
||||
path: "{{ redis_basepath }}"
|
||||
state: directory
|
||||
state: "directory"
|
||||
owner: "{{ redis_user }}"
|
||||
group: "{{ redis_user }}"
|
||||
tags: ['prepare', 'prepare-redis']
|
||||
mode: "0755"
|
||||
tags: ["prepare", "prepare-redis"]
|
||||
|
||||
- name: Create redis directory for data persistance
|
||||
- name: "Create redis directory for data persistance"
|
||||
file:
|
||||
path: "{{ redis_data_dir }}"
|
||||
state: directory
|
||||
state: "directory"
|
||||
owner: "{{ redis_user }}"
|
||||
group: "{{ redis_user }}"
|
||||
tags: ['prepare', 'prepare-redis']
|
||||
mode: "0755"
|
||||
tags: ["prepare", "prepare-redis"]
|
||||
|
||||
- name: Create redis config directory
|
||||
- name: "Create redis config directory"
|
||||
file:
|
||||
path: "{{ redis_config_dir }}"
|
||||
state: directory
|
||||
state: "directory"
|
||||
owner: "{{ redis_user }}"
|
||||
group: "{{ redis_user }}"
|
||||
tags: ['prepare', 'prepare-redis']
|
||||
mode: "0755"
|
||||
tags: ["prepare", "prepare-redis"]
|
||||
|
||||
- name: Template redis config file
|
||||
- name: "Template redis config file"
|
||||
template:
|
||||
src: redis.conf.j2
|
||||
src: "redis.conf.j2"
|
||||
dest: "{{ redis_config_file }}"
|
||||
owner: "{{ redis_user }}"
|
||||
group: "{{ redis_user }}"
|
||||
notify: restart-redis
|
||||
tags: ['deploy', 'deploy-redis']
|
||||
mode: "0600"
|
||||
notify: "restart-redis"
|
||||
tags: ["deploy", "deploy-redis"]
|
||||
|
||||
- name: Ensure redis container image is present
|
||||
docker_image:
|
||||
- name: "Ensure redis container image is present"
|
||||
community.docker.docker_image:
|
||||
name: "{{ redis_docker_image }}"
|
||||
force_source: "{{ redis_docker_image_force_pull|default(False) }}"
|
||||
source: pull
|
||||
state: present
|
||||
tags: ['prepare', 'prepare-redis']
|
||||
force_source: "{{ redis_docker_image_force_pull | default(False) }}"
|
||||
source: "pull"
|
||||
state: "present"
|
||||
tags: ["prepare", "prepare-redis"]
|
||||
|
||||
- name: Setup redis docker container
|
||||
docker_container:
|
||||
- name: "Setup redis docker container"
|
||||
community.docker.docker_container:
|
||||
image: "{{ redis_docker_image }}"
|
||||
name: "{{ redis_docker_container_name }}"
|
||||
restart_policy: unless-stopped
|
||||
restart_policy: "unless-stopped"
|
||||
user: "{{ redis_user_res.uid }}:{{ redis_user_res.group }}"
|
||||
ports: "{{ redis_docker_ports }}"
|
||||
volumes: "{{ redis_docker_volumes }}"
|
||||
|
@ -62,11 +64,11 @@
|
|||
networks: "{{ redis_docker_networks | default(omit, True) }}"
|
||||
purge_networks: "{{ redis_docker_purge_networks }}"
|
||||
entrypoint: "redis-server"
|
||||
command: [ "{{ redis_docker_configpath }}" ]
|
||||
command: ["{{ redis_docker_configpath }}"]
|
||||
healthcheck:
|
||||
test: >-
|
||||
redis-cli -a {{ redis_secret }} PING || exit 1
|
||||
tags: ['deploy', 'deploy-redis']
|
||||
tags: ["deploy", "deploy-redis"]
|
||||
|
||||
- name: Ensure redis is restarted if config changed
|
||||
meta: flush_handlers
|
||||
- name: "Ensure redis is restarted if config changed"
|
||||
meta: "flush_handlers"
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
---
|
||||
|
||||
redis_docker_volumes_base:
|
||||
- "{{ redis_data_dir }}:/data"
|
||||
- "{{ redis_config_file }}:{{ redis_docker_configpath }}"
|
||||
redis_docker_volumes: "{{ redis_docker_volumes_base + redis_docker_extra_volumes|default([]) }}"
|
||||
redis_docker_volumes: "{{ redis_docker_volumes_base + redis_docker_extra_volumes | default([]) }}"
|
||||
|
||||
redis_docker_labels_base:
|
||||
version: "{{ redis_version }}"
|
||||
|
|
Loading…
Reference in a new issue