minor fixes, add a redlight install section for rapid testing

This commit is contained in:
PC-Admin 2023-08-11 01:51:55 +08:00
parent bb10c3a4b9
commit a707d8a746
14 changed files with 124 additions and 17 deletions

View File

@ -3,3 +3,9 @@ server_name: "penholder.xyz"
postgresql_password: "strong-redacted-password" postgresql_password: "strong-redacted-password"
matrix_admin_email: "perthchat@protonmail.com" matrix_admin_email: "perthchat@protonmail.com"
registration_shared_secret: "strong-redacted-password" registration_shared_secret: "strong-redacted-password"
testing_user: {
"username": "newuser2657",
"password": "strong-redacted-password",
"admin": True
}

View File

@ -3,3 +3,9 @@ server_name: "snowsupport.top"
postgresql_password: "strong-redacted-password" postgresql_password: "strong-redacted-password"
matrix_admin_email: "perthchat@protonmail.com" matrix_admin_email: "perthchat@protonmail.com"
registration_shared_secret: "strong-redacted-password" registration_shared_secret: "strong-redacted-password"
testing_user: {
"username": "newuser2657",
"password": "strong-redacted-password",
"admin": True
}

View File

@ -1,4 +1,4 @@
[matrix_servers] [matrix_servers]
matrix.penholder.xyz ansible_host=matrix.penholder.xyz ansible_ssh_user=root #matrix.penholder.xyz ansible_host=matrix.penholder.xyz ansible_ssh_user=root
#matrix.snowsupport.top ansible_host=matrix.snowsupport.top ansible_ssh_user=root matrix.snowsupport.top ansible_host=matrix.snowsupport.top ansible_ssh_user=root

6
roles/handlers/main.yml Normal file
View File

@ -0,0 +1,6 @@
---
- name: Restart Synapse
service:
name: matrix-synapse
state: restarted

View File

@ -0,0 +1,3 @@
- import_tasks: "{{ role_path }}/tasks/setup_redlight.yml"
tags: ['never', 'setup-redlight']

View File

@ -0,0 +1,63 @@
- name: Ensure /opt/synapse_modules directory exists
file:
path: /opt/synapse_modules
state: directory
owner: matrix-synapse
group: matrix-synapse
mode: '0755'
- name: Add PYTHONPATH to /lib/systemd/system/matrix-synapse.service file
lineinfile:
path: /lib/systemd/system/matrix-synapse.service
insertafter: "^[Service]"
regexp: '^Environment="PYTHONPATH=.*'
line: 'Environment="PYTHONPATH=$PYTHONPATH:/opt/synapse_modules"'
owner: root
group: root
mode: '0644'
- name: Reload systemd daemon
systemd:
daemon_reload: yes
- name: Ensure rsync is installed
apt:
name: rsync
state: present
- name: Clone redlight module to /tmp
git:
repo: https://code.glowers.club/PC-Admin/redlight.git
dest: /tmp/redlight
version: main
force: yes
- name: Synchronize /tmp/redlight content to /opt/synapse_modules/
synchronize:
src: /tmp/redlight/
dest: /opt/synapse_modules/
delete: yes
- name: Change ownership of /opt/synapse_modules/
file:
path: /opt/synapse_modules/
owner: matrix-synapse
group: matrix-synapse
recurse: yes
state: directory
- name: Add modules to homeserver.yaml
blockinfile:
path: /etc/matrix-synapse/homeserver.yaml
block: |
modules:
- module: hello_world_module.HelloWorldModule
config: {} # No specific configuration for this module
- module: abuse_lookup_module.AbuseLookupModule
config: {}
state: present
owner: root
group: root
mode: '0644'
notify: Restart Synapse

View File

@ -1,4 +1,4 @@
---
- name: Install Certbot - name: Install Certbot
apt: apt:
name: certbot name: certbot

View File

@ -1,4 +1,4 @@
---
- name: Install NGINX - name: Install NGINX
apt: apt:
name: nginx name: nginx
@ -16,3 +16,15 @@
src: "/etc/nginx/sites-available/{{ server_name }}" src: "/etc/nginx/sites-available/{{ server_name }}"
dest: "/etc/nginx/sites-enabled/{{ server_name }}" dest: "/etc/nginx/sites-enabled/{{ server_name }}"
state: link state: link
- name: Remove default Nginx Config
file:
path: /etc/nginx/sites-enabled/default
state: absent
notify: Restart Nginx
- name: Remove 'matrix' Nginx Config
file:
path: /etc/nginx/sites-enabled/matrix
state: absent
notify: Restart Nginx

View File

@ -27,11 +27,11 @@
state: absent state: absent
notify: Restart Nginx notify: Restart Nginx
- name: Set Synapse Cache Factor # - name: Set Synapse Cache Factor
lineinfile: # lineinfile:
path: /etc/default/matrix-synapse # path: /etc/default/matrix-synapse
regexp: '^SYNAPSE_CACHE_FACTOR=' # regexp: '^SYNAPSE_CACHE_FACTOR='
line: 'SYNAPSE_CACHE_FACTOR=2.0' # line: 'SYNAPSE_CACHE_FACTOR=2.0'
state: present # state: present
create: yes # create: yes
notify: Restart Synapse # notify: Restart Synapse

View File

@ -0,0 +1,4 @@
- name: Create Testing User
shell: |
sudo -u matrix-synapse python3 /opt/venvs/matrix-synapse/lib/python3.11/site-packages/synapse/_scripts/register_new_matrix_user.py -c /etc/matrix-synapse/homeserver.yaml http://localhost:8008 --user {{ testing_user.username }} --password {{ testing_user.password }}

View File

@ -3,7 +3,7 @@
become: yes become: yes
template: template:
src: "{{ role_path }}/templates/nginx-element.conf.j2" src: "{{ role_path }}/templates/nginx-element.conf.j2"
dest: "/etc/nginx/sites-available/element.{{ server_name}}.conf" dest: "/etc/nginx/sites-available/element"
owner: root owner: root
group: root group: root
mode: '0644' mode: '0644'
@ -12,8 +12,8 @@
- name: Create symbolic link for NGINX config - name: Create symbolic link for NGINX config
become: yes become: yes
file: file:
src: /etc/nginx/sites-available/element.{{ server_name}}.conf src: /etc/nginx/sites-available/element
dest: /etc/nginx/sites-enabled/element.{{ server_name}}.conf dest: /etc/nginx/sites-enabled/element
state: link state: link
force: yes force: yes

View File

@ -17,3 +17,7 @@
# Install Element Web # Install Element Web
- import_tasks: "{{ role_path }}/tasks/element_setup.yml" - import_tasks: "{{ role_path }}/tasks/element_setup.yml"
tags: install-element tags: install-element
# Create Admin User
- import_tasks: "{{ role_path }}/tasks/create_admin_user.yml"
tags: create-admin-user

View File

@ -29,3 +29,5 @@ allow_public_rooms_over_federation: true
enable_registration: false enable_registration: false
admin_contact: "mailto:{{ matrix_admin_email }}" admin_contact: "mailto:{{ matrix_admin_email }}"
registration_shared_secret: "{{ registration_shared_secret }}" registration_shared_secret: "{{ registration_shared_secret }}"
caches:
global_factor: 1.0

View File

@ -5,3 +5,4 @@
roles: roles:
- setup-synapse - setup-synapse
- setup-redlight