Merge branch 'master' into 'change_default_soft'
# Conflicts: # roles/baseconfig/tasks/main.yml
This commit is contained in:
commit
fa7aa8ea75
33 changed files with 383 additions and 94 deletions
|
@ -1,6 +1,18 @@
|
||||||
---
|
---
|
||||||
image: quay.io/ansible/molecule:2.19
|
image: python:3.6
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- lint
|
||||||
|
|
||||||
yamllint:
|
yamllint:
|
||||||
script: yamllint -c .yamllint.yml .
|
stage: lint
|
||||||
|
script:
|
||||||
|
- pip install yamllint==1.15.0
|
||||||
|
- yamllint -c .yamllint.yml .
|
||||||
|
|
||||||
|
ansible-lint:
|
||||||
|
stage: lint
|
||||||
|
script:
|
||||||
|
- pip install ansible-lint==4.0.0
|
||||||
|
- ansible-lint *.yml
|
||||||
...
|
...
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
# Playbook et rôles Ansible d'Aurore
|
# Playbook et rôles Ansible d'Aurore
|
||||||
|
|
||||||
|
Ces politiques de déployement nécessite Ansible 2.7 ou plus récent.
|
||||||
|
Le paquet dans Debian Buster est suffisamment à jour, sinon vous pouvez l'obtenir de la façon suivante :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip3 install --user ansible
|
||||||
|
```
|
||||||
|
|
||||||
## Exécution d'un playbook
|
## Exécution d'un playbook
|
||||||
|
|
||||||
Pour appliquer le playbook `base.yml` :
|
Pour appliquer le playbook `base.yml` :
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
# Install Matrix Synapse on corresponding containers
|
# Install Matrix Synapse on corresponding containers
|
||||||
- hosts: synapse.adm.auro.re
|
- hosts: synapse.adm.auro.re
|
||||||
vars:
|
vars:
|
||||||
mxisd_version: 1.3.1
|
mxisd_releases: https://github.com/kamax-matrix/mxisd/releases
|
||||||
synapse_rest_auth_url: https://raw.githubusercontent.com/kamax-matrix/matrix-synapse-rest-auth/master/rest_auth_provider.py
|
mxisd_deb: "{{ mxisd_releases }}/download/v1.3.1/mxisd_1.3.1_all.deb"
|
||||||
roles:
|
roles:
|
||||||
- debian-backports
|
- debian-backports
|
||||||
- matrix-synapse
|
- matrix-synapse
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
name: apt-listchanges
|
name: apt-listchanges
|
||||||
state: present
|
state: present
|
||||||
update_cache: true
|
update_cache: true
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
|
||||||
# Send email when there is something new
|
# Send email when there is something new
|
||||||
- name: Configure apt-listchanges
|
- name: Configure apt-listchanges
|
||||||
|
|
|
@ -3,11 +3,7 @@
|
||||||
- name: Install basic tools
|
- name: Install basic tools
|
||||||
when: ansible_os_family == "Debian"
|
when: ansible_os_family == "Debian"
|
||||||
apt:
|
apt:
|
||||||
name: "{{ packages }}"
|
name:
|
||||||
state: present
|
|
||||||
update_cache: true
|
|
||||||
vars:
|
|
||||||
packages:
|
|
||||||
- bash-completion # for bash users
|
- bash-completion # for bash users
|
||||||
- zsh # alternative shell
|
- zsh # alternative shell
|
||||||
- sudo # to gain root access
|
- sudo # to gain root access
|
||||||
|
@ -19,6 +15,10 @@
|
||||||
- tree # create a graphical tree of files
|
- tree # create a graphical tree of files
|
||||||
- acl # for Ansible become support
|
- acl # for Ansible become support
|
||||||
- screen # Vulcain asked for this
|
- screen # Vulcain asked for this
|
||||||
|
update_cache: true
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
|
||||||
# Pimp my server
|
# Pimp my server
|
||||||
- name: Customize motd
|
- name: Customize motd
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
name: molly-guard
|
name: molly-guard
|
||||||
state: present
|
state: present
|
||||||
update_cache: true
|
update_cache: true
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
|
||||||
# Always ask for hostname
|
# Always ask for hostname
|
||||||
- name: Configure molly-guard
|
- name: Configure molly-guard
|
||||||
|
|
|
@ -22,4 +22,4 @@
|
||||||
- /usr/bin/chfn # With re2o
|
- /usr/bin/chfn # With re2o
|
||||||
- /bin/mount # Only root should mount
|
- /bin/mount # Only root should mount
|
||||||
- /bin/umount # Only root should umount
|
- /bin/umount # Only root should umount
|
||||||
ignore_errors: yes # Sometimes file won't exist
|
ignore_errors: true # Sometimes file won't exist
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# Build front-end bundle
|
# Build front-end bundle
|
||||||
# This can take very long and requires > 2GB of RAM
|
# This can take very long and requires > 2GB of RAM
|
||||||
- name: Build front-end for CodiMD
|
- name: Build front-end for CodiMD
|
||||||
command: NODE_ENV="production" yarn run build
|
command: yarn run build
|
||||||
args:
|
args:
|
||||||
chdir: /var/local/codimd/codimd
|
chdir: /var/local/codimd/codimd
|
||||||
become: true
|
become: true
|
||||||
|
@ -10,4 +10,5 @@
|
||||||
|
|
||||||
# Reload systemd daemons when a service file changes
|
# Reload systemd daemons when a service file changes
|
||||||
- name: Reload systemd daemons
|
- name: Reload systemd daemons
|
||||||
command: systemctl daemon-reload
|
systemd:
|
||||||
|
daemon_reload: true
|
||||||
|
|
|
@ -9,20 +9,37 @@
|
||||||
dest: /etc/apt/preferences.d/nodejs
|
dest: /etc/apt/preferences.d/nodejs
|
||||||
mode: 0644
|
mode: 0644
|
||||||
|
|
||||||
# TODO
|
# For HTTPS apt
|
||||||
# apt-transport-https
|
- name: Install HTTPS apt
|
||||||
# curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
|
apt:
|
||||||
# echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
|
name: apt-transport-https
|
||||||
|
update_cache: true
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
|
||||||
|
- name: Configure the apt key
|
||||||
|
apt_key:
|
||||||
|
url: https://dl.yarnpkg.com/debian/pubkey.gpg
|
||||||
|
id: 1646B01B86E50310
|
||||||
|
register: apt_key_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_key_result is succeeded
|
||||||
|
|
||||||
|
- name: Configure Yarn repository
|
||||||
|
apt_repository:
|
||||||
|
repo: "deb https://dl.yarnpkg.com/debian/ stable main"
|
||||||
|
|
||||||
# Install CodiMD dependencies
|
# Install CodiMD dependencies
|
||||||
- name: Install required packages
|
- name: Install required packages
|
||||||
apt:
|
apt:
|
||||||
name: "{{ item }}"
|
name:
|
||||||
state: present
|
|
||||||
update_cache: true
|
|
||||||
with_items:
|
|
||||||
- git
|
- git
|
||||||
- nodejs
|
- nodejs
|
||||||
- npm
|
- npm
|
||||||
- build-essential
|
- build-essential
|
||||||
- yarn
|
- yarn
|
||||||
|
update_cache: true
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
- name: Create CodiMD system group
|
- name: Create CodiMD system group
|
||||||
group:
|
group:
|
||||||
name: codimd
|
name: codimd
|
||||||
system: yes
|
system: true
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
# Security #2
|
# Security #2
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
group: codimd
|
group: codimd
|
||||||
home: /var/local/codimd
|
home: /var/local/codimd
|
||||||
comment: CodiMD
|
comment: CodiMD
|
||||||
system: yes
|
system: true
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
# Security #3
|
# Security #3
|
||||||
|
|
|
@ -16,12 +16,15 @@
|
||||||
notify: Build front-end for CodiMD
|
notify: Build front-end for CodiMD
|
||||||
|
|
||||||
# Setup dependencies and configs
|
# Setup dependencies and configs
|
||||||
- name: Install CodiMD depedencies
|
- name: Install CodiMD dependencies
|
||||||
command: NODE_ENV="production" bin/setup
|
yarn:
|
||||||
args:
|
path: /var/local/codimd/codimd
|
||||||
chdir: /var/local/codimd/codimd
|
production: true
|
||||||
become: true
|
become: true
|
||||||
become_user: codimd
|
become_user: codimd
|
||||||
|
register: yarn_result
|
||||||
|
retries: 3
|
||||||
|
until: yarn_result is succeeded
|
||||||
|
|
||||||
# Connection to database
|
# Connection to database
|
||||||
- name: Connect CodiMD to PostgreSQL db
|
- name: Connect CodiMD to PostgreSQL db
|
||||||
|
|
|
@ -24,3 +24,6 @@
|
||||||
apt:
|
apt:
|
||||||
name: dokuwiki
|
name: dokuwiki
|
||||||
update_cache: true
|
update_cache: true
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
---
|
---
|
||||||
# Reload systemd daemons when a service file changes
|
# Reload systemd daemons when a service file changes
|
||||||
- name: Reload systemd daemons
|
- name: Reload systemd daemons
|
||||||
command: systemctl daemon-reload
|
systemd:
|
||||||
|
daemon_reload: true
|
||||||
|
|
|
@ -12,12 +12,13 @@
|
||||||
# Install EtherPad dependencies
|
# Install EtherPad dependencies
|
||||||
- name: Install required packages
|
- name: Install required packages
|
||||||
apt:
|
apt:
|
||||||
name: "{{ item }}"
|
name:
|
||||||
state: present
|
|
||||||
update_cache: true
|
|
||||||
with_items:
|
|
||||||
- build-essential
|
- build-essential
|
||||||
- curl
|
- curl
|
||||||
- git
|
- git
|
||||||
- nodejs
|
- nodejs
|
||||||
- npm
|
- npm
|
||||||
|
update_cache: true
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
- name: Create EtherPad system group
|
- name: Create EtherPad system group
|
||||||
group:
|
group:
|
||||||
name: etherpad
|
name: etherpad
|
||||||
system: yes
|
system: true
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
# Security #2
|
# Security #2
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
group: etherpad
|
group: etherpad
|
||||||
home: /var/local/etherpad
|
home: /var/local/etherpad
|
||||||
comment: EtherPad
|
comment: EtherPad
|
||||||
system: yes
|
system: true
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
# Security #3
|
# Security #3
|
||||||
|
|
|
@ -10,19 +10,38 @@
|
||||||
git:
|
git:
|
||||||
repo: https://github.com/ether/etherpad-lite.git
|
repo: https://github.com/ether/etherpad-lite.git
|
||||||
dest: /var/local/etherpad/etherpad-lite
|
dest: /var/local/etherpad/etherpad-lite
|
||||||
version: master
|
version: 1.7.5
|
||||||
become: true
|
become: true
|
||||||
become_user: etherpad
|
become_user: etherpad
|
||||||
|
|
||||||
# Installation script
|
# Installation script bin/installDeps.sh (1)
|
||||||
# TODO: move this in a handler
|
- name: Create node_modules directory
|
||||||
- name: Install Etherpad dependencies
|
file:
|
||||||
command: bin/installDeps.sh
|
path: /var/local/etherpad/etherpad-lite/node_modules
|
||||||
args:
|
state: directory
|
||||||
chdir: /var/local/etherpad/etherpad-lite
|
|
||||||
become: true
|
become: true
|
||||||
become_user: etherpad
|
become_user: etherpad
|
||||||
|
|
||||||
|
# Installation script bin/installDeps.sh (2)
|
||||||
|
- name: Create symbolic link to EtherPad src
|
||||||
|
file:
|
||||||
|
src: /var/local/etherpad/etherpad-lite/src
|
||||||
|
dest: /var/local/etherpad/etherpad-lite/node_modules/ep_etherpad-lite
|
||||||
|
state: link
|
||||||
|
become: true
|
||||||
|
become_user: etherpad
|
||||||
|
|
||||||
|
# Installation script bin/installDeps.sh (3)
|
||||||
|
# TODO --no-save
|
||||||
|
- name: Install Etherpad dependencies
|
||||||
|
npm:
|
||||||
|
path: /var/local/etherpad/etherpad-lite/node_modules/ep_etherpad-lite
|
||||||
|
become: true
|
||||||
|
become_user: etherpad
|
||||||
|
register: npm_result
|
||||||
|
retries: 3
|
||||||
|
until: npm_result is succeeded
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
- name: Configure EtherPad
|
- name: Configure EtherPad
|
||||||
lineinfile:
|
lineinfile:
|
||||||
|
@ -32,7 +51,7 @@
|
||||||
with_dict:
|
with_dict:
|
||||||
title: " \"title\": \"Etherpad Aurore\","
|
title: " \"title\": \"Etherpad Aurore\","
|
||||||
dbType: " \"dbType\" : \"postgres\","
|
dbType: " \"dbType\" : \"postgres\","
|
||||||
defaultPadText: " \"defaultPadText\" : \"Bienvenue sur l'EtherPad d'Aurore !\\n\\nCe pad est synchronisé avec les autres utilisateur·rice·s présent·e·s sur cette page.\\n\","
|
defaultPadText: " \"defaultPadText\" : \"Bienvenue sur l'EtherPad d'Aurore !\\n\\nCe pad est public.\\n\","
|
||||||
lang: " \"lang\": \"fr-fr\""
|
lang: " \"lang\": \"fr-fr\""
|
||||||
|
|
||||||
# Service file
|
# Service file
|
||||||
|
@ -50,10 +69,8 @@
|
||||||
service:
|
service:
|
||||||
name: etherpad-lite
|
name: etherpad-lite
|
||||||
state: started
|
state: started
|
||||||
enabled: True
|
enabled: true
|
||||||
|
|
||||||
# La configuration de la clé `dbSettings` n'est pas encore automatisé !
|
|
||||||
|
|
||||||
# TODO-list
|
# TODO-list
|
||||||
# * Configure admin user, logs
|
# La configuration de la clé `dbSettings` n'est pas encore automatisé !
|
||||||
# Plugins : https://framacloud.org/fr/cultiver-son-jardin/etherpad.html#concernant-framapad
|
# * Configure logs
|
||||||
|
|
|
@ -2,13 +2,14 @@
|
||||||
# Install LDAP client packages
|
# Install LDAP client packages
|
||||||
- name: Install LDAP client packages
|
- name: Install LDAP client packages
|
||||||
apt:
|
apt:
|
||||||
name: "{{ item }}"
|
name:
|
||||||
state: present
|
|
||||||
update_cache: true
|
|
||||||
with_items:
|
|
||||||
- nslcd
|
- nslcd
|
||||||
- libnss-ldapd
|
- libnss-ldapd
|
||||||
- libpam-ldapd
|
- libpam-ldapd
|
||||||
|
update_cache: true
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
|
||||||
# Reduce LDAP load
|
# Reduce LDAP load
|
||||||
# For the moment it is broken on Stretch when using PHP7.3
|
# For the moment it is broken on Stretch when using PHP7.3
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
package:
|
package:
|
||||||
name: sudo
|
name: sudo
|
||||||
state: present
|
state: present
|
||||||
|
register: package_result
|
||||||
|
retries: 3
|
||||||
|
until: package_result is succeeded
|
||||||
|
|
||||||
# Set sudo group
|
# Set sudo group
|
||||||
- name: Configure sudoers
|
- name: Configure sudoers
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
name: slapd
|
name: slapd
|
||||||
state: present
|
state: present
|
||||||
update_cache: true
|
update_cache: true
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
|
||||||
# What is written after is really not a nice way to install a schema
|
# What is written after is really not a nice way to install a schema
|
||||||
# because the LDAP is being flushed away always...
|
# because the LDAP is being flushed away always...
|
||||||
|
@ -48,7 +51,7 @@
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
owner: openldap
|
owner: openldap
|
||||||
group: openldap
|
group: openldap
|
||||||
recurse: yes
|
recurse: true
|
||||||
with_items:
|
with_items:
|
||||||
- '/var/lib/ldap'
|
- '/var/lib/ldap'
|
||||||
- '/etc/ldap/slapd.d'
|
- '/etc/ldap/slapd.d'
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
---
|
---
|
||||||
# Reload systemd daemons when a service file changes
|
# Reload systemd daemons when a service file changes
|
||||||
- name: Reload systemd daemons
|
- name: Reload systemd daemons
|
||||||
command: systemctl daemon-reload
|
systemd:
|
||||||
|
daemon_reload: true
|
||||||
|
|
|
@ -10,11 +10,12 @@
|
||||||
|
|
||||||
- name: Install required packages
|
- name: Install required packages
|
||||||
apt:
|
apt:
|
||||||
name: "{{ item }}"
|
name:
|
||||||
state: present
|
|
||||||
update_cache: true
|
|
||||||
with_items:
|
|
||||||
- git
|
- git
|
||||||
- nodejs
|
- nodejs
|
||||||
- npm
|
- npm
|
||||||
- build-essential
|
- build-essential
|
||||||
|
update_cache: true
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
- name: Create matrix-appservice-discord system group
|
- name: Create matrix-appservice-discord system group
|
||||||
group:
|
group:
|
||||||
name: matrix-appservice-discord
|
name: matrix-appservice-discord
|
||||||
system: yes
|
system: true
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
# Security #2
|
# Security #2
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
group: matrix-appservice-discord
|
group: matrix-appservice-discord
|
||||||
home: /var/local/matrix-appservice-discord
|
home: /var/local/matrix-appservice-discord
|
||||||
comment: Matrix Appservice Discord
|
comment: Matrix Appservice Discord
|
||||||
system: yes
|
system: true
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
# Security #3
|
# Security #3
|
||||||
|
|
|
@ -15,18 +15,23 @@
|
||||||
become_user: matrix-appservice-discord
|
become_user: matrix-appservice-discord
|
||||||
|
|
||||||
# Setup dependencies
|
# Setup dependencies
|
||||||
- name: Install matrix-appservice-discord depedencies
|
# May create issues with package-lock.json not in gitignore
|
||||||
command: npm ci
|
- name: Install matrix-appservice-discord dependencies
|
||||||
args:
|
npm:
|
||||||
chdir: /var/local/matrix-appservice-discord/matrix-appservice-discord
|
path: /var/local/matrix-appservice-discord/matrix-appservice-discord
|
||||||
become: true
|
become: true
|
||||||
become_user: matrix-appservice-discord
|
become_user: matrix-appservice-discord
|
||||||
|
register: npm_result
|
||||||
|
retries: 3
|
||||||
|
until: npm_result is succeeded
|
||||||
|
|
||||||
# Typescript into javascript
|
# Typescript into javascript
|
||||||
- name: Compile matrix-appservice-discord
|
- name: Compile matrix-appservice-discord
|
||||||
command: npm run build
|
command: ./node_modules/.bin/tsc
|
||||||
args:
|
args:
|
||||||
chdir: /var/local/matrix-appservice-discord/matrix-appservice-discord
|
chdir: /var/local/matrix-appservice-discord/matrix-appservice-discord
|
||||||
|
register: npm_build_result
|
||||||
|
changed_when: npm_build_result
|
||||||
become: true
|
become: true
|
||||||
become_user: matrix-appservice-discord
|
become_user: matrix-appservice-discord
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
---
|
---
|
||||||
# Reload systemd daemons when a service file changes
|
# Reload systemd daemons when a service file changes
|
||||||
- name: Reload systemd daemons
|
- name: Reload systemd daemons
|
||||||
command: systemctl daemon-reload
|
systemd:
|
||||||
|
daemon_reload: true
|
||||||
|
|
|
@ -10,11 +10,12 @@
|
||||||
|
|
||||||
- name: Install required packages
|
- name: Install required packages
|
||||||
apt:
|
apt:
|
||||||
name: "{{ item }}"
|
name:
|
||||||
state: present
|
|
||||||
update_cache: true
|
|
||||||
with_items:
|
|
||||||
- git
|
- git
|
||||||
- nodejs
|
- nodejs
|
||||||
- npm
|
- npm
|
||||||
- build-essential
|
- build-essential
|
||||||
|
update_cache: true
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
- name: Create matrix-appservice-irc system group
|
- name: Create matrix-appservice-irc system group
|
||||||
group:
|
group:
|
||||||
name: matrix-appservice-irc
|
name: matrix-appservice-irc
|
||||||
system: yes
|
system: true
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
# Security #2
|
# Security #2
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
group: matrix-appservice-irc
|
group: matrix-appservice-irc
|
||||||
home: /var/local/matrix-appservice-irc
|
home: /var/local/matrix-appservice-irc
|
||||||
comment: Matrix Appservice IRC
|
comment: Matrix Appservice IRC
|
||||||
system: yes
|
system: true
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
# Security #3
|
# Security #3
|
||||||
|
|
|
@ -14,12 +14,15 @@
|
||||||
become_user: matrix-appservice-irc
|
become_user: matrix-appservice-irc
|
||||||
|
|
||||||
# Setup dependencies
|
# Setup dependencies
|
||||||
- name: Install matrix-appservice-irc depedencies
|
- name: Install matrix-appservice-irc dependencies
|
||||||
command: npm install
|
npm:
|
||||||
args:
|
path: /var/local/matrix-appservice-irc/matrix-appservice-irc
|
||||||
chdir: /var/local/matrix-appservice-irc/matrix-appservice-irc
|
production: true
|
||||||
become: true
|
become: true
|
||||||
become_user: matrix-appservice-irc
|
become_user: matrix-appservice-irc
|
||||||
|
register: npm_result
|
||||||
|
retries: 3
|
||||||
|
until: npm_result is succeeded
|
||||||
|
|
||||||
# Configure
|
# Configure
|
||||||
- name: Configure matrix-appservice-irc
|
- name: Configure matrix-appservice-irc
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
---
|
---
|
||||||
- name: Install mxisd
|
- name: Install mxisd
|
||||||
apt:
|
apt:
|
||||||
deb: https://github.com/kamax-matrix/mxisd/releases/download/v{{ mxisd_version }}/mxisd_{{ mxisd_version }}_all.deb
|
deb: "{{ mxisd_deb }}"
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
|
||||||
- name: Configure mxisd
|
- name: Configure mxisd
|
||||||
template:
|
template:
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
apt:
|
apt:
|
||||||
name: apt-transport-https
|
name: apt-transport-https
|
||||||
update_cache: true
|
update_cache: true
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
|
||||||
# Add the repository into source list
|
# Add the repository into source list
|
||||||
- name: Configure riot repository
|
- name: Configure riot repository
|
||||||
|
@ -15,17 +18,26 @@
|
||||||
apt_key:
|
apt_key:
|
||||||
url: https://riot.im/packages/debian/repo-key.asc
|
url: https://riot.im/packages/debian/repo-key.asc
|
||||||
id: E019645248E8F4A1
|
id: E019645248E8F4A1
|
||||||
|
register: apt_key_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_key_result is succeeded
|
||||||
|
|
||||||
# Install riot
|
# Install riot
|
||||||
- name: Install riot-web
|
- name: Install riot-web
|
||||||
apt:
|
apt:
|
||||||
name: riot-web
|
name: riot-web
|
||||||
update_cache: true
|
update_cache: true
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
|
||||||
# Install nginx
|
# Install nginx
|
||||||
- name: Install nginx
|
- name: Install nginx
|
||||||
apt:
|
apt:
|
||||||
name: nginx
|
name: nginx
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
|
||||||
# Configure nginx
|
# Configure nginx
|
||||||
- name: Configure nginx
|
- name: Configure nginx
|
||||||
|
|
178
roles/matrix-synapse/files/rest_auth_provider.py
Normal file
178
roles/matrix-synapse/files/rest_auth_provider.py
Normal file
|
@ -0,0 +1,178 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# REST endpoint Authentication module for Matrix synapse
|
||||||
|
# Copyright (C) 2017 Maxime Dor
|
||||||
|
#
|
||||||
|
# https://max.kamax.io/
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
import logging
|
||||||
|
from twisted.internet import defer
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class RestAuthProvider(object):
|
||||||
|
|
||||||
|
def __init__(self, config, account_handler):
|
||||||
|
self.account_handler = account_handler
|
||||||
|
|
||||||
|
if not config.endpoint:
|
||||||
|
raise RuntimeError('Missing endpoint config')
|
||||||
|
|
||||||
|
self.endpoint = config.endpoint
|
||||||
|
self.regLower = config.regLower
|
||||||
|
self.config = config
|
||||||
|
|
||||||
|
logger.info('Endpoint: %s', self.endpoint)
|
||||||
|
logger.info('Enforce lowercase username during registration: %s', self.regLower)
|
||||||
|
|
||||||
|
@defer.inlineCallbacks
|
||||||
|
def check_password(self, user_id, password):
|
||||||
|
logger.info("Got password check for " + user_id)
|
||||||
|
data = {'user':{'id':user_id, 'password':password}}
|
||||||
|
r = requests.post(self.endpoint + '/_matrix-internal/identity/v1/check_credentials', json = data)
|
||||||
|
r.raise_for_status()
|
||||||
|
r = r.json()
|
||||||
|
if not r["auth"]:
|
||||||
|
reason = "Invalid JSON data returned from REST endpoint"
|
||||||
|
logger.warning(reason)
|
||||||
|
raise RuntimeError(reason)
|
||||||
|
|
||||||
|
auth = r["auth"]
|
||||||
|
if not auth["success"]:
|
||||||
|
logger.info("User not authenticated")
|
||||||
|
defer.returnValue(False)
|
||||||
|
|
||||||
|
localpart = user_id.split(":", 1)[0][1:]
|
||||||
|
logger.info("User %s authenticated", user_id)
|
||||||
|
|
||||||
|
registration = False
|
||||||
|
if not (yield self.account_handler.check_user_exists(user_id)):
|
||||||
|
logger.info("User %s does not exist yet, creating...", user_id)
|
||||||
|
|
||||||
|
if localpart != localpart.lower() and self.regLower:
|
||||||
|
logger.info('User %s was cannot be created due to username lowercase policy', localpart)
|
||||||
|
defer.returnValue(False)
|
||||||
|
|
||||||
|
user_id, access_token = (yield self.account_handler.register(localpart=localpart))
|
||||||
|
registration = True
|
||||||
|
logger.info("Registration based on REST data was successful for %s", user_id)
|
||||||
|
else:
|
||||||
|
logger.info("User %s already exists, registration skipped", user_id)
|
||||||
|
|
||||||
|
if auth["profile"]:
|
||||||
|
logger.info("Handling profile data")
|
||||||
|
profile = auth["profile"]
|
||||||
|
|
||||||
|
store = yield self.account_handler.hs.get_profile_handler().store
|
||||||
|
if "display_name" in profile and ((registration and self.config.setNameOnRegister) or (self.config.setNameOnLogin)):
|
||||||
|
display_name = profile["display_name"]
|
||||||
|
logger.info("Setting display name to '%s' based on profile data", display_name)
|
||||||
|
yield store.set_profile_displayname(localpart, display_name)
|
||||||
|
else:
|
||||||
|
logger.info("Display name was not set because it was not given or policy restricted it")
|
||||||
|
|
||||||
|
if (self.config.updateThreepid):
|
||||||
|
if "three_pids" in profile:
|
||||||
|
logger.info("Handling 3PIDs")
|
||||||
|
for threepid in profile["three_pids"]:
|
||||||
|
medium = threepid["medium"].lower()
|
||||||
|
address = threepid["address"].lower()
|
||||||
|
logger.info("Looking for 3PID %s:%s in user profile", medium, address)
|
||||||
|
|
||||||
|
validated_at = self.account_handler.hs.get_clock().time_msec()
|
||||||
|
if not (yield store.get_user_id_by_threepid(medium, address)):
|
||||||
|
logger.info("3PID is not present, adding")
|
||||||
|
yield store.user_add_threepid(
|
||||||
|
user_id,
|
||||||
|
medium,
|
||||||
|
address,
|
||||||
|
validated_at,
|
||||||
|
validated_at
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
logger.info("3PID is present, skipping")
|
||||||
|
else:
|
||||||
|
logger.info("3PIDs were not updated due to policy")
|
||||||
|
else:
|
||||||
|
logger.info("No profile data")
|
||||||
|
|
||||||
|
defer.returnValue(True)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def parse_config(config):
|
||||||
|
# verify config sanity
|
||||||
|
_require_keys(config, ["endpoint"])
|
||||||
|
|
||||||
|
class _RestConfig(object):
|
||||||
|
endpoint = ''
|
||||||
|
regLower = True
|
||||||
|
setNameOnRegister = True
|
||||||
|
setNameOnLogin = False
|
||||||
|
updateThreepid = True
|
||||||
|
|
||||||
|
rest_config = _RestConfig()
|
||||||
|
rest_config.endpoint = config["endpoint"]
|
||||||
|
|
||||||
|
try:
|
||||||
|
rest_config.regLower = config['policy']['registration']['username']['enforceLowercase']
|
||||||
|
except TypeError:
|
||||||
|
# we don't care
|
||||||
|
pass
|
||||||
|
except KeyError:
|
||||||
|
# we don't care
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
rest_config.setNameOnRegister = config['policy']['registration']['profile']['name']
|
||||||
|
except TypeError:
|
||||||
|
# we don't care
|
||||||
|
pass
|
||||||
|
except KeyError:
|
||||||
|
# we don't care
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
rest_config.setNameOnLogin = config['policy']['login']['profile']['name']
|
||||||
|
except TypeError:
|
||||||
|
# we don't care
|
||||||
|
pass
|
||||||
|
except KeyError:
|
||||||
|
# we don't care
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
rest_config.updateThreepid = config['policy']['all']['threepid']['update']
|
||||||
|
except TypeError:
|
||||||
|
# we don't care
|
||||||
|
pass
|
||||||
|
except KeyError:
|
||||||
|
# we don't care
|
||||||
|
pass
|
||||||
|
|
||||||
|
return rest_config
|
||||||
|
|
||||||
|
def _require_keys(config, required):
|
||||||
|
missing = [key for key in required if key not in config]
|
||||||
|
if missing:
|
||||||
|
raise Exception(
|
||||||
|
"REST Auth enabled but missing required config values: {}".format(
|
||||||
|
", ".join(missing)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
name: matrix-synapse
|
name: matrix-synapse
|
||||||
update_cache: true
|
update_cache: true
|
||||||
default_release: stretch-backports
|
default_release: stretch-backports
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
|
||||||
- name: Configure matrix-synapse
|
- name: Configure matrix-synapse
|
||||||
template:
|
template:
|
||||||
|
@ -22,8 +25,8 @@
|
||||||
notify: Restart matrix-synapse service
|
notify: Restart matrix-synapse service
|
||||||
|
|
||||||
- name: Install rest auth provider
|
- name: Install rest auth provider
|
||||||
get_url:
|
copy:
|
||||||
url: "{{ synapse_rest_auth_url }}"
|
src: rest_auth_provider.py
|
||||||
dest: /usr/local/lib/python3.5/dist-packages/rest_auth_provider.py
|
dest: /usr/local/lib/python3.5/dist-packages/rest_auth_provider.py
|
||||||
mode: 0755
|
mode: 0755
|
||||||
notify: Restart matrix-synapse service
|
notify: Restart matrix-synapse service
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
apt:
|
apt:
|
||||||
name: nginx
|
name: nginx
|
||||||
update_cache: true
|
update_cache: true
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
|
||||||
# Install sites
|
# Install sites
|
||||||
- name: Configure NGINX sites
|
- name: Configure NGINX sites
|
||||||
|
|
|
@ -9,3 +9,6 @@
|
||||||
upgrade: dist
|
upgrade: dist
|
||||||
update_cache: true
|
update_cache: true
|
||||||
cache_valid_time: 86400 # one day
|
cache_valid_time: 86400 # one day
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
|
Loading…
Reference in a new issue