-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathp_setup-container-redis.yml
97 lines (88 loc) · 2.57 KB
/
p_setup-container-redis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
- name: Setup Redis Container
hosts: redis
user: "{{ redis_vm_user }}"
become: true
gather_facts: no
any_errors_fatal: yes
tags:
- redis
vars:
redis_data_dir: /var/data/redis
tasks:
- when: redis_runtime_user is defined
block:
- name: Get Redis User UID
shell: "getent passwd {{ redis_runtime_user }} | cut -d ':' -f 3 || false"
changed_when: false
register: redis_runtime_uid_out
- name: Setup user for Redis
when: "redis_runtime_uid_out.stdout | default('') == ''"
user:
name: "{{ redis_runtime_user }}"
system: yes
home: /dev/null
shell: /bin/false
create_home: no
- name: Get Redis User UID
shell: "getent passwd {{ redis_runtime_user }} | cut -d ':' -f 3 || false"
changed_when: false
register: redis_runtime_uid_out
- name: Set Redis User UID Fact
set_fact:
redis_runtime_uid: "{{ redis_runtime_uid_out.stdout }}"
- name: Create Redis Container Directories
tags:
- folders
file:
path: "{{ redis_data_dir }}/{{ item }}"
state: directory
owner: "{{ redis_runtime_user | default(omit) }}"
group: "{{ redis_runtime_user | default(omit) }}"
mode: 0755
with_items:
- ''
- data
- name: Remove Container
when: remove_redis_container|bool
block:
- include_role:
name: r_quay
tasks_from: class-remove-container.yml
vars:
service_name: redis
runtime_user: "{{ redis_runtime_user }}"
- name: Login to {{ image_registry }}
become_user: "{{ redis_runtime_user }}"
command: "podman login -u={{ image_registry_user }} -p={{ quay_registry_password }} {{ image_registry }}"
- name: Run Redis container
become_user: "{{ redis_runtime_user }}"
command: >
podman run --name redis
-v {{ redis_data_dir }}/data:/var/lib/redis/data:Z
-e REDIS_PASSWORD={{ secrets.quay_redis_password }}
-p 6379:6379 -d {{ redis_image }}
register: podman_pid
- name: Wait for Redis to come up
pause:
seconds: 7
# Daemonize Redis
#
#
- name: Daemonize Podman
tags: install-service
block:
- include_role:
name: r_quay
tasks_from: class-container-service.yml
vars:
service_name: redis
runtime_user: "{{ redis_runtime_user }}"
- name: Redis Unit Tests
tags: unit-tests
block:
- include_role:
name: r_quay
tasks_from: unit-test-service.yml
vars:
service_name: redis
runtime_user: "{{ redis_runtime_user }}"