Browse Source

forum: pin discourse & plugins to the latest stable release

Fixes: main/infrastructure#303
keep-around/34709ea3c75007151621309f05154d4115de9044
Loïc Dachary 7 months ago
committed by some
parent
commit
34709ea3c7
Signed by: dachary GPG Key ID: 992D23B392F9E4F2
  1. 5
      docs/release-notes.rst
  2. 7
      docs/services/forum.rst
  3. 2
      playbooks/forum/forum-playbook.yml
  4. 48
      playbooks/forum/roles/discourse/defaults/main.yml
  5. 29
      playbooks/forum/roles/discourse/tasks/main.yml
  6. 12
      playbooks/forum/roles/discourse/templates/app.yml.j2
  7. 9
      playbooks/forum/roles/discourse/templates/version.template.yml.j2
  8. 2
      playbooks/forum/tests/test_discourse.py

5
docs/release-notes.rst

@ -14,6 +14,11 @@ nextcloud
* Reduce `memory requirements <https://lab.enough.community/main/infrastructure/-/issues/321>`__ when downloading files from Nextcloud. It can become a problem when the size of the file is large (i.e. greater than 1GB).
forum
~~~~~
* Pin the `discourse version and the plugins <https://lab.enough.community/main/infrastructure/-/issues/303>`__ to the latest stable release.
2.1.14
------

7
docs/services/forum.rst

@ -2,3 +2,10 @@ Forum
=====
`Discourse <https://discourse.org/>`__ is available at `forum.example.com`.
The user with administrative rights, the
Discourse version and other variables are documented in `this file
<https://lab.enough.community/main/infrastructure/blob/master/playbooks/forum/roles/discourse/defaults/main.yml>`__
and can be modified in the
`~/.enough/example.com/inventory/host_vars/forum-host/forum.yml`
file.

2
playbooks/forum/forum-playbook.yml

@ -9,8 +9,6 @@
- role: docker
- role: discourse
forum_name: Enough
repository: https://github.com/discourse/discourse_docker
- role: enough-nginx
vars:

48
playbooks/forum/roles/discourse/defaults/main.yml

@ -0,0 +1,48 @@
---
#
####################################################
#
# discourse name
#
forum_name: Enough
#
####################################################
#
# discourse user with administrative rights
#
forum_user: "admin@{{ domain }}"
forum_password: "BefShnygs33SwowCifViwag"
#
####################################################
#
# discourse version as found in https://github.com/discourse/discourse/tags
#
forum_discourse_version: v2.6.0
#
####################################################
#
# discourse docker hash commit compatible with forum_discourse_version
#
forum_discourse_docker_version: 333b879a0889db082741a1ae431612a9fa74cb91
#
####################################################
#
# discourse plugins
#
# name: name of the plugin
# url: URL of the plugin
# hash: commit hash compatible with forum_discourse_version
#
forum_plugins:
- name: discourse-chat-integration
url: https://github.com/discourse/discourse-chat-integration
hash: 4c9553725d2f5d802bf45aa2d87516567040cd69
- name: discourse-solved
url: https://github.com/discourse/discourse-solved
hash: 584060102526cca953f270281751034c14b98d67
- name: discourse-events
url: https://github.com/angusmcleod/discourse-events
hash: df9bb0e2c02982605786224262e6abfb085c9056
- name: discourse-locations
url: https://github.com/angusmcleod/discourse-locations
hash: d5a94823bd63374f6616809077a93ebadf051f9a

29
playbooks/forum/roles/discourse/tasks/main.yml

@ -13,14 +13,19 @@
owner: debian
become: true
- name: git clone master {{ repository }}
- name: git clone https://github.com/discourse/discourse_docker
git:
update: no
repo: "{{ repository }}"
version: master
repo: "https://github.com/discourse/discourse_docker"
version: "{{ forum_discourse_docker_version }}"
dest: "/srv/forum/{{ forum_name }}"
become: false
- name: workaround https://meta.discourse.org/t/shallow-git-fetch-regression-in-discourse-docker/172324/16
template:
src: "templates/version.template.yml.j2"
dest: "/srv/forum/{{ forum_name }}/templates/version.template.yml"
become: false
- name: deploy configuration
template:
src: "templates/app.yml.j2"
@ -34,3 +39,19 @@
chdir: "/srv/forum/{{ forum_name }}"
become: false
when: app_config is changed
- name: create API key
shell: |
docker exec app rake 'api_key:create_master[ADMIN]' | tee apikey
args:
chdir: "/srv/forum/{{ forum_name }}"
creates: "/srv/forum/{{ forum_name }}/apikey"
- name: "create {{ forum_user }} user"
shell: |
set -ex
pass="{{ forum_password }}" ; ( echo {{ forum_user }} ; echo "$pass" ; echo "$pass" ; echo ) | docker exec -i app rake 'admin:create'
touch admin_exists
args:
chdir: "/srv/forum/{{ forum_name }}"
creates: "/srv/forum/{{ forum_name }}/admin_exists"

12
playbooks/forum/roles/discourse/templates/app.yml.j2

@ -1,6 +1,7 @@
templates:
- "templates/postgres.template.yml"
- "templates/redis.template.yml"
- "templates/version.template.yml"
- "templates/web.template.yml"
- "templates/web.ratelimited.template.yml"
# - "templates/web.ssl.template.yml"
@ -12,7 +13,7 @@ expose:
params:
db_default_text_search_config: "pg_catalog.english"
version: stable
version: {{ forum_discourse_version }}
env:
LANG: en_US.UTF-8
@ -22,7 +23,7 @@ env:
UNICORN_WORKERS: 2
## The domain name this Discourse instance will respond to
DISCOURSE_HOSTNAME: '{{ forum_vhost_fqdn }}'
DISCOURSE_HOSTNAME: 'forum.{{ domain }}'
## Uncomment if you want the container to be started with the same
## hostname (-h option) as specified above (default "$hostname-$config")
@ -61,10 +62,9 @@ hooks:
cd: $home/plugins
cmd:
- git clone https://github.com/discourse/docker_manager.git
- git clone https://github.com/discourse/discourse-chat-integration.git
- git clone https://github.com/discourse/discourse-solved.git
- git clone https://github.com/angusmcleod/discourse-events.git
- git clone https://github.com/angusmcleod/discourse-locations.git
{% for plugin in forum_plugins %}
- git clone {{ plugin.url }} {{ plugin.name }} ; cd {{ plugin.name }} ; git checkout {{ plugin.hash }}
{% endfor %}
## Any custom commands to run after building
run:

9
playbooks/forum/roles/discourse/templates/version.template.yml.j2

@ -0,0 +1,9 @@
params:
home: /var/www/discourse
run:
- exec:
cd: $home
hook: code
cmd:
- git fetch --tags

2
playbooks/forum/tests/test_discourse.py

@ -6,7 +6,7 @@ def test_discourse(host):
set -xe
sudo apt-get install -y curl
curl --silent https://forum.$(hostname -d) | \
grep --quiet 'Congratulations, you installed Discourse!'
grep --quiet 'Welcome to Discourse'
""")
print(cmd.stdout)
print(cmd.stderr)

Loading…
Cancel
Save