Skip to content

Commit 9b98606

Browse files
authored
Add redis (#185)
* Add redis role from ansible-automation-platform-containerized-setup-2.6-1 just cp from .tar.gz Signed-off-by: Justin Cinkelj <justin.cinkelj@xlab.si> * Setup redis Signed-off-by: Justin Cinkelj <justin.cinkelj@xlab.si> * Retry systemctl stop/start It often fails when combined with daemon_reload Signed-off-by: Justin Cinkelj <justin.cinkelj@xlab.si> * Add uwsgi back to container image Signed-off-by: Justin Cinkelj <justin.cinkelj@xlab.si> * Use requirements-build.txt to build container image Signed-off-by: Justin Cinkelj <justin.cinkelj@xlab.si> * Fix load SECRET_KEY from correct file Before: everyone was using same hardcoded SECRED_KEY Enduser will need to run 'python manage.py setclusters clusters.yaml' again. Signed-off-by: Justin Cinkelj <justin.cinkelj@xlab.si> --------- Signed-off-by: Justin Cinkelj <justin.cinkelj@xlab.si>
1 parent b8d64d4 commit 9b98606

File tree

27 files changed

+692
-6
lines changed

27 files changed

+692
-6
lines changed

docker/Dockerfile.backend

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ RUN useradd awx -u 1000 -g 0 --home-dir /var/lib/awx -s /bin/bash
7272
RUN python3.12 -m venv /venv
7373
RUN /venv/bin/pip install --upgrade pip wheel
7474
RUN mkdir /code /code/src
75-
COPY requirements.txt /code
76-
RUN /venv/bin/pip install -r /code/requirements.txt
75+
COPY requirements-build.txt /code
76+
RUN /venv/bin/pip install -r /code/requirements-build.txt
7777

7878
# source .env
7979
COPY src/backend /code/src/backend

requirements-build.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,9 @@ uvicorn==0.38.0 \
12581258
--hash=sha256:48c0afd214ceb59340075b4a052ea1ee91c16fbc2a9b1469cca0e54566977b02 \
12591259
--hash=sha256:fd97093bdd120a2609fc0d3afe931d4d4ad688b6e75f0f929fde1bc36fe0e91d
12601260
# via -r requirements-pinned.txt
1261+
uwsgi==2.0.31 \
1262+
--hash=sha256:e8f8b350ccc106ff93a65247b9136f529c14bf96b936ac5b264c6ff9d0c76257
1263+
# via -r requirements-pinned.txt
12611264
weasyprint==66.0 \
12621265
--hash=sha256:82b0783b726fcd318e2c977dcdddca76515b30044bc7a830cc4fbe717582a6d0 \
12631266
--hash=sha256:da71dc87dc129ac9cffdc65e5477e90365ab9dbae45c744014ec1d06303dde40

requirements-pinned.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ split-settings==1.0.0
2323
urllib3==2.5.0
2424
uvicorn==0.38.0
2525

26+
# Deployment dependencies
27+
uwsgi==2.0.31
28+
2629
# Development dependencies
2730
pytest-cov==7.0.0
2831
pytest-django==4.11.1
2932
pytest-mock==3.15.1
3033
pytest==9.0.0
31-
time-machine==2.19.0
34+
time-machine==2.19.0

setup/collections/ansible_collections/ansible/containerized_installer/playbooks/dashboard_install.yml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
name: preflight
1919

2020
- name: Install common container components
21-
hosts: automationcontroller:automationeda:automationhub:database:execution_nodes:automationdashboard
21+
hosts: automationcontroller:automationeda:automationhub:database:execution_nodes:automationdashboard:redis
2222
any_errors_fatal: true
2323
gather_facts: false
2424
become: false
@@ -61,6 +61,45 @@
6161
tasks_from: conf.yml
6262
when: not dashboard_pg_containerized
6363

64+
- name: Install redis cluster cache
65+
hosts: redis
66+
any_errors_fatal: true
67+
gather_facts: false
68+
become: false
69+
tasks:
70+
- name: Install and configure redis cluster tcp socket
71+
ansible.builtin.include_role:
72+
name: redis
73+
vars:
74+
redis_unix_socket: false
75+
redis_cluster: true
76+
when: redis_mode | default('cluster') == 'cluster'
77+
78+
- name: Install the redis cache
79+
hosts: automationcontroller:automationeda:automationgateway:automationhub:automationdashboard
80+
any_errors_fatal: true
81+
gather_facts: false
82+
become: false
83+
tasks:
84+
- name: Install and configure redis unix socket
85+
ansible.builtin.include_role:
86+
name: redis
87+
when: >
88+
inventory_hostname in groups.get('automationcontroller', []) or
89+
inventory_hostname in groups.get('automationhub', []) or
90+
(inventory_hostname in groups.get('automationeda', []) and groups.get('automationeda', []) | length == 1) or
91+
(inventory_hostname in groups.get('automationdashboard', []) and groups.get('automationdashboard', []) | length == 1)
92+
93+
# group automationgateway in not defined when installing only automationdashboard
94+
# - name: Install and configure redis tcp socket
95+
# ansible.builtin.include_role:
96+
# name: redis
97+
# vars:
98+
# redis_unix_socket: false
99+
# when:
100+
# - redis_mode | default('cluster') == 'standalone'
101+
# - inventory_hostname == groups['automationgateway'] | first
102+
64103
- name: Install the Automation Dashboard
65104
any_errors_fatal: true
66105
hosts: automationdashboard

setup/collections/ansible_collections/ansible/containerized_installer/playbooks/dashboard_uninstall.yml

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
- name: Collect services facts
3-
hosts: automationcontroller:automationeda:automationhub:database:execution_nodes:automationdashboard
3+
hosts: automationcontroller:automationeda:automationhub:database:execution_nodes:automationdashboard:redis
44
gather_facts: false
55
become: false
66
tasks:
@@ -24,6 +24,47 @@
2424
name: automationdashboard
2525
tasks_from: uninstall.yml
2626

27+
- name: Uninstall redis cluster
28+
hosts: redis
29+
any_errors_fatal: true
30+
gather_facts: false
31+
become: false
32+
tasks:
33+
- name: Uninstall redis cluster tcp socket
34+
ansible.builtin.include_role:
35+
name: redis
36+
tasks_from: uninstall.yml
37+
vars:
38+
redis_unix_socket: false
39+
redis_cluster: true
40+
when: redis_mode | default('cluster') == 'cluster'
41+
42+
- name: Uninstall redis
43+
hosts: automationcontroller:automationeda:automationgateway:automationhub:automationdashboard
44+
any_errors_fatal: true
45+
gather_facts: false
46+
become: false
47+
tasks:
48+
- name: Uninstall redis unix socket
49+
ansible.builtin.include_role:
50+
name: redis
51+
tasks_from: uninstall.yml
52+
when: >
53+
inventory_hostname in groups.get('automationcontroller', []) or
54+
inventory_hostname in groups.get('automationhub', []) or
55+
(inventory_hostname in groups.get('automationeda', []) and groups.get('automationeda', []) | length == 1) or
56+
(inventory_hostname in groups.get('automationdashboard', []) and groups.get('automationdashboard', []) | length == 1)
57+
58+
# - name: Uninstall redis tcp socket
59+
# ansible.builtin.include_role:
60+
# name: redis
61+
# tasks_from: uninstall.yml
62+
# vars:
63+
# redis_unix_socket: false
64+
# when:
65+
# - redis_mode | default('cluster') == 'standalone'
66+
# - inventory_hostname == groups['automationgateway'] | first
67+
2768
- name: Uninstall the database
2869
hosts: database
2970
gather_facts: false

setup/collections/ansible_collections/ansible/containerized_installer/roles/automationdashboard/tasks/facts.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
- '{{ dashboard_conf_dir }}/launch_dashboard_web.sh:/usr/bin/launch_dashboard_web.sh:ro,z'
5555
# - '{{ receptor_conf_dir }}/receptor.conf:/etc/receptor/receptor.conf:ro,z'
5656
# - 'receptor_run:/run/receptor:U'
57-
# - 'redis_run:/run/redis:z'
57+
- 'redis_run:/run/redis:z'
5858
# - '{{ rsyslog_run_dir }}:/run/awx-rsyslog:z'
5959
- '{{ supervisor_run_dir }}:/run/supervisor:z'
6060
- '{{ dispatcher_run_dir }}:/run/dispatcher:z'

setup/collections/ansible_collections/ansible/containerized_installer/roles/automationdashboard/templates/django_dashboard_conf.py.j2

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
with open("/etc/dashboard/SECRET_KEY") as fin:
2+
SECRET_KEY = fin.read()
3+
14
ALLOWED_HOSTS=["*"]
25
CORS_ALLOWED_ORIGINS = [
36
"http://localhost:8080",
@@ -35,6 +38,8 @@ INITIAL_SYNC_SINCE = "{{ initial_sync_since }}"
3538

3639
DISPATCHERD_DEBUGGING_SOCKFILE = "/run/dispatcher/automation-dashboard-dispatcher.sock"
3740

41+
BROKER_URL = 'unix:///run/redis/redis.sock'
42+
3843
SHOW_URLLIB3_INSECURE_REQUEST_WARNING = {{ show_urllib3_insecure_request_warning | default(True) }}
3944
# django DEBUG=0
4045
DEBUG = {{ django_debug | default(False) }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
### container
3+
container_log_driver: journald
4+
5+
### common
6+
archive_compressed_extension: "tar.gz"
7+
archive_decompressed_extension: "tar"
8+
9+
### backup/restore
10+
redis_use_archive_compression: "{{ use_archive_compression | default(true) }}"
11+
12+
redis_conf_dir: '{{ ansible_user_dir }}/aap/redis'
13+
redis_disable_tls: false
14+
redis_firewall_zone: public
15+
redis_port: 6379
16+
redis_unix_socket: true
17+
redis_cluster: false
18+
redis_cluster_replicas: 1
19+
redis_cluster_port: 16379
20+
...
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
- name: Restart redis
3+
ansible.builtin.systemd:
4+
name: 'redis-{{ _redis_suffix }}.service'
5+
scope: user
6+
state: restarted
7+
...
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
- name: Archive the redis data
3+
ansible.containerized_installer.archive:
4+
path:
5+
- '{{ ansible_user_dir }}/aap/redis'
6+
- '{{ ansible_user_dir }}/aap/tls'
7+
dest: '{{ ansible_user_dir }}/aap/backups/redis.{{ redis_archive_extension }}'
8+
format: '{{ redis_use_archive_compression | bool | ternary(omit, archive_decompressed_extension) }}'
9+
mode: '0640'
10+
11+
- name: Download the redis tarball
12+
ansible.builtin.fetch:
13+
src: '{{ ansible_user_dir }}/aap/backups/redis.{{ redis_archive_extension }}'
14+
dest: '{{ hostvars["localhost"]["_backup_dir"] }}/redis_{{ inventory_hostname }}.{{ redis_archive_extension }}'
15+
flat: true
16+
...

0 commit comments

Comments
 (0)