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

@@ -2,7 +2,7 @@
## Description
WordPress is a versatile and widely used content management system (CMS) that powers millions of websites—from blogs and portfolios to e-commerce and corporate sites. This deployment provides a containerized WordPress instance optimized for multisite operation, advanced media management, and extensive plugin support, allowing you to fully leverage the rich features of the WordPress software.
[WordPress](https://en.wordpress.org/) is a versatile and widely used [content management system (CMS)](https://en.wikipedia.org/wiki/Content_management_system) that powers millions of websites—from blogs and portfolios to e-commerce and corporate sites. This deployment provides a containerized WordPress instance optimized for multisite operation, advanced media management, and extensive plugin support, allowing you to fully leverage the rich features of the WordPress software.
## Overview
@@ -31,6 +31,8 @@ WordPress offers an extensive array of features that make it a robust platform f
This automated Docker Compose deployment streamlines the process by building a custom WordPress image (which includes tools like msmtp for email delivery) and configuring the necessary PHP settings. In doing so, it ensures that your WordPress site is secure, scalable, and always uptodate.
This deployment provides a containerized WordPress instance optimized for multisite operation, advanced media management, and extensive plugin support—including optional integration with Discourse forums.
## Purpose
The goal of this deployment is to provide a productionready, scalable WordPress instance with multisite capabilities and enhanced performance. By automating the custom image build and configuration processes via Docker Compose and Ansible, it minimizes manual intervention, reduces errors, and allows you to concentrate on building great content.
@@ -40,6 +42,7 @@ The goal of this deployment is to provide a productionready, scalable WordPre
- [WordPress Official Website](https://wordpress.org/)
- [WordPress Multisite Documentation](https://wordpress.org/support/article/create-a-network/)
- [WordPress Plugin Repository](https://wordpress.org/plugins/)
- [WP Discourse Plugin](https://wordpress.org/plugins/wp-discourse/)
## Credits

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

View File

@@ -0,0 +1,9 @@
# Defines WP Discourse plugin settings
# @see https://github.com/discourse/wp-discourse
discourse_settings:
publish_discourse_posts: true
discourse_url: "https://{{ domains.discourse }}"
discourse_api_key: "{{ vault_discourse_api_key }}"
discourse_username: "system"
discourse_use_sso: false

View File

@@ -1,10 +0,0 @@
# Defines WP Discourse plugin settings
# @see https://github.com/discourse/wp-discourse
discourse_settings:
publish_discourse_posts: true
discourse_url: "https://{{ domains.discourse }}"
discourse_api_key: "{{ applications.discourse.api_key }}"
discourse_username: "system"
discourse_use_sso: false # You can change this depending on your integration style
discourse_sso_secret: "{{ applications.wordpress.credentials.discourse_sso_secret | default('') }}"