From 9f97dd180d46f536c8d3f6ba6dcd4c1a0e26a4c4 Mon Sep 17 00:00:00 2001 From: Daniel Roberts Date: Fri, 1 Sep 2023 12:14:11 -0500 Subject: [PATCH 01/15] Remove unused template supervisor_task.conf.j2 last usage removed in dbca747e79765a12f8daed01016aba5d4ca1818e --- .../roles/supervisor/templates/supervisor_task.conf.j2 | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 src/commcare_cloud/ansible/roles/supervisor/templates/supervisor_task.conf.j2 diff --git a/src/commcare_cloud/ansible/roles/supervisor/templates/supervisor_task.conf.j2 b/src/commcare_cloud/ansible/roles/supervisor/templates/supervisor_task.conf.j2 deleted file mode 100644 index 6c14b4efd5..0000000000 --- a/src/commcare_cloud/ansible/roles/supervisor/templates/supervisor_task.conf.j2 +++ /dev/null @@ -1,7 +0,0 @@ -; -; {{ ansible_managed }} -; -[program:{{ item.name }}] -{% for key, val in item.config.items() %} -{{ key }}={{ val }} -{% endfor %} From e820de8a7908e068084fb64b00e02d67e0f981ac Mon Sep 17 00:00:00 2001 From: Daniel Roberts Date: Fri, 1 Sep 2023 12:17:11 -0500 Subject: [PATCH 02/15] Introduce supervisor_service_files w/ comment (to be completed) --- src/commcare_cloud/ansible/group_vars/all.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/commcare_cloud/ansible/group_vars/all.yml b/src/commcare_cloud/ansible/group_vars/all.yml index 6a762873a6..ac38fd8b67 100644 --- a/src/commcare_cloud/ansible/group_vars/all.yml +++ b/src/commcare_cloud/ansible/group_vars/all.yml @@ -169,3 +169,16 @@ ansible_become_password: "{{ ansible_sudo_pass }}" # Java version for Formplayer java_17_bin_path: /usr/lib/jvm/java-1.17.0-openjdk-amd64/bin + +# To find this complete list, you can run: +# $ find . -type f | grep templates/supervisor_ +# ./src/commcare_cloud/ansible/roles/commcarehq/templates/supervisor_django.conf.j2 +# ./src/commcare_cloud/ansible/roles/commcarehq/templates/supervisor_celery_beat.conf.j2 +# ./src/commcare_cloud/ansible/roles/commcarehq/templates/supervisor_prometheus.conf.j2 +# ./src/commcare_cloud/ansible/roles/commcarehq/templates/supervisor_pillowtop.conf.j2 +# ./src/commcare_cloud/ansible/roles/commcarehq/templates/supervisor_celery_workers.conf.j2 +# ./src/commcare_cloud/ansible/roles/commcarehq/templates/supervisor_websockets.conf +# ./src/commcare_cloud/ansible/roles/commcarehq/templates/supervisor_formplayer_spring.conf.j2 +# ./src/commcare_cloud/ansible/roles/commcarehq/templates/supervisor_management_commands.conf.j2 +# ./src/commcare_cloud/ansible/roles/commcarehq/templates/supervisor_celery_flower.conf.j2 +supervisor_service_files: From b074b8d069cdd400f7180c2897dfa083c3283612 Mon Sep 17 00:00:00 2001 From: Daniel Roberts Date: Fri, 1 Sep 2023 12:21:04 -0500 Subject: [PATCH 03/15] Use supervisor_service_files.django vars for setting up webworker supervisor confs --- src/commcare_cloud/ansible/group_vars/all.yml | 4 ++++ .../ansible/roles/commcarehq/tasks/webworkers.yml | 10 ++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/commcare_cloud/ansible/group_vars/all.yml b/src/commcare_cloud/ansible/group_vars/all.yml index ac38fd8b67..a9239d2c57 100644 --- a/src/commcare_cloud/ansible/group_vars/all.yml +++ b/src/commcare_cloud/ansible/group_vars/all.yml @@ -182,3 +182,7 @@ java_17_bin_path: /usr/lib/jvm/java-1.17.0-openjdk-amd64/bin # ./src/commcare_cloud/ansible/roles/commcarehq/templates/supervisor_management_commands.conf.j2 # ./src/commcare_cloud/ansible/roles/commcarehq/templates/supervisor_celery_flower.conf.j2 supervisor_service_files: + django: + file_path: "{{ service_home }}/{{ deploy_env }}_supervisor_django.conf" + template: ../templates/supervisor_django.conf.j2 + should_exist: "{{ inventory_hostname in groups['webworkers'] }}" diff --git a/src/commcare_cloud/ansible/roles/commcarehq/tasks/webworkers.yml b/src/commcare_cloud/ansible/roles/commcarehq/tasks/webworkers.yml index 414a72ff02..5d6575bb88 100644 --- a/src/commcare_cloud/ansible/roles/commcarehq/tasks/webworkers.yml +++ b/src/commcare_cloud/ansible/roles/commcarehq/tasks/webworkers.yml @@ -1,18 +1,16 @@ -- set_fact: - supervisor_django: "{{ service_home }}/{{ deploy_env }}_supervisor_django.conf" - - set_fact: webworker_managed_files: - - "{{ supervisor_django }}" + - "{{ supervisor_service_files.django.file_path }}" - name: define django worker service become: yes template: - src: "../templates/supervisor_django.conf.j2" - dest: "{{ supervisor_django }}" + src: "{{ supervisor_service_files.django.template }}" + dest: "{{ supervisor_service_files.django.file_path }}" owner: "{{ cchq_user }}" group: "{{ cchq_user }}" mode: 0644 + when: supervisor_service_files.django.should_exist with_items: - env_vars: http_proxy: "{% if http_proxy_address is defined %}http://{{ http_proxy_address }}:{{ http_proxy_port }}{% endif %}" From b07a6ad43f54f86c401e19546d590cec19b72ef0 Mon Sep 17 00:00:00 2001 From: Daniel Roberts Date: Fri, 1 Sep 2023 12:44:24 -0500 Subject: [PATCH 04/15] Use supervisor_service_files.celery_beat --- src/commcare_cloud/ansible/group_vars/all.yml | 4 ++++ .../ansible/roles/commcarehq/tasks/celery.yml | 15 ++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/commcare_cloud/ansible/group_vars/all.yml b/src/commcare_cloud/ansible/group_vars/all.yml index a9239d2c57..cebc21030f 100644 --- a/src/commcare_cloud/ansible/group_vars/all.yml +++ b/src/commcare_cloud/ansible/group_vars/all.yml @@ -186,3 +186,7 @@ supervisor_service_files: file_path: "{{ service_home }}/{{ deploy_env }}_supervisor_django.conf" template: ../templates/supervisor_django.conf.j2 should_exist: "{{ inventory_hostname in groups['webworkers'] }}" + celery_beat: + file_path: "{{ service_home }}/{{ deploy_env }}_supervisor_celery_beat.conf" + template: ../templates/supervisor_celery_beat.conf.j2 + should_exist: "{{ app_processes_config.celery_processes.get(inventory_hostname).beat is defined }}" diff --git a/src/commcare_cloud/ansible/roles/commcarehq/tasks/celery.yml b/src/commcare_cloud/ansible/roles/commcarehq/tasks/celery.yml index 5661c421c5..e4487599ea 100644 --- a/src/commcare_cloud/ansible/roles/commcarehq/tasks/celery.yml +++ b/src/commcare_cloud/ansible/roles/commcarehq/tasks/celery.yml @@ -3,14 +3,13 @@ - set_fact: celery_bash_runner: "{{ service_home }}/{{ deploy_env }}_celery_bash_runner.sh" supervisor_celery_flower: "{{ service_home }}/{{ deploy_env }}_supervisor_celery_flower.conf" - supervisor_celery_beat: "{{ service_home }}/{{ deploy_env }}_supervisor_celery_beat.conf" supervisor_celery_workers: "{{ service_home }}/{{ deploy_env }}_supervisor_celery_workers.conf" - set_fact: celery_managed_files: - "{{celery_bash_runner}}" - "{{supervisor_celery_flower}}" - - "{{supervisor_celery_beat}}" + - "{{ supervisor_service_files.celery_beat.file_path }}" - "{{supervisor_celery_workers}}" - name: Add celery_bash_runner files @@ -26,18 +25,16 @@ - name: define special celery services template: src: "{{ item.template }}" - dest: "{{ item.file_name }}" + dest: "{{ item.file_path }}" owner: "{{ cchq_user }}" group: "{{ cchq_user }}" mode: 0600 - when: item.should_apply + when: item.should_exist with_items: - template: ../templates/supervisor_celery_flower.conf.j2 - file_name: "{{supervisor_celery_flower}}" - should_apply: "{{ app_processes_config.celery_processes.get(inventory_hostname).flower is defined }}" - - template: ../templates/supervisor_celery_beat.conf.j2 - file_name: "{{supervisor_celery_beat}}" - should_apply: "{{ app_processes_config.celery_processes.get(inventory_hostname).beat is defined }}" + file_path: "{{supervisor_celery_flower}}" + should_exist: "{{ app_processes_config.celery_processes.get(inventory_hostname).flower is defined }}" + - "{{ supervisor_service_files.celery_beat }}" - name: define celery workers template: From 8309d061999974bc753780a43f0c5f155ae930b3 Mon Sep 17 00:00:00 2001 From: Daniel Roberts Date: Fri, 1 Sep 2023 12:49:28 -0500 Subject: [PATCH 05/15] Use supervisor_service_files.celery_flower --- src/commcare_cloud/ansible/group_vars/all.yml | 4 ++++ .../ansible/roles/commcarehq/tasks/celery.yml | 7 ++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/commcare_cloud/ansible/group_vars/all.yml b/src/commcare_cloud/ansible/group_vars/all.yml index cebc21030f..8caaa0582d 100644 --- a/src/commcare_cloud/ansible/group_vars/all.yml +++ b/src/commcare_cloud/ansible/group_vars/all.yml @@ -190,3 +190,7 @@ supervisor_service_files: file_path: "{{ service_home }}/{{ deploy_env }}_supervisor_celery_beat.conf" template: ../templates/supervisor_celery_beat.conf.j2 should_exist: "{{ app_processes_config.celery_processes.get(inventory_hostname).beat is defined }}" + celery_flower: + file_path: "{{ service_home }}/{{ deploy_env }}_supervisor_celery_flower.conf" + template: ../templates/supervisor_celery_flower.conf.j2 + should_exist: "{{ app_processes_config.celery_processes.get(inventory_hostname).flower is defined }}" diff --git a/src/commcare_cloud/ansible/roles/commcarehq/tasks/celery.yml b/src/commcare_cloud/ansible/roles/commcarehq/tasks/celery.yml index e4487599ea..f461bae3b8 100644 --- a/src/commcare_cloud/ansible/roles/commcarehq/tasks/celery.yml +++ b/src/commcare_cloud/ansible/roles/commcarehq/tasks/celery.yml @@ -2,13 +2,12 @@ # validate_app_processes_config(), in app_processes.py, so they don't share a process with another queue. - set_fact: celery_bash_runner: "{{ service_home }}/{{ deploy_env }}_celery_bash_runner.sh" - supervisor_celery_flower: "{{ service_home }}/{{ deploy_env }}_supervisor_celery_flower.conf" supervisor_celery_workers: "{{ service_home }}/{{ deploy_env }}_supervisor_celery_workers.conf" - set_fact: celery_managed_files: - "{{celery_bash_runner}}" - - "{{supervisor_celery_flower}}" + - "{{ supervisor_service_files.celery_flower.file_path }}" - "{{ supervisor_service_files.celery_beat.file_path }}" - "{{supervisor_celery_workers}}" @@ -31,9 +30,7 @@ mode: 0600 when: item.should_exist with_items: - - template: ../templates/supervisor_celery_flower.conf.j2 - file_path: "{{supervisor_celery_flower}}" - should_exist: "{{ app_processes_config.celery_processes.get(inventory_hostname).flower is defined }}" + - "{{ supervisor_service_files.celery_flower }}" - "{{ supervisor_service_files.celery_beat }}" - name: define celery workers From 9a3f73faad3b61dee6294c73151641b098fca88b Mon Sep 17 00:00:00 2001 From: Daniel Roberts Date: Fri, 1 Sep 2023 13:07:58 -0500 Subject: [PATCH 06/15] Use supervisor_service_files.celery_workers --- src/commcare_cloud/ansible/group_vars/all.yml | 4 ++++ .../ansible/roles/commcarehq/tasks/celery.yml | 9 ++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/commcare_cloud/ansible/group_vars/all.yml b/src/commcare_cloud/ansible/group_vars/all.yml index 8caaa0582d..e5301fd086 100644 --- a/src/commcare_cloud/ansible/group_vars/all.yml +++ b/src/commcare_cloud/ansible/group_vars/all.yml @@ -194,3 +194,7 @@ supervisor_service_files: file_path: "{{ service_home }}/{{ deploy_env }}_supervisor_celery_flower.conf" template: ../templates/supervisor_celery_flower.conf.j2 should_exist: "{{ app_processes_config.celery_processes.get(inventory_hostname).flower is defined }}" + celery_workers: + file_path: "{{ service_home }}/{{ deploy_env }}_supervisor_celery_workers.conf" + template: ../templates/supervisor_celery_workers.conf.j2 + should_exist: "{{ app_processes_config.celery_processes.get(inventory_hostname) is defined }}" diff --git a/src/commcare_cloud/ansible/roles/commcarehq/tasks/celery.yml b/src/commcare_cloud/ansible/roles/commcarehq/tasks/celery.yml index f461bae3b8..adbaad5933 100644 --- a/src/commcare_cloud/ansible/roles/commcarehq/tasks/celery.yml +++ b/src/commcare_cloud/ansible/roles/commcarehq/tasks/celery.yml @@ -2,14 +2,13 @@ # validate_app_processes_config(), in app_processes.py, so they don't share a process with another queue. - set_fact: celery_bash_runner: "{{ service_home }}/{{ deploy_env }}_celery_bash_runner.sh" - supervisor_celery_workers: "{{ service_home }}/{{ deploy_env }}_supervisor_celery_workers.conf" - set_fact: celery_managed_files: - "{{celery_bash_runner}}" - "{{ supervisor_service_files.celery_flower.file_path }}" - "{{ supervisor_service_files.celery_beat.file_path }}" - - "{{supervisor_celery_workers}}" + - "{{ supervisor_service_files.celery_workers.file_path }}" - name: Add celery_bash_runner files template: @@ -35,12 +34,12 @@ - name: define celery workers template: - src: "../templates/supervisor_celery_workers.conf.j2" - dest: "{{ supervisor_celery_workers }}" + src: "{{ supervisor_service_files.celery_workers.template }}" + dest: "{{ supervisor_service_files.celery_workers.file_path }}" owner: "{{ cchq_user }}" group: "{{ cchq_user }}" mode: 0644 - when: app_processes_config.celery_processes.get(inventory_hostname) is defined + when: supervisor_service_files.celery_workers.should_exist with_items: - env_vars: http_proxy: "{% if http_proxy_address is defined %}http://{{ http_proxy_address }}:{{ http_proxy_port }}{% endif %}" From dd796c19dc936159d1f2ac83abbbdfe132709093 Mon Sep 17 00:00:00 2001 From: Daniel Roberts Date: Fri, 1 Sep 2023 13:17:02 -0500 Subject: [PATCH 07/15] Use supervisor_service_files.celery_bash_runner --- src/commcare_cloud/ansible/group_vars/all.yml | 6 ++++++ .../ansible/roles/commcarehq/tasks/celery.yml | 11 ++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/commcare_cloud/ansible/group_vars/all.yml b/src/commcare_cloud/ansible/group_vars/all.yml index e5301fd086..4b08743ac6 100644 --- a/src/commcare_cloud/ansible/group_vars/all.yml +++ b/src/commcare_cloud/ansible/group_vars/all.yml @@ -181,6 +181,8 @@ java_17_bin_path: /usr/lib/jvm/java-1.17.0-openjdk-amd64/bin # ./src/commcare_cloud/ansible/roles/commcarehq/templates/supervisor_formplayer_spring.conf.j2 # ./src/commcare_cloud/ansible/roles/commcarehq/templates/supervisor_management_commands.conf.j2 # ./src/commcare_cloud/ansible/roles/commcarehq/templates/supervisor_celery_flower.conf.j2 +# +# The only one not matching this pattern is celery_bash_runner supervisor_service_files: django: file_path: "{{ service_home }}/{{ deploy_env }}_supervisor_django.conf" @@ -198,3 +200,7 @@ supervisor_service_files: file_path: "{{ service_home }}/{{ deploy_env }}_supervisor_celery_workers.conf" template: ../templates/supervisor_celery_workers.conf.j2 should_exist: "{{ app_processes_config.celery_processes.get(inventory_hostname) is defined }}" + celery_bash_runner: + file_path: "{{ service_home }}/{{ deploy_env }}_celery_bash_runner.sh" + template: ../templates/celery_bash_runner.sh.j2 + should_exist: "{{ app_processes_config.celery_processes.get(inventory_hostname) is defined }}" diff --git a/src/commcare_cloud/ansible/roles/commcarehq/tasks/celery.yml b/src/commcare_cloud/ansible/roles/commcarehq/tasks/celery.yml index adbaad5933..b941f3883e 100644 --- a/src/commcare_cloud/ansible/roles/commcarehq/tasks/celery.yml +++ b/src/commcare_cloud/ansible/roles/commcarehq/tasks/celery.yml @@ -1,24 +1,21 @@ # Note: Make sure to add queues with associated tasks to the solo_queues list in # validate_app_processes_config(), in app_processes.py, so they don't share a process with another queue. -- set_fact: - celery_bash_runner: "{{ service_home }}/{{ deploy_env }}_celery_bash_runner.sh" - set_fact: celery_managed_files: - - "{{celery_bash_runner}}" + - "{{ supervisor_service_files.celery_bash_runner.file_path }}" - "{{ supervisor_service_files.celery_flower.file_path }}" - "{{ supervisor_service_files.celery_beat.file_path }}" - "{{ supervisor_service_files.celery_workers.file_path }}" - name: Add celery_bash_runner files template: - src: "../templates/celery_bash_runner.sh.j2" - dest: "{{ item.file_name }}" + src: "{{ supervisor_service_files.celery_bash_runner.template }}" + dest: "{{ supervisor_service_files.celery_bash_runner.file_path }}" owner: "{{ cchq_user }}" group: "{{ cchq_user }}" mode: 0644 - with_items: - - file_name: "{{ celery_bash_runner }}" + when: supervisor_service_files.celery_bash_runner.should_exist - name: define special celery services template: From 99fc0eab2100490d3d842eb01977b690589f2fdf Mon Sep 17 00:00:00 2001 From: Daniel Roberts Date: Fri, 1 Sep 2023 13:23:00 -0500 Subject: [PATCH 08/15] Use supervisor_service_files.formplayer_spring --- src/commcare_cloud/ansible/group_vars/all.yml | 4 ++++ .../ansible/roles/commcarehq/tasks/formplayer.yml | 12 ++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/commcare_cloud/ansible/group_vars/all.yml b/src/commcare_cloud/ansible/group_vars/all.yml index 4b08743ac6..6ab7110b97 100644 --- a/src/commcare_cloud/ansible/group_vars/all.yml +++ b/src/commcare_cloud/ansible/group_vars/all.yml @@ -204,3 +204,7 @@ supervisor_service_files: file_path: "{{ service_home }}/{{ deploy_env }}_celery_bash_runner.sh" template: ../templates/celery_bash_runner.sh.j2 should_exist: "{{ app_processes_config.celery_processes.get(inventory_hostname) is defined }}" + formplayer_spring: + file_path: "{{ service_home }}/{{ deploy_env }}_supervisor_formplayer_spring.conf" + template: ../templates/supervisor_formplayer_spring.conf.j2 + should_exist: "{{ inventory_hostname in groups['formplayer'] }}" diff --git a/src/commcare_cloud/ansible/roles/commcarehq/tasks/formplayer.yml b/src/commcare_cloud/ansible/roles/commcarehq/tasks/formplayer.yml index ffecb05e8c..1d7aba4ba6 100644 --- a/src/commcare_cloud/ansible/roles/commcarehq/tasks/formplayer.yml +++ b/src/commcare_cloud/ansible/roles/commcarehq/tasks/formplayer.yml @@ -1,11 +1,6 @@ -- set_fact: - supervisor_formplayer_spring: "{{ service_home }}/{{ deploy_env }}_supervisor_formplayer_spring.conf" - tags: - - formplayer_deploy - - set_fact: formplayer_managed_files: - - "{{ supervisor_formplayer_spring }}" + - "{{ supervisor_service_files.formplayer_spring.file_path }}" tags: - formplayer_deploy @@ -23,11 +18,12 @@ - name: define formplayer spring services become: yes template: - src: "../templates/supervisor_formplayer_spring.conf.j2" - dest: "{{ supervisor_formplayer_spring }}" + src: "{{ supervisor_service_files.formplayer_spring.template }}" + dest: "{{ supervisor_service_files.formplayer_spring.file_path }}" owner: "{{ cchq_user }}" group: "{{ cchq_user }}" mode: 0644 + when: supervisor_service_files.formplayer_spring.should_exist with_items: - env_vars: http_proxy: "{% if http_proxy_address is defined %}http://{{ http_proxy_address }}:{{ http_proxy_port }}{% endif %}" From a9cd669644cd8009fe847b99e0ee21b61ec94d6f Mon Sep 17 00:00:00 2001 From: Daniel Roberts Date: Fri, 1 Sep 2023 13:27:13 -0500 Subject: [PATCH 09/15] Use supervisor_service_files.management_commands --- src/commcare_cloud/ansible/group_vars/all.yml | 4 ++++ .../roles/commcarehq/tasks/management_commands.yml | 11 ++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/commcare_cloud/ansible/group_vars/all.yml b/src/commcare_cloud/ansible/group_vars/all.yml index 6ab7110b97..61d02f7bf4 100644 --- a/src/commcare_cloud/ansible/group_vars/all.yml +++ b/src/commcare_cloud/ansible/group_vars/all.yml @@ -208,3 +208,7 @@ supervisor_service_files: file_path: "{{ service_home }}/{{ deploy_env }}_supervisor_formplayer_spring.conf" template: ../templates/supervisor_formplayer_spring.conf.j2 should_exist: "{{ inventory_hostname in groups['formplayer'] }}" + management_commands: + file_path: "{{ service_home }}/{{ deploy_env }}_supervisor_management_commands.conf" + template: ../templates/supervisor_management_commands.conf.j2 + should_exist: "{{ app_processes_config.management_commands.get(inventory_hostname, {}) }}" diff --git a/src/commcare_cloud/ansible/roles/commcarehq/tasks/management_commands.yml b/src/commcare_cloud/ansible/roles/commcarehq/tasks/management_commands.yml index 984d7044ee..2d5120f8d6 100644 --- a/src/commcare_cloud/ansible/roles/commcarehq/tasks/management_commands.yml +++ b/src/commcare_cloud/ansible/roles/commcarehq/tasks/management_commands.yml @@ -1,19 +1,16 @@ -- set_fact: - supervisor_management_commands: "{{ service_home }}/{{ deploy_env }}_supervisor_management_commands.conf" - - set_fact: mgmt_cmd_managed_files: - - "{{ supervisor_management_commands }}" + - "{{ supervisor_service_files.management_commands.file_path }}" - name: define management command services become: yes template: - src: "../templates/supervisor_management_commands.conf.j2" - dest: "{{ supervisor_management_commands }}" + src: "{{ supervisor_service_files.management_commands.template }}" + dest: "{{ supervisor_service_files.management_commands.file_path }}" owner: "{{ cchq_user }}" group: "{{ cchq_user }}" mode: 0644 - when: app_processes_config.management_commands.get(inventory_hostname, {}) + when: supervisor_service_files.management_commands.should_exist with_items: - env_vars: TMPDIR: '{{ encrypted_tmp }}' From a3e26575318d5f40155f545d03b71dd8dc2a0e10 Mon Sep 17 00:00:00 2001 From: Daniel Roberts Date: Fri, 1 Sep 2023 13:30:41 -0500 Subject: [PATCH 10/15] Use supervisor_service_files.pillowtop --- src/commcare_cloud/ansible/group_vars/all.yml | 4 ++++ .../ansible/roles/commcarehq/tasks/pillowtop.yml | 10 ++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/commcare_cloud/ansible/group_vars/all.yml b/src/commcare_cloud/ansible/group_vars/all.yml index 61d02f7bf4..dbc35d857e 100644 --- a/src/commcare_cloud/ansible/group_vars/all.yml +++ b/src/commcare_cloud/ansible/group_vars/all.yml @@ -212,3 +212,7 @@ supervisor_service_files: file_path: "{{ service_home }}/{{ deploy_env }}_supervisor_management_commands.conf" template: ../templates/supervisor_management_commands.conf.j2 should_exist: "{{ app_processes_config.management_commands.get(inventory_hostname, {}) }}" + pillowtop: + file_path: "{{ service_home }}/{{ deploy_env }}_supervisor_pillowtop.conf" + template: ../templates/supervisor_pillowtop.conf.j2 + should_exist: "{{ inventory_hostname in groups['pillowtop'] }}" diff --git a/src/commcare_cloud/ansible/roles/commcarehq/tasks/pillowtop.yml b/src/commcare_cloud/ansible/roles/commcarehq/tasks/pillowtop.yml index 85d52d8a65..610af2aa95 100644 --- a/src/commcare_cloud/ansible/roles/commcarehq/tasks/pillowtop.yml +++ b/src/commcare_cloud/ansible/roles/commcarehq/tasks/pillowtop.yml @@ -1,18 +1,16 @@ -- set_fact: - supervisor_pillowtop: "{{ service_home }}/{{ deploy_env }}_supervisor_pillowtop.conf" - - set_fact: pillowtop_managed_files: - - "{{ supervisor_pillowtop }}" + - "{{ supervisor_service_files.pillowtop.file_path }}" - name: define pillowtop services become: yes template: - src: "../templates/supervisor_pillowtop.conf.j2" - dest: "{{ supervisor_pillowtop }}" + src: "{{ supervisor_service_files.pillowtop.template }}" + dest: "{{ supervisor_service_files.pillowtop.file_path }}" owner: "{{ cchq_user }}" group: "{{ cchq_user }}" mode: 0644 + when: supervisor_service_files.pillowtop.should_exist with_items: - env_vars: TMPDIR: '{{ encrypted_tmp }}' From f7d192d47124b474ff7a8ee6bd6ba8a39ac5068d Mon Sep 17 00:00:00 2001 From: Daniel Roberts Date: Fri, 1 Sep 2023 13:34:19 -0500 Subject: [PATCH 11/15] Use supervisor_service_files.websockets --- src/commcare_cloud/ansible/group_vars/all.yml | 4 ++++ .../roles/commcarehq/tasks/proxy_websockets.yml | 10 ++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/commcare_cloud/ansible/group_vars/all.yml b/src/commcare_cloud/ansible/group_vars/all.yml index dbc35d857e..81701b4735 100644 --- a/src/commcare_cloud/ansible/group_vars/all.yml +++ b/src/commcare_cloud/ansible/group_vars/all.yml @@ -216,3 +216,7 @@ supervisor_service_files: file_path: "{{ service_home }}/{{ deploy_env }}_supervisor_pillowtop.conf" template: ../templates/supervisor_pillowtop.conf.j2 should_exist: "{{ inventory_hostname in groups['pillowtop'] }}" + websockets: + file_path: "{{ service_home }}/{{ deploy_env }}_supervisor_websockets.conf" + template: ../templates/supervisor_websockets.conf + should_exist: "{{ inventory_hostname in groups['proxy'] and run_websockets_wsgi }}" diff --git a/src/commcare_cloud/ansible/roles/commcarehq/tasks/proxy_websockets.yml b/src/commcare_cloud/ansible/roles/commcarehq/tasks/proxy_websockets.yml index d8d8b62392..0aa9110f19 100644 --- a/src/commcare_cloud/ansible/roles/commcarehq/tasks/proxy_websockets.yml +++ b/src/commcare_cloud/ansible/roles/commcarehq/tasks/proxy_websockets.yml @@ -1,15 +1,13 @@ -- set_fact: - supervisor_websockets: "{{ service_home }}/{{ deploy_env }}_supervisor_websockets.conf" - - set_fact: proxy_managed_files: - - "{{ supervisor_websockets }}" + - "{{ supervisor_service_files.websockets.file_path }}" - name: define websockets services become: yes template: - src: "../templates/supervisor_websockets.conf" - dest: "{{ supervisor_websockets }}" + src: "{{ supervisor_service_files.websockets.template }}" + dest: "{{ supervisor_service_files.websockets.file_path }}" owner: "{{ cchq_user }}" group: "{{ cchq_user }}" mode: 0644 + when: supervisor_service_files.websockets.should_exist From 599086f9fe80271b32685a6f0998611efe4da0a5 Mon Sep 17 00:00:00 2001 From: Daniel Roberts Date: Fri, 1 Sep 2023 13:38:58 -0500 Subject: [PATCH 12/15] Use supervisor_service_files.prometheus --- src/commcare_cloud/ansible/group_vars/all.yml | 4 ++++ .../ansible/roles/commcarehq/tasks/prometheus.yml | 11 ++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/commcare_cloud/ansible/group_vars/all.yml b/src/commcare_cloud/ansible/group_vars/all.yml index 81701b4735..fac98a4f37 100644 --- a/src/commcare_cloud/ansible/group_vars/all.yml +++ b/src/commcare_cloud/ansible/group_vars/all.yml @@ -220,3 +220,7 @@ supervisor_service_files: file_path: "{{ service_home }}/{{ deploy_env }}_supervisor_websockets.conf" template: ../templates/supervisor_websockets.conf should_exist: "{{ inventory_hostname in groups['proxy'] and run_websockets_wsgi }}" + prometheus: + file_path: "{{ service_home }}/{{ deploy_env }}_supervisor_prometheus.conf" + template: ../templates/supervisor_prometheus.conf.j2 + should_exist: "{{ prometheus_monitoring_enabled|default(False) }}" diff --git a/src/commcare_cloud/ansible/roles/commcarehq/tasks/prometheus.yml b/src/commcare_cloud/ansible/roles/commcarehq/tasks/prometheus.yml index 22f99bcfeb..6bfa487106 100644 --- a/src/commcare_cloud/ansible/roles/commcarehq/tasks/prometheus.yml +++ b/src/commcare_cloud/ansible/roles/commcarehq/tasks/prometheus.yml @@ -1,9 +1,6 @@ -- set_fact: - supervisor_prometheus: "{{ service_home }}/{{ deploy_env }}_supervisor_prometheus.conf" - - set_fact: prometheus_managed_files: - - "{{ supervisor_prometheus }}" + - "{{ supervisor_service_files.prometheus.file_path }}" - name: Creates Prometheus Metrics directory become: yes @@ -17,9 +14,9 @@ - name: define prometheus service become: yes template: - src: "../templates/supervisor_prometheus.conf.j2" - dest: "{{ supervisor_prometheus }}" + src: "{{ supervisor_service_files.prometheus.template }}" + dest: "{{ supervisor_service_files.prometheus.file_path }}" owner: "{{ cchq_user }}" group: "{{ cchq_user }}" mode: 0644 - when: prometheus_monitoring_enabled|default(False) + when: supervisor_service_files.prometheus.should_exist From 23c167d1dc1bb597fd0cfbdf4767fa5691994fb2 Mon Sep 17 00:00:00 2001 From: Daniel Roberts Date: Fri, 1 Sep 2023 13:46:24 -0500 Subject: [PATCH 13/15] Use supervisor_service_files.django_bash_runner --- src/commcare_cloud/ansible/group_vars/all.yml | 7 ++++++- .../roles/commcarehq/tasks/prometheus_django_runner.yml | 8 ++++---- src/commcare_cloud/ansible/roles/commcarehq/vars/main.yml | 3 +-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/commcare_cloud/ansible/group_vars/all.yml b/src/commcare_cloud/ansible/group_vars/all.yml index fac98a4f37..90c0c852ee 100644 --- a/src/commcare_cloud/ansible/group_vars/all.yml +++ b/src/commcare_cloud/ansible/group_vars/all.yml @@ -182,7 +182,7 @@ java_17_bin_path: /usr/lib/jvm/java-1.17.0-openjdk-amd64/bin # ./src/commcare_cloud/ansible/roles/commcarehq/templates/supervisor_management_commands.conf.j2 # ./src/commcare_cloud/ansible/roles/commcarehq/templates/supervisor_celery_flower.conf.j2 # -# The only one not matching this pattern is celery_bash_runner +# The only ones not matching this pattern is celery_bash_runner and django_bash_runner supervisor_service_files: django: file_path: "{{ service_home }}/{{ deploy_env }}_supervisor_django.conf" @@ -224,3 +224,8 @@ supervisor_service_files: file_path: "{{ service_home }}/{{ deploy_env }}_supervisor_prometheus.conf" template: ../templates/supervisor_prometheus.conf.j2 should_exist: "{{ prometheus_monitoring_enabled|default(False) }}" + # only used with prometheus + django_bash_runner: + file_path: "{{ service_home }}/{{ deploy_env }}_django_bash_runner.sh" + template: ../templates/django_bash_runner.sh.j2 + should_exist: "{{ prometheus_monitoring_enabled|default(False) }}" diff --git a/src/commcare_cloud/ansible/roles/commcarehq/tasks/prometheus_django_runner.yml b/src/commcare_cloud/ansible/roles/commcarehq/tasks/prometheus_django_runner.yml index 2dc28c7735..c786e03d2a 100644 --- a/src/commcare_cloud/ansible/roles/commcarehq/tasks/prometheus_django_runner.yml +++ b/src/commcare_cloud/ansible/roles/commcarehq/tasks/prometheus_django_runner.yml @@ -1,13 +1,13 @@ - set_fact: prometheus_django_runner_managed_files: - - "{{ django_bash_runner_path }}" + - "{{ supervisor_service_files.django_bash_runner.file_path }}" - name: Add django_bash_runner become: yes template: - src: "../templates/django_bash_runner.sh.j2" - dest: "{{ django_bash_runner_path }}" + src: "{{ supervisor_service_files.django_bash_runner.template }}" + dest: "{{ supervisor_service_files.django_bash_runner.file_path }}" owner: "{{ cchq_user }}" group: "{{ cchq_user }}" mode: 0644 - when: prometheus_monitoring_enabled|default(False) + when: supervisor_service_files.django_bash_runner.should_exist diff --git a/src/commcare_cloud/ansible/roles/commcarehq/vars/main.yml b/src/commcare_cloud/ansible/roles/commcarehq/vars/main.yml index faac678920..d87efc95e9 100644 --- a/src/commcare_cloud/ansible/roles/commcarehq/vars/main.yml +++ b/src/commcare_cloud/ansible/roles/commcarehq/vars/main.yml @@ -3,8 +3,7 @@ code_source: "{{ code_releases }}/{{ ansible_date_time.date }}_{{ ansible_date_t python_name: python{{ python_version }} virtualenv_source: "{{ code_source }}/python_env-{{ python_version }}" -django_bash_runner_path: "{{ service_home }}/{{ deploy_env }}_django_bash_runner.sh" -django_bash_runner: "/bin/bash {{ django_bash_runner_path }}" +django_bash_runner: "/bin/bash {{ supervisor_service_files.django_bash_runner.file_path }}" django_direct_runner: "{{ virtualenv_home }}/bin/python {{ code_home }}/manage.py" formplayer_java: "{{ formplayer_java_version | default('java') }}" From 3d15ca2e23a4dfaa308454fcc8f02bf33adb4fbf Mon Sep 17 00:00:00 2001 From: Daniel Roberts Date: Fri, 1 Sep 2023 13:55:09 -0500 Subject: [PATCH 14/15] Delete files based on supervisor_service_files file_path and should_exist --- src/commcare_cloud/ansible/deploy_commcarehq.yml | 12 ++---------- .../ansible/roles/commcarehq/tasks/celery.yml | 7 ------- .../ansible/roles/commcarehq/tasks/formplayer.yml | 6 ------ .../roles/commcarehq/tasks/management_commands.yml | 4 ---- .../ansible/roles/commcarehq/tasks/pillowtop.yml | 4 ---- .../ansible/roles/commcarehq/tasks/prometheus.yml | 4 ---- .../commcarehq/tasks/prometheus_django_runner.yml | 4 ---- .../roles/commcarehq/tasks/proxy_websockets.yml | 4 ---- .../ansible/roles/commcarehq/tasks/webworkers.yml | 4 ---- 9 files changed, 2 insertions(+), 47 deletions(-) diff --git a/src/commcare_cloud/ansible/deploy_commcarehq.yml b/src/commcare_cloud/ansible/deploy_commcarehq.yml index 4bf88303b9..b169370ba2 100644 --- a/src/commcare_cloud/ansible/deploy_commcarehq.yml +++ b/src/commcare_cloud/ansible/deploy_commcarehq.yml @@ -104,15 +104,7 @@ - webworkers tasks: - set_fact: - supervisor_files: - - "{{ celery_managed_files|default([]) }}" - - "{{ pillowtop_managed_files|default([]) }}" - - "{{ proxy_managed_files|default([]) }}" - - "{{ webworker_managed_files|default([]) }}" - - "{{ formplayer_managed_files|default([]) }}" - - "{{ mgmt_cmd_managed_files|default([]) }}" - - "{{ prometheus_managed_files|default([]) }}" - - "{{ prometheus_django_runner_managed_files|default([]) }}" + supervisor_files: "{{ supervisor_service_files.values()|selectattr('should_exist')|map(attribute='file_path') }}" - name: "Find supervisor config files" become: true shell: find {{ service_home|quote }} -type f @@ -125,7 +117,7 @@ path: "{{ item }}" state: absent with_items: "{{ contents.stdout_lines }}" - when: item not in supervisor_files|sum(start=[]) + when: item not in supervisor_files tags: services - name: Celery tasks cleanup Cron job diff --git a/src/commcare_cloud/ansible/roles/commcarehq/tasks/celery.yml b/src/commcare_cloud/ansible/roles/commcarehq/tasks/celery.yml index b941f3883e..d30c9ecf2e 100644 --- a/src/commcare_cloud/ansible/roles/commcarehq/tasks/celery.yml +++ b/src/commcare_cloud/ansible/roles/commcarehq/tasks/celery.yml @@ -1,13 +1,6 @@ # Note: Make sure to add queues with associated tasks to the solo_queues list in # validate_app_processes_config(), in app_processes.py, so they don't share a process with another queue. -- set_fact: - celery_managed_files: - - "{{ supervisor_service_files.celery_bash_runner.file_path }}" - - "{{ supervisor_service_files.celery_flower.file_path }}" - - "{{ supervisor_service_files.celery_beat.file_path }}" - - "{{ supervisor_service_files.celery_workers.file_path }}" - - name: Add celery_bash_runner files template: src: "{{ supervisor_service_files.celery_bash_runner.template }}" diff --git a/src/commcare_cloud/ansible/roles/commcarehq/tasks/formplayer.yml b/src/commcare_cloud/ansible/roles/commcarehq/tasks/formplayer.yml index 1d7aba4ba6..d64bad47cf 100644 --- a/src/commcare_cloud/ansible/roles/commcarehq/tasks/formplayer.yml +++ b/src/commcare_cloud/ansible/roles/commcarehq/tasks/formplayer.yml @@ -1,9 +1,3 @@ -- set_fact: - formplayer_managed_files: - - "{{ supervisor_service_files.formplayer_spring.file_path }}" - tags: - - formplayer_deploy - - name: create services home become: yes file: diff --git a/src/commcare_cloud/ansible/roles/commcarehq/tasks/management_commands.yml b/src/commcare_cloud/ansible/roles/commcarehq/tasks/management_commands.yml index 2d5120f8d6..fde3c881ee 100644 --- a/src/commcare_cloud/ansible/roles/commcarehq/tasks/management_commands.yml +++ b/src/commcare_cloud/ansible/roles/commcarehq/tasks/management_commands.yml @@ -1,7 +1,3 @@ -- set_fact: - mgmt_cmd_managed_files: - - "{{ supervisor_service_files.management_commands.file_path }}" - - name: define management command services become: yes template: diff --git a/src/commcare_cloud/ansible/roles/commcarehq/tasks/pillowtop.yml b/src/commcare_cloud/ansible/roles/commcarehq/tasks/pillowtop.yml index 610af2aa95..0f5979c6f6 100644 --- a/src/commcare_cloud/ansible/roles/commcarehq/tasks/pillowtop.yml +++ b/src/commcare_cloud/ansible/roles/commcarehq/tasks/pillowtop.yml @@ -1,7 +1,3 @@ -- set_fact: - pillowtop_managed_files: - - "{{ supervisor_service_files.pillowtop.file_path }}" - - name: define pillowtop services become: yes template: diff --git a/src/commcare_cloud/ansible/roles/commcarehq/tasks/prometheus.yml b/src/commcare_cloud/ansible/roles/commcarehq/tasks/prometheus.yml index 6bfa487106..2312b2d56e 100644 --- a/src/commcare_cloud/ansible/roles/commcarehq/tasks/prometheus.yml +++ b/src/commcare_cloud/ansible/roles/commcarehq/tasks/prometheus.yml @@ -1,7 +1,3 @@ -- set_fact: - prometheus_managed_files: - - "{{ supervisor_service_files.prometheus.file_path }}" - - name: Creates Prometheus Metrics directory become: yes file: diff --git a/src/commcare_cloud/ansible/roles/commcarehq/tasks/prometheus_django_runner.yml b/src/commcare_cloud/ansible/roles/commcarehq/tasks/prometheus_django_runner.yml index c786e03d2a..092c95570f 100644 --- a/src/commcare_cloud/ansible/roles/commcarehq/tasks/prometheus_django_runner.yml +++ b/src/commcare_cloud/ansible/roles/commcarehq/tasks/prometheus_django_runner.yml @@ -1,7 +1,3 @@ -- set_fact: - prometheus_django_runner_managed_files: - - "{{ supervisor_service_files.django_bash_runner.file_path }}" - - name: Add django_bash_runner become: yes template: diff --git a/src/commcare_cloud/ansible/roles/commcarehq/tasks/proxy_websockets.yml b/src/commcare_cloud/ansible/roles/commcarehq/tasks/proxy_websockets.yml index 0aa9110f19..541da57a48 100644 --- a/src/commcare_cloud/ansible/roles/commcarehq/tasks/proxy_websockets.yml +++ b/src/commcare_cloud/ansible/roles/commcarehq/tasks/proxy_websockets.yml @@ -1,7 +1,3 @@ -- set_fact: - proxy_managed_files: - - "{{ supervisor_service_files.websockets.file_path }}" - - name: define websockets services become: yes template: diff --git a/src/commcare_cloud/ansible/roles/commcarehq/tasks/webworkers.yml b/src/commcare_cloud/ansible/roles/commcarehq/tasks/webworkers.yml index 5d6575bb88..19bf917baf 100644 --- a/src/commcare_cloud/ansible/roles/commcarehq/tasks/webworkers.yml +++ b/src/commcare_cloud/ansible/roles/commcarehq/tasks/webworkers.yml @@ -1,7 +1,3 @@ -- set_fact: - webworker_managed_files: - - "{{ supervisor_service_files.django.file_path }}" - - name: define django worker service become: yes template: From 907a668f1141dcd3c4ace68ea858790e130438d8 Mon Sep 17 00:00:00 2001 From: Danny Roberts Date: Fri, 1 Sep 2023 15:38:34 -0500 Subject: [PATCH 15/15] Fix typo in src/commcare_cloud/ansible/group_vars/all.yml --- src/commcare_cloud/ansible/group_vars/all.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commcare_cloud/ansible/group_vars/all.yml b/src/commcare_cloud/ansible/group_vars/all.yml index 90c0c852ee..a009d39e1e 100644 --- a/src/commcare_cloud/ansible/group_vars/all.yml +++ b/src/commcare_cloud/ansible/group_vars/all.yml @@ -182,7 +182,7 @@ java_17_bin_path: /usr/lib/jvm/java-1.17.0-openjdk-amd64/bin # ./src/commcare_cloud/ansible/roles/commcarehq/templates/supervisor_management_commands.conf.j2 # ./src/commcare_cloud/ansible/roles/commcarehq/templates/supervisor_celery_flower.conf.j2 # -# The only ones not matching this pattern is celery_bash_runner and django_bash_runner +# The only ones not matching this pattern are celery_bash_runner and django_bash_runner supervisor_service_files: django: file_path: "{{ service_home }}/{{ deploy_env }}_supervisor_django.conf"