Application de develop sur octo #1

Open
lucaskev wants to merge 15 commits from develop into main
15 changed files with 2684 additions and 2199 deletions

4
.gitignore vendored
View File

@ -1,3 +1 @@
.vagrant
hosts.ini
ubuntu-bionic-18.04-cloudimg-console.log
.vscode/

View File

@ -1,30 +1,12 @@
# Fuz Playbooks
Playbooks for (relatively) easy sysadmin!
Playbooks pour installation via Ansible de services pour le Fuz.
ansible-galaxy install -r requirements.yml
## With Vagrant
1. Install Vagrant
2. `vagrant up`
3. Install ansible:
## Deployment
1. Récupérer l'inventaire `hosts.ini` auprès d'un humain ou autre
2. Installer ansible:
```bash
sudo apt update
sudo apt install software-properties-common
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt install ansible
sudo pip3 install ansible
```
<!-- 3. Install the roles: `ansible-galaxy install -r requirements.yml` -->
4. Launch the playbook: `ansible-playbook setup.yml`
## With a real server
1. Edit the file `hosts.ini`
2. Install ansible:
```bash
sudo apt update
sudo apt install software-properties-common
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt install ansible
```
<!-- 3. Install the roles: `ansible-galaxy install -r requirements.yml` -->
3. Launch the playbook: `ansible-playbook setup.yml`
1. Launch the playbook sans faire de changements: `ansible-playbook main.yml -K --check --diff -vv`

22
adminsys-classique.yml Normal file
View File

@ -0,0 +1,22 @@
---
- hosts: all
become: yes
pre_tasks:
- apt:
update_cache: yes
# roles:
# - geerlingguy.pip
tasks:
- name: Faire une full upgrade
apt:
upgrade: yes
- name: Programmes utiles installés
apt:
name:
- python3-pip
- certbot
- tmux
- bash-completion
- rsync
- unattended-upgrades
# - zsh

View File

@ -1 +0,0 @@
# Configure crontab of ansible pull to this repo to create a puppet-like kind of config

272
files/lighttpd.conf Normal file
View File

@ -0,0 +1,272 @@
server.modules = (
"mod_access",
"mod_accesslog",
"mod_alias",
"mod_compress",
"mod_redirect",
"mod_setenv",
"mod_rewrite",
"mod_proxy",
"mod_cgi",
"mod_openssl",
)
server.document-root = "/var/www/html"
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
server.errorlog = "/var/log/lighttpd/error.log"
accesslog.filename = "/var/log/lighttpd/access.log"
server.pid-file = "/var/run/lighttpd.pid"
server.username = "www-data"
server.groupname = "www-data"
server.port = 80
dir-listing.activate = "enable"
dir-listing.encoding = "utf-8"
index-file.names = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
compress.cache-dir = "/var/cache/lighttpd/compress/"
compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" )
# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
# not here anymore see next line : include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/create-mime.conf.pl"
#include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
include "/etc/lighttpd/conf-enabled/*.conf"
### FUZ.RE ###
### Wiki pas encore hébergé ici ###
$HTTP["host"] == "wiki.fuz.re" {
server.document-root = "/var/www/fuz.re/dokuwiki/"
$HTTP["scheme"] == "http" {
url.redirect = (".*" => "https://wiki.fuz.re$0")
}
$HTTP["scheme"] == "https" {
$HTTP["url"] =~ "^/" {
server.follow-symlink = "enable"
}
$HTTP["url"] =~ "/(\.|_)ht" {
url.access-deny = ( "" )
}
$HTTP["url"] =~ "^/(bin|data|inc|conf)" {
url.access-deny = ( "" )
}
# $SERVER["socket"] == ":443" {
# ssl.engine = "enable"
# ssl.ca-file = "/etc/letsencrypt/live/wiki.fuz.re/fullchain.pem"
# ssl.pemfile = "/etc/lighttpd/certs/wiki.fuz.re.pem"
# }
}
}
# Redirect www -> https without www
$HTTP["host"] == "www.fuz.re" {
$HTTP["scheme"] == "http" {
url.redirect = (".*" => "https://fuz.re$0")
}
}
# Redirect http -> https without www
$HTTP["host"] == "fuz.re" {
$HTTP["scheme"] == "http" {
url.redirect = (".*" => "https://fuz.re$0")
}
# HTTPS :
$HTTP["scheme"] == "https" {
server.document-root = "/var/www/fuz.re/newsite/public"
$SERVER["socket"] == ":443" {
ssl.engine = "enable"
ssl.pemfile = "/etc/letsencrypt/live/fuz.re/fullchain.pem"
ssl.privkey = "/etc/letsencrypt/live/fuz.re/privkey.pem"
}
}
}
# Old Jack.tf
$HTTP["host"] == "jack.fuz.re" {
server.document-root = "/var/www/fuz.re/jack/site"
$HTTP["scheme"] == "http" {
$HTTP["url"] !~ "^/.well-known/acme-challenge/" {
url.redirect = (".*" => "https://jack.fuz.re$0")
}
}
$HTTP["scheme"] == "https" {
$SERVER["socket"] == ":443" {
ssl.engine = "enable"
ssl.pemfile = "/etc/letsencrypt/live/jack.fuz.re/fullchain.pem"
ssl.privkey = "/etc/letsencrypt/live/jack.fuz.re/privkey.pem"
}
}
}
$HTTP["host"] == "riot.fuz.re" {
server.document-root = "/var/www/fuz.re/riot/site"
$HTTP["scheme"] == "http" {
$HTTP["url"] !~ "^/.well-known/acme-challenge/" {
url.redirect = (".*" => "https://riot.fuz.re$0")
}
}
$HTTP["scheme"] == "https" {
alias.url = (
"/rc" => "/var/www/fuz.re/riot/rc"
)
$SERVER["socket"] == ":443" {
ssl.engine = "enable"
ssl.pemfile = "/etc/letsencrypt/live/riot.fuz.re/fullchain.pem"
ssl.privkey = "/etc/letsencrypt/live/riot.fuz.re/privkey.pem"
}
}
}
$HTTP["host"] == "matrix.fuz.re" {
server.document-root = "/var/www/fuz.re/matrix/site"
$HTTP["scheme"] == "http" {
$HTTP["url"] !~ "^/.well-known/acme-challenge/" {
url.redirect = (".*" => "https://matrix.fuz.re$0")
}
}
$SERVER["socket"] == ":443" {
ssl.engine = "enable"
ssl.pemfile = "/etc/letsencrypt/live/matrix.fuz.re/fullchain.pem"
ssl.privkey = "/etc/letsencrypt/live/matrix.fuz.re/privkey.pem"
proxy.server = ( "" => (( "host" => "127.0.0.1", "port" => 8008 )))
proxy.header = ( "map-host-request" => ( "-" => "matrix.fuz.re"),
"map-host-response" => ("-" => "-"))
}
$SERVER["socket"] == ":8448" {
ssl.engine = "enable"
ssl.pemfile = "/etc/letsencrypt/live/matrix.fuz.re/fullchain.pem"
ssl.privkey = "/etc/letsencrypt/live/matrix.fuz.re/privkey.pem"
proxy.server = ( "" => (( "host" => "127.0.0.1", "port" => 8008 )))
proxy.header = ( "map-host-request" => ( "-" => "matrix.fuz.re"),
"map-host-response" => ("-" => "-"))
}
}
$HTTP["host"] == "mumble.fuz.re" {
$HTTP["scheme"] == "http" {
server.document-root = "/var/www/fuz.re/mumble/site"
$HTTP["url"] !~ "^/.well-known/acme-challenge/" {
url.redirect = (".*" => "https://mumble.fuz.re$0")
}
}
$SERVER["socket"] == ":443" {
ssl.engine = "enable"
ssl.pemfile = "/etc/letsencrypt/live/mumble.fuz.re/fullchain.pem"
ssl.privkey = "/etc/letsencrypt/live/mumble.fuz.re/privkey.pem"
url.redirect-code = 302 # it's a workaround for retarded lighttpd unable to handle websockets, hence a temp 302 redirection -- Lomanic 20200606
url.redirect = (".*" => "https://mumble.fuz.re:64737$0")
}
}
$HTTP["host"] == "presence.fuz.re" { # added by Lomanic 20200606
$HTTP["scheme"] == "http" {
server.document-root = "/var/www/fuz.re/presence/site"
$HTTP["url"] !~ "^/.well-known/acme-challenge/" {
url.redirect = (".*" => "https://${url.authority}${url.path}${qsa}")
}
}
$SERVER["socket"] == ":443" {
ssl.engine = "enable"
proxy.server = ( "" => (("host" => "127.0.0.1", "port" => 3000)) )
#ssl.ca-file = "/etc/letsencrypt/live/presence.fuz.re/chain.pem"
#ssl.pemfile = "/etc/lighttpd/certs/presence.fuz.re.pem"
ssl.pemfile = "/etc/letsencrypt/live/presence.fuz.re/fullchain.pem"
ssl.privkey = "/etc/letsencrypt/live/presence.fuz.re/privkey.pem"
}
}
$HTTP["host"] == "spaceapi.fuz.re" { # added by Lomanic 20201017
$HTTP["scheme"] == "http" {
server.document-root = "/var/www/fuz.re/spaceapi/site"
$HTTP["url"] !~ "^/.well-known/acme-challenge/" {
url.redirect = (".*" => "https://${url.authority}${url.path}${qsa}")
}
}
$SERVER["socket"] == ":443" {
ssl.engine = "enable"
proxy.server = ( "" => (("host" => "127.0.0.1", "port" => 3001)) )
ssl.pemfile = "/etc/letsencrypt/live/spaceapi.fuz.re/fullchain.pem"
ssl.privkey = "/etc/letsencrypt/live/spaceapi.fuz.re/privkey.pem"
}
}
$HTTP["host"] == "sonic.fuz.re" {
server.document-root = "/var/www/sonic.fuz.re/"
}
### Mailman ###
$HTTP["host"] == "liste.fuz.re" {
server.document-root = "/var/www/fuz.re/liste/site"
$HTTP["scheme"] == "http" {
$HTTP["url"] !~ "^/.well-known/acme-challenge/" {
url.redirect = (".*" => "https://liste.fuz.re$0")
}
}
$SERVER["socket"] == ":443" {
ssl.engine = "enable"
#ssl.ca-file = "/etc/letsencrypt/live/liste.fuz.re/chain.pem"
#ssl.pemfile = "/etc/letsencrypt/live/liste.fuz.re/combined.pem"
ssl.pemfile = "/etc/letsencrypt/live/liste.fuz.re/fullchain.pem"
ssl.privkey = "/etc/letsencrypt/live/liste.fuz.re/privkey.pem"
}
alias.url = (
"/mailman/" => "/usr/lib/cgi-bin/mailman/",
"/cgi-bin/mailman/" => "/usr/lib/cgi-bin/mailman/",
"/images/mailman/" => "/usr/share/images/mailman/",
#"/pipermail/" => "/var/lib/mailman/archives/public/"
)
cgi.assign = (
"/admin" => "",
"/admindb" => "",
"/confirm" => "",
"/create" => "",
"/edithtml" => "",
"/listinfo" => "",
"/options" => "",
"/private" => "",
"/rmlist" => "",
"/roster" => "",
"/subscribe" => "")
}
## Datapaulette - Pas hébérgé ici non plus
$HTTP["host"] =~ "www.datapaulette.org" {
url.redirect = (".*" => "http://datapaulette.org")
}
$HTTP["host"] =~ "datapaulette.org" {
server.error-handler-404 = "/index.php"
server.document-root = "/var/www/datapaulette.org/dp-wp"
# $SERVER["socket"] == ":443" {
# ssl.engine = "enable"
# ssl.ca-file = "/etc/letsencrypt/live/datapaulette.org/fullchain.pem"
# ssl.pemfile = "/etc/lighttpd/certs/datapaulette.org.pem"
# }
#url.rewrite = (
# "^/(.*)\.(.+)$" => "$0",
# ###"^/(wp-admin|wp-includes|wp-content|gallery2)/(.*)" => "$0",
# "^/(.+)/?$" => "/index.php/$1"
#)
}
### WOOTDEVICES.IO - https à activer après copie des certs
$HTTP["host"] == "wootdevices.io" {
server.document-root = "/var/www/wootdevices.io/site/"
# $SERVER["socket"] == ":443" {
# ssl.engine = "enable"
# ssl.ca-file = "/etc/letsencrypt/live/wootdevices.io/fullchain.pem"
# ssl.pemfile = "/etc/lighttpd/certs/wootdevices.io.pem"
# }
}

2
hosts.ini Normal file
View File

@ -0,0 +1,2 @@
# sonic ansible_host=sonic.fuz.re
octo.fuz.re

View File

@ -1 +0,0 @@
<name> ansible_connection=ssh ansible_user=root ansible_password=<password> ansible_host=<host> ansible_become=yes

24
lighttpd.yml Normal file
View File

@ -0,0 +1,24 @@
- hosts: octo.fuz.re
become: yes
tasks:
- name: Lighttpd installé
apt:
name: lighttpd
- name: Copie la conf
copy:
src: files/lighttpd.conf
dest: /etc/lighttpd/lighttpd.conf
notify: Restart de lighttpd
- name: On charge lighttpd
service:
name: lighttpd
state: started
enabled: yes
handlers:
- name: Restart de lighttpd
service:
name: lighttpd
state: restarted

View File

@ -1,17 +1,8 @@
---
- hosts:
- scaleway
handlers:
- name: reboot
reboot:
# Tous
- import_playbook: adminsys-classique.yml
# Octo
- import_playbook: matrix.yml
- import_playbook: lighttpd.yml
# - import_playbook: certbot.yml
pre_tasks:
- apt:
update_cache: yes
# - apt:
# name: python-pip
# roles:
# - geerlingguy.pip
# - import_playbook: nginx-certbot.yml
- import_playbook: matrix.yml
# Sonic

View File

@ -1,11 +0,0 @@
# https://github.com/tulir/mautrix-telegram/wiki/Bridge-setup-with-Docker
# version: "3.7"
# services:
# mautrix-telegram:
# container_name: mautrix-telegram
# image: dock.mau.dev/tulir/mautrix-telegram:<version>
# restart: unless-stopped
# volumes:
# - .:/data

View File

@ -1,74 +1,43 @@
---
- hosts: scaleway
vars:
matrix_synapse_version: "v1.5.1-py3"
# matrix_synapse_version: "v1.5.1"
matrix_server_name: matrix-test.local
matrix_bind_address: "51.158.114.109"
matrix_synapse_pg_host: synapse-postgres # does it need to be an IP?
matrix_synapse_db_name: psycopg2
matrix_synapse_pg_user: "synapse"
matrix_synapse_pg_pass: "pomme"
matrix_synapse_pg_db: "synapse"
matrix_registration_shared_secret: "xxxxx"
matrix_synapse_report_stats: false
matrix_synapse_config_dir: "/etc/matrix-synapse"
matrix_synapse_config_path: "{{ matrix_synapse_config_dir }}/homeserver.yaml"
matrix_synapse_config_docker_path: "/config/homeserver.yaml"
matrix_synapse_config_docker_dir: "/config"
# to implement
# matrix_no_tls: true
- hosts: octo.fuz.re
become: yes
tasks:
# - docker_volume:
# name: synapse-data
- name: Create config directory
file:
path: "{{ matrix_synapse_config_dir }}"
state: directory
- name: synapse installé et upgradé
apt:
name: matrix-synapse
update_cache: yes
upgrade: yes
- template:
src: templates/homeserver.yaml.j2
dest: "{{ matrix_synapse_config_path }}"
# - name: Config Synapse conforme à ce qu'il y a dans ce dépôt Ansible
# template:
# src: templates/homeserver.yaml.j2
# dest: /etc/matrix-synapse/homeserver.yaml
- name: Postgres lancé
service:
name: postgresql@13-main
state: started
enabled: yes
- name: Create config directory
file:
path: "/etc/docker"
state: directory
- template:
src: templates/docker-compose-matrix.yml.j2
dest: /etc/docker/docker-compose.yml
- name: Install required system packages
apt: name={{ item }} state=latest update_cache=yes
loop: [ 'apt-transport-https', 'ca-certificates', 'curl', 'software-properties-common', 'python3-pip']
- name: Add Docker GPG apt Key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add Docker Repository
apt_repository:
repo: deb https://download.docker.com/linux/ubuntu bionic stable
state: present
- name: Update apt and install docker-ce
apt: update_cache=yes name=docker-ce state=latest
- name: install pip docker
pip: name={{ item }}
loop: ['docker', 'docker-compose']
- name: Create and start matrix services
docker_compose:
project_src: /etc/docker/
register: output
# uploads_path: "/var/lib/matrix-synapse/uploads"
# media_store_path: "/var/lib/matrix-synapse/media"
- name: Synapse lancé
service:
name: matrix-synapse
state: started
enabled: yes
vars:
- matrix_server_name: matrix.fuz.re
- synapse_postgres_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
65636365623364333261383933393663356536646562653539343765663631613333323231613564
3836333964313235373865376235373934323861396339330a353637633333386434306533363166
36373238633939303261666263303562653233313339326638393032343531613435326436393739
6535346265653732380a363738333836366334633264303130336435323637303037373563306266
3235
- synapse_turn_secret: !vault |
$ANSIBLE_VAULT;1.1;AES256
32616461613066343434373265376663653230393837313264636130623963383636333739333561
6434613031303161656531303639633437613132336131660a333466356165616434646366333765
31653164633930326434643339616231616235613062663733326339653830306566313735306339
3831646665393963390a636332353233396462663831623966373437306531663331333233363361
31383766356137636661306134326236656666623432656163616132663530343566

View File

@ -1,20 +0,0 @@
# from galaxy
# - src: geerlingguy.pip
# - src: geerlingguy.postgresql
# - src: https://github.com/geerlingguy/ansible-role-certbot
# scm: git
# from GitHub, overriding the name and specifying a specific tag
# - src: https://github.com/bennojoy/nginx
# version: master
# name: nginx_role
# from a webserver, where the role is packaged in a tar.gz
# - src: https://some.webserver.example.com/files/master.tar.gz
# name: http-role
# from GitLab or other git-based scm, using git+ssh
# - src: https://gitlab.com/famedly/ansible/synapse
# scm: git
# version: "0.1" # quoted, so YAML doesn't parse this as a floating-point value

View File

@ -1,48 +0,0 @@
version: '3'
services:
# matrix_synapse_version: "v1.5.1-py3"
# matrix_synapse_version: "v1.5.1"
#matrix_synapse_pg_host: synapse-postgres
synapse:
# build:
# context: ../..
# dockerfile: docker/Dockerfile
image: "matrixdotorg/synapse:{{ matrix_synapse_version }}"
# Since synapse does not retry to connect to the database, restart upon
# failure
restart: unless-stopped
# See the readme for a full documentation of the environment settings
environment:
- SYNAPSE_REPORT_STATS={{ matrix_synapse_report_stats }}
- SYNAPSE_CONFIG_PATH={{ matrix_synapse_config_docker_path }}
volumes:
# You may either store all the files in a local folder
- {{ matrix_synapse_config_dir }}:{{ matrix_synapse_config_docker_dir }}
- ./files:/data
# .. or you may split this between different storage points
# - ./files:/data
# - /path/to/ssd:/data/uploads
# - /path/to/large_hdd:/data/media
depends_on:
- db
# In order to expose Synapse, remove one of the following, you might for
# instance expose the TLS port directly:
ports:
- 8008:8008/tcp
# labels:
db:
image: docker.io/postgres:10-alpine
# Change that password, of course!
environment:
- POSTGRES_USER={{ matrix_synapse_db_name }}
- POSTGRES_PASSWORD={{ matrix_synapse_pg_pass }}
volumes:
# You may store the database tables in a local folder..
- ./schemas:/var/lib/postgresql/data
# .. or store them on some high performance storage for better results
# - /path/to/ssd/storage:/var/lib/postgresql/data

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff