mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-30 15:28:12 +02:00
Different optimations and mig integration. test will fail due to strickter validation checks. need to be cleaned up tomorrow
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
repository: "discourse_repository" # Name of the repository folder
|
||||
repository: "discourse_repository" # Name of the repository folder
|
||||
features:
|
||||
matomo: true
|
||||
css: true
|
||||
@@ -24,12 +24,9 @@ docker:
|
||||
enabled: true
|
||||
redis:
|
||||
enabled: true
|
||||
# This container is propably wrong name.
|
||||
# Chance is high that the name is discourse_application.
|
||||
# @todo check this out and repair it if necessary
|
||||
discourse:
|
||||
name: "discourse"
|
||||
image: "local_discourse/discourse_application" # Necessary to define this for the docker 2 loc backup
|
||||
image: "local_discourse/<< defaults_applications[web-app-discourse].docker.services.discourse.name >>" # Necessary to define this for the docker 2 loc backup
|
||||
backup:
|
||||
no_stop_required: true
|
||||
volumes:
|
||||
|
@@ -1,14 +1,14 @@
|
||||
---
|
||||
- name: "stop and remove discourse container if it exist"
|
||||
docker_container:
|
||||
name: "{{ discourse_name }}"
|
||||
name: "{{ discourse_container }}"
|
||||
state: absent
|
||||
register: container_action
|
||||
failed_when: container_action.failed and 'No such container' not in container_action.msg
|
||||
listen: recreate discourse
|
||||
|
||||
- name: "add central database temporary to {{application_id}}_default"
|
||||
command: docker network connect {{applications | get_app_conf(application_id, 'network', True)}} {{ database_host }}
|
||||
- name: "add central database temporary to {{ discourse_network }}"
|
||||
command: "docker network connect {{ discourse_network }} {{ database_host }}"
|
||||
failed_when: >
|
||||
result.rc != 0 and
|
||||
'already exists in network' not in result.stderr
|
||||
@@ -17,7 +17,7 @@
|
||||
listen: recreate discourse
|
||||
|
||||
- name: rebuild discourse
|
||||
shell: ./launcher rebuild {{ discourse_name }}
|
||||
shell: ./launcher rebuild {{ discourse_container }}
|
||||
args:
|
||||
executable: /bin/bash
|
||||
chdir: "{{docker_repository_directory }}"
|
||||
|
@@ -1,74 +1,79 @@
|
||||
---
|
||||
- name: "reset (if enabled)"
|
||||
include_tasks: reset.yml
|
||||
when: mode_reset | bool and run_once_docker_discourse is not defined
|
||||
- name: "Setup {{ application_id }}"
|
||||
when: run_once_web_app_discourse is not defined
|
||||
block:
|
||||
- name: "reset (if enabled)"
|
||||
include_tasks: reset.yml
|
||||
when: mode_reset | bool
|
||||
|
||||
# Necessary for building: https://chat.openai.com/share/99d258cc-294b-4924-8eef-02fe419bb838
|
||||
- name: install which
|
||||
pacman:
|
||||
name: which
|
||||
state: present
|
||||
when: run_once_docker_discourse is not defined
|
||||
# Necessary for building: https://chat.openai.com/share/99d258cc-294b-4924-8eef-02fe419bb838
|
||||
- name: install which
|
||||
pacman:
|
||||
name: which
|
||||
state: present
|
||||
|
||||
- name: "load docker, db and proxy for {{application_id}}"
|
||||
include_role:
|
||||
name: cmp-db-docker-proxy
|
||||
when: run_once_docker_discourse is not defined
|
||||
- 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
|
||||
when: run_once_docker_discourse is not defined
|
||||
- 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
|
||||
when: run_once_docker_discourse is not defined
|
||||
- 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: discourse_application.yml.j2
|
||||
dest: "{{discourse_application_yml_destination}}"
|
||||
notify: recreate discourse
|
||||
when: run_once_docker_discourse is not defined
|
||||
- name: "copy configuration to {{discourse_application_yml_destination}}"
|
||||
template:
|
||||
src: config.yml.j2
|
||||
dest: "{{ discourse_application_yml_destination }}"
|
||||
notify: recreate discourse
|
||||
|
||||
- name: flush, to recreate discourse app
|
||||
meta: flush_handlers
|
||||
when: run_once_docker_discourse is not defined
|
||||
- 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: "Connect {{ discourse_name }} to network {{ applications | get_app_conf('svc-db-postgres', 'docker.network' ) }}"
|
||||
command: >
|
||||
docker network connect {{ applications | get_app_conf('svc-db-postgres', 'docker.network' ) }} {{ discourse_name }}
|
||||
register: network_connect
|
||||
failed_when: >
|
||||
network_connect.rc != 0 and
|
||||
"Error response from daemon: endpoint with name {{ discourse_name }} already exists in network {{ applications | get_app_conf('svc-db-postgres', 'docker.network' ) }}"
|
||||
not in network_connect.stderr
|
||||
changed_when: network_connect.rc == 0
|
||||
when:
|
||||
- applications | get_app_conf(application_id, 'features.central_database', False)
|
||||
- run_once_docker_discourse is not defined
|
||||
- name: flush, to recreate discourse app
|
||||
meta: flush_handlers
|
||||
|
||||
- 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
|
||||
'is not connected to network {{ discourse_network }}' not in network_disconnect.stderr
|
||||
changed_when: network_disconnect.rc == 0
|
||||
when:
|
||||
- applications | get_app_conf(application_id, 'features.central_database', False)
|
||||
- run_once_docker_discourse is not defined
|
||||
- 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: run the docker_discourse tasks once
|
||||
set_fact:
|
||||
run_once_docker_discourse: true
|
||||
when: run_once_docker_discourse is not defined
|
||||
- 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: "Remove {{ discourse_network }} from {{ database_host }}"
|
||||
command: >
|
||||
docker network disconnect {{ discourse_network }} {{ database_host }}
|
||||
register: network_disconnect
|
||||
failed_when: >
|
||||
network_disconnect.rc != 0 and
|
||||
'is not connected to network {{ discourse_network }}' not in network_disconnect.stderr
|
||||
changed_when: network_disconnect.rc == 0
|
||||
when:
|
||||
- applications | get_app_conf(application_id, 'features.central_database', False)
|
||||
|
||||
- name: run the docker_discourse tasks once
|
||||
set_fact:
|
||||
run_once_web_app_discourse: true
|
||||
when: run_once_web_app_discourse is not defined
|
@@ -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_application"
|
||||
- name: "destroy container {{ discourse_container }}"
|
||||
command:
|
||||
cmd: "./launcher destroy discourse_application"
|
||||
cmd: "./launcher destroy {{ discourse_container }}"
|
||||
chdir: "{{ docker_repository_directory }}"
|
||||
ignore_errors: true
|
||||
notify: recreate discourse
|
@@ -41,7 +41,7 @@ env:
|
||||
UNICORN_WORKERS: 8
|
||||
|
||||
## Required. Discourse will not work with a bare IP number.
|
||||
DISCOURSE_HOSTNAME: {{domains | get_domain(application_id)}}
|
||||
DISCOURSE_HOSTNAME: {{ domains | get_domain(application_id) }}
|
||||
|
||||
## Uncomment if you want the container to be started with the same
|
||||
## hostname (-h option) as specified above (default "$hostname-$config")
|
||||
@@ -139,7 +139,7 @@ run:
|
||||
#- exec: rails r "User.find_by_email('{{ users.administrator.email }}').update(username: '{{users.administrator.username}}')"
|
||||
|
||||
# The following code is just an inspiration, how to connect with the oidc account. as long as this is not set the admini account needs to be manually connected with oidc
|
||||
# docker exec -it discourse_application rails runner "user = User.find_by_email('test@cymais.cloud'); UserAuth.create(user_id: user.id, provider: 'oidc', uid: 'eindeutige_oidc_id', info: { name: user.username, email: user.email })"
|
||||
# docker exec -it {{ discourse_container }} rails runner "user = User.find_by_email('test@cymais.cloud'); UserAuth.create(user_id: user.id, provider: 'oidc', uid: 'eindeutige_oidc_id', info: { name: user.username, email: user.email })"
|
||||
|
||||
# OIDC Activation
|
||||
- exec: rails r "SiteSetting.openid_connect_enabled = true"
|
||||
@@ -178,4 +178,4 @@ run:
|
||||
|
||||
docker_args:
|
||||
- --network={{application_id}}_default
|
||||
- --name={{ discourse_name }}
|
||||
- --name={{ discourse_container }}
|
@@ -1,15 +1,16 @@
|
||||
application_id: "web-app-discourse"
|
||||
|
||||
# Database
|
||||
database_password: "{{ applications | get_app_conf(application_id, 'credentials.database_password', True) }}"
|
||||
database_password: "{{ applications | get_app_conf(application_id, 'credentials.database_password') }}"
|
||||
database_type: "postgres"
|
||||
|
||||
# Discourse
|
||||
discourse_name: "{{ applications | get_app_conf(application_id, 'docker.services.discourse.name', True) }}"
|
||||
discourse_application_yml_destination: "{{ docker_repository_directory }}containers/{{discourse_name }}.yml"
|
||||
discourse_network: "{{ applications | get_app_conf(application_id, 'docker.network', True) }}"
|
||||
discourse_volume: "{{ applications | get_app_conf(application_id, 'docker.volumes.data', True) }}"
|
||||
discourse_container: "{{ applications | get_app_conf(application_id, 'docker.services.discourse.name') }}"
|
||||
discourse_application_yml_destination: "{{ docker_repository_directory }}containers/{{ discourse_container }}.yml"
|
||||
discourse_network: "{{ applications | get_app_conf(application_id, 'docker.network') }}"
|
||||
discourse_volume: "{{ applications | get_app_conf(application_id, 'docker.volumes.data') }}"
|
||||
discourse_pg_network: "{{ applications | get_app_conf('svc-db-postgres', 'docker.network' ) }}"
|
||||
|
||||
# General Docker Configuration
|
||||
docker_repository_directory : "{{ docker_compose.directories.services}}{{applications | get_app_conf(application_id, 'repository', True) }}/"
|
||||
docker_repository_directory : "{{ docker_compose.directories.services}}{{applications | get_app_conf( application_id, 'repository') }}/"
|
||||
docker_compose_flush_handlers: false
|
Reference in New Issue
Block a user