mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-30 15:28:12 +02:00
Refactoring of discourse role during debugging
This commit is contained in:
@@ -2,74 +2,8 @@
|
||||
include_tasks: 02_reset.yml
|
||||
when: MODE_RESET | bool
|
||||
|
||||
# Necessary for building: https://chat.openai.com/share/99d258cc-294b-4924-8eef-02fe419bb838
|
||||
- name: install which
|
||||
community.general.pacman:
|
||||
name: which
|
||||
state: present
|
||||
- name: "Setup '{{ application_id }}' docker"
|
||||
include_tasks: 03_docker.yml
|
||||
|
||||
- name: "load docker, db and proxy for {{ application_id }}"
|
||||
include_role:
|
||||
name: cmp-db-docker-proxy
|
||||
|
||||
- name: pull docker repository
|
||||
git:
|
||||
repo: "https://github.com/discourse/discourse_docker.git"
|
||||
dest: "{{docker_repository_directory }}"
|
||||
update: yes
|
||||
notify: recreate discourse
|
||||
become: true
|
||||
ignore_errors: true
|
||||
|
||||
- name: set chmod 700 for {{docker_repository_directory }}containers
|
||||
ansible.builtin.file:
|
||||
path: "{{docker_repository_directory }}/containers"
|
||||
mode: '700'
|
||||
state: directory
|
||||
|
||||
- name: "copy configuration to {{discourse_application_yml_destination}}"
|
||||
template:
|
||||
src: config.yml.j2
|
||||
dest: "{{ discourse_application_yml_destination }}"
|
||||
mode: '0640'
|
||||
notify: recreate discourse
|
||||
|
||||
- name: "Verify that '{{ discourse_container }}' is running"
|
||||
command: docker compose ps --filter status=running --format '{{"{{"}}.Name{{"}}"}}' | grep -x {{ discourse_container }}
|
||||
register: docker_ps
|
||||
changed_when: docker_ps.rc == 1
|
||||
failed_when: docker_ps.rc not in [0, 1]
|
||||
notify: recreate discourse
|
||||
|
||||
- name: flush, to recreate discourse app
|
||||
meta: flush_handlers
|
||||
|
||||
- name: Set error string for network already exists
|
||||
set_fact:
|
||||
docker_discourse_already_in_net: "Error response from daemon: endpoint with name {{ discourse_container }} already exists in network {{ discourse_pg_network }}"
|
||||
|
||||
- name: "Connect {{ discourse_container }} to network {{ discourse_pg_network }}"
|
||||
command: >
|
||||
docker network connect {{ discourse_pg_network }} {{ discourse_container }}
|
||||
register: network_connect
|
||||
failed_when: >
|
||||
network_connect.rc != 0 and
|
||||
docker_discourse_already_in_net not in network_connect.stderr
|
||||
changed_when: network_connect.rc == 0
|
||||
when:
|
||||
- applications | get_app_conf(application_id, 'features.central_database', False)
|
||||
|
||||
- name: Set error string for network not connected
|
||||
set_fact:
|
||||
docker_discourse_not_connected: 'is not connected to network {{ discourse_network }}'
|
||||
|
||||
- name: "Remove {{ discourse_network }} from {{ database_host }}"
|
||||
command: >
|
||||
docker network disconnect {{ discourse_network }} {{ database_host }}
|
||||
register: network_disconnect
|
||||
failed_when: >
|
||||
network_disconnect.rc != 0 and
|
||||
docker_discourse_not_connected not in network_disconnect.stderr
|
||||
changed_when: network_disconnect.rc == 0
|
||||
when:
|
||||
- applications | get_app_conf(application_id, 'features.central_database', False)
|
||||
- name: "Setup '{{ application_id }}' network"
|
||||
include_tasks: 04_network.yml
|
@@ -6,9 +6,9 @@
|
||||
cmd: "docker network disconnect {{applications | get_app_conf(application_id, 'network', True)}} {{ database_host }}"
|
||||
ignore_errors: true
|
||||
|
||||
- name: "destroy container {{ discourse_container }}"
|
||||
- name: "destroy container {{ DISCOURSE_CONTAINER }}"
|
||||
command:
|
||||
cmd: "./launcher destroy {{ discourse_container }}"
|
||||
chdir: "{{ docker_repository_directory }}"
|
||||
cmd: "./launcher destroy {{ DISCOURSE_CONTAINER }}"
|
||||
chdir: "{{ DISCOURSE_REPOSITORY_DIR }}"
|
||||
ignore_errors: true
|
||||
notify: recreate discourse
|
43
roles/web-app-discourse/tasks/03_docker.yml
Normal file
43
roles/web-app-discourse/tasks/03_docker.yml
Normal file
@@ -0,0 +1,43 @@
|
||||
# Necessary for building: https://chat.openai.com/share/99d258cc-294b-4924-8eef-02fe419bb838
|
||||
- name: install which
|
||||
community.general.pacman:
|
||||
name: which
|
||||
state: present
|
||||
|
||||
- name: "load docker, db and proxy for {{ application_id }}"
|
||||
include_role:
|
||||
name: cmp-db-docker-proxy
|
||||
vars:
|
||||
docker_compose_flush_handlers: true
|
||||
|
||||
- name: pull docker repository
|
||||
git:
|
||||
repo: "{{ DISCOURSE_REPOSITORY_URL }}"
|
||||
dest: "{{ DISCOURSE_REPOSITORY_DIR }}"
|
||||
update: yes
|
||||
notify: recreate discourse
|
||||
become: true
|
||||
ignore_errors: true
|
||||
|
||||
- name: set chmod 700 for '{{ DISCOURSE_CONTAINERS_DIR}}'
|
||||
ansible.builtin.file:
|
||||
path: "{{ DISCOURSE_CONTAINERS_DIR }}"
|
||||
mode: '700'
|
||||
state: directory
|
||||
|
||||
- name: "copy configuration to '{{ DISCOURSE_APPLICATION_YML_DEST }}'"
|
||||
template:
|
||||
src: config.yml.j2
|
||||
dest: "{{ DISCOURSE_APPLICATION_YML_DEST }}"
|
||||
mode: '0640'
|
||||
notify: recreate discourse
|
||||
|
||||
- name: "Verify that '{{ DISCOURSE_CONTAINER }}' is running"
|
||||
command: docker compose ps --filter status=running --format '{{"{{"}}.Name{{"}}"}}' | grep -x {{ DISCOURSE_CONTAINER }}
|
||||
register: docker_ps
|
||||
changed_when: docker_ps.rc == 1
|
||||
failed_when: docker_ps.rc not in [0, 1]
|
||||
notify: recreate discourse
|
||||
|
||||
- name: flush, to recreate discourse app
|
||||
meta: flush_handlers
|
21
roles/web-app-discourse/tasks/04_network.yml
Normal file
21
roles/web-app-discourse/tasks/04_network.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
- name: "Connect '{{ DISCOURSE_CONTAINER }}' to network '{{ DISCOURSE_PG_NETWORK }}'"
|
||||
command: >
|
||||
docker network connect {{ DISCOURSE_PG_NETWORK }} {{ DISCOURSE_CONTAINER }}
|
||||
register: network_connect
|
||||
failed_when: >
|
||||
network_connect.rc != 0 and
|
||||
DISCOURSE_ERROR_ALREADY_IN_NET not in network_connect.stderr
|
||||
changed_when: network_connect.rc == 0
|
||||
when:
|
||||
- applications | get_app_conf(application_id, 'features.central_database', False)
|
||||
|
||||
- name: "Remove {{ DISCOURSE_NETWORK }} from {{ database_host }}"
|
||||
command: >
|
||||
docker network disconnect {{ DISCOURSE_NETWORK }} {{ database_host }}
|
||||
register: network_disconnect
|
||||
failed_when: >
|
||||
network_disconnect.rc != 0 and
|
||||
DISCOURSE_ERROR_NOT_CONNECTED not in network_disconnect.stderr
|
||||
changed_when: network_disconnect.rc == 0
|
||||
when:
|
||||
- applications | get_app_conf(application_id, 'features.central_database', False)
|
Reference in New Issue
Block a user