Added wordpress disourse draft

This commit is contained in:
2025-04-22 12:50:48 +02:00
parent e1df746346
commit 3653b3111a
14 changed files with 110 additions and 833 deletions

View File

@@ -0,0 +1,4 @@
# Wordpress with Discourse Support
This folder contains the files to setup Discourse support for Wordpress.
IT's realized with the [WP Discourse Plugin](https://de.wordpress.org/plugins/wp-discourse/)

View File

@@ -0,0 +1,37 @@
- name: "Revoke old WP Discourse API keys via Rails"
command: >
docker exec {{ applications.discourse.container }}
rails runner "
user = User.find_by_username('system')
ApiKey
.where(
user_id: user.id,
description: 'WP Discourse Integration',
revoked_at: nil
)
.update_all(revoked_at: Time.current)
"
args:
chdir: "{{ docker_compose.directories.instance }}"
failed_when: false
- name: "Generate new WP Discourse API key via Rails"
command: >
docker exec {{ applications.discourse.container }}
rails runner "
user = User.find_by_username('system')
ak = ApiKey.create!(
user_id: user.id,
token: SecureRandom.hex,
description: 'WP Discourse Integration'
)
puts ak.token
"
args:
chdir: "{{ docker_compose.directories.instance }}"
register: discourse_generated_api_key
failed_when: false
- name: "Set fact for new WP Discourse API key"
set_fact:
vault_discourse_api_key: "{{ discourse_generated_api_key.stdout_lines[0] }}"

View File

@@ -1,4 +1,17 @@
---
- name: "Include docker-discourse"
include_role:
name: docker-discourse
- name: "Generate Discourse API Key when WP Discourse is enabled"
include_tasks: generate-api-key.yml
# Load after api key generation, so that it can be used
- name: "Include WP Discourse vars"
include_vars:
file: "{{ role_path }}/vars/discourse.yml"
name: discourse_settings
- name: "Install WP Discourse plugin"
command: >
docker-compose exec -u www-data -T application

View File

@@ -38,9 +38,9 @@
include_tasks: install.yml
- name: "Activating OIDC when enabled."
include_tasks: oidc.yml
include_tasks: oidc/install.yml
when: applications[application_id].features.oidc | bool
#- name: "Activating WP Discourse when enabled"
# include_tasks: wp_discourse.yml
# when: applications[application_id].wp_discourse.enabled | bool
- name: "Activating WP Discourse when enabled"
include_tasks: discourse/install.yml
when: applications[application_id].plugins.discourse | bool

View File

@@ -0,0 +1,2 @@
# Wordpress with OIDC
This folder contains the files to setup Wordpress with OIDC.

View File

@@ -7,6 +7,13 @@
args:
chdir: "{{ docker_compose.directories.instance }}"
- name: Wait for Discourse API
wait_for:
host: "{{ domains.discourse }}"
port: 80
delay: 5
timeout: 600
- name: "Activate OpenID Connect Generic Plugin"
command: >
docker-compose exec -u www-data -T application
@@ -16,4 +23,4 @@
chdir: "{{ docker_compose.directories.instance }}"
- name: "Setup OIDC settings"
include_tasks: "oidc_settings.yml"
include_tasks: "settings.yml"

View File

@@ -1,23 +0,0 @@
---
- name: "Create Discourse API key for WordPress integration"
uri:
url: "https://{{ domains.discourse }}/admin/api/keys"
method: POST
headers:
Content-Type: "application/json"
Api-Key: "{{ applications.discourse.master_api_key }}"
Api-Username: "{{ applications.discourse.master_api_username | default('admin') }}"
body_format: json
body:
key:
description: "WP Discourse Integration"
username: "system"
return_content: true
status_code: 200
register: discourse_api_key_response
when: applications.discourse.master_api_key is defined
- name: "Set fact for vault_discourse_api_key"
set_fact:
vault_discourse_api_key: "{{ discourse_api_key_response.json.key.key }}"
when: discourse_api_key_response is defined and discourse_api_key_response.json.key is defined