Prefix variables with etherpad_
All checks were successful
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2810|0|2810|0|:zzz:
gitea/ansible-roles/pipeline/head This commit looks good

This commit is contained in:
Mathieu Gauthier-Pilote 2024-05-08 14:09:02 -04:00
parent e076c54fcd
commit ae726365ec
8 changed files with 70 additions and 70 deletions

View file

@ -31,17 +31,17 @@ Exemple de playbook
- all - all
vars: vars:
# Supplanter ici les variables du rôle # Supplanter ici les variables du rôle
domains: ['votre-vrai-domaine.org']
service: 'mon-etherpad' service: 'mon-etherpad'
db_host: 'localhost' etherpad_domains: ['votre-vrai-domaine.org']
db_user: "{{ service }}" etherpad_db_host: 'localhost'
db_name: "{{ service }}" etherpad_db_user: "{{ service }}"
db_password: 'zKEh-CHANGEZ-MOI-qIKc' etherpad_db_name: "{{ service }}"
etherpad_db_password: 'zKEh-CHANGEZ-MOI-qIKc'
pre_tasks: pre_tasks:
- name: "Installer les rôles systèmes" - name: "Installer les rôles systèmes"
roles: roles:
- { role: nodejs, nodejs_apt_version: "{{ node_version }}" } - { role: nodejs, nodejs_apt_version: "{{ etherpad_node_version }}" }
roles: roles:
- { role: webapps/etherpad , tags: "etherpad" } - { role: webapps/etherpad , tags: "etherpad" }

View file

@ -31,17 +31,17 @@ Example Playbook
- all - all
vars: vars:
# Overwrite the role variable here # Overwrite the role variable here
domains: ['your-real-domain.org']
service: 'my-etherpad' service: 'my-etherpad'
db_host: 'localhost' etherpad_domains: ['your-real-domain.org']
db_user: "{{ service }}" etherpad_db_host: 'localhost'
db_name: "{{ service }}" etherpad_db_user: "{{ service }}"
db_password: 'zKEh-CHANGE-ME-qIKc' etherpad_db_name: "{{ service }}"
etherpad_db_password: 'zKEh-CHANGE-ME-qIKc'
pre_tasks: pre_tasks:
- name: "Install system roles" - name: "Install system roles"
roles: roles:
- { role: nodejs, nodejs_apt_version: "{{ node_version }}" } - { role: nodejs, nodejs_apt_version: "{{ etherpad_node_version }}" }
roles: roles:
- { role: webapps/etherpad , tags: "etherpad" } - { role: webapps/etherpad , tags: "etherpad" }

View file

@ -1,28 +1,28 @@
--- ---
# defaults file for etherpad # defaults file for etherpad
system_dep: "['apt-transport-https', 'mariadb-server', 'python3-mysqldb', 'nginx', 'ssl-cert', 'git', 'wget', 'certbot', 'npm']"
git_url: 'https://github.com/ether/etherpad-lite.git'
git_version: '1.8.18'
node_version: 'node_18.x'
node_port: '9001'
service: 'example' service: 'example'
domains: ['example.domain.org'] etherpad_system_dep: "['apt-transport-https', 'mariadb-server', 'python3-mysqldb', 'nginx', 'ssl-cert', 'git', 'wget', 'certbot', 'npm']"
certbot_admin_email: 'mgauthier@evolix.ca' etherpad_git_url: 'https://github.com/ether/etherpad-lite.git'
etherpad_git_version: '1.8.18'
etherpad_node_version: 'node_18.x'
etherpad_node_port: '9001'
etherpad_domains: ['example.domain.org']
etherpad_certbot_admin_email: 'mgauthier@evolix.ca'
db_host: '127.0.0.1' etherpad_db_host: '127.0.0.1'
db_port: '3306' etherpad_db_port: '3306'
db_user: "{{ service }}" etherpad_db_user: "{{ service }}"
db_name: "{{ service }}" etherpad_db_name: "{{ service }}"
db_password: 'CHANGE_ME' etherpad_db_password: 'CHANGE_ME'
app_ip: '127.0.0.1' etherpad_app_ip: '127.0.0.1'
app_title: 'My Etherpad' etherpad_app_title: 'My Etherpad'
app_db_type: 'mysql' etherpad_app_db_type: 'mysql'
app_skin_name: 'colibris' etherpad_app_skin_name: 'colibris'
app_skin_variants: 'super-light-toolbar super-light-editor light-background' etherpad_app_skin_variants: 'super-light-toolbar super-light-editor light-background'
app_trust_proxy: 'true' etherpad_app_trust_proxy: 'true'
app_require_authentication: 'false' etherpad_app_require_authentication: 'false'
app_require_authorization: 'true' etherpad_app_require_authorization: 'true'
app_admin_password: 'CHANGE_ME_TOO' etherpad_app_admin_password: 'CHANGE_ME_TOO'
app_default_pad_text: 'Bienvenue sur Etherpad !\n\nLe texte de ce bloc-notes est synchronisé sur le serveur au fur et à mesure que vous tapez, de sorte que toutes les personnes qui consultent cette page voient le même texte. Cela vous permet de collaborer de manière transparente et collaborative sur des documents !\n\nParticipez à Etherpad sur https:\/\/etherpad.org\n' etherpad_app_default_pad_text: 'Bienvenue sur Etherpad !\n\nLe texte de ce bloc-notes est synchronisé sur le serveur au fur et à mesure que vous tapez, de sorte que toutes les personnes qui consultent cette page voient le même texte. Cela vous permet de collaborer de manière transparente et collaborative sur des documents !\n\nParticipez à Etherpad sur https:\/\/etherpad.org\n'
app_file_ends: 'false' etherpad_app_file_ends: 'false'

View file

@ -3,7 +3,7 @@
- name: Install main system dependencies - name: Install main system dependencies
apt: apt:
name: "{{ system_dep }}" name: "{{ etherpad_system_dep }}"
update_cache: yes update_cache: yes
- name: Add UNIX account - name: Add UNIX account
@ -13,20 +13,20 @@
- name: Add database - name: Add database
mysql_db: mysql_db:
name: "{{ db_name }}" name: "{{ etherpad_db_name }}"
- name: Add database user - name: Add database user
mysql_user: mysql_user:
name: "{{ db_user }}" name: "{{ etherpad_db_user }}"
password: "{{ db_password }}" password: "{{ etherpad_db_password }}"
priv: "{{ db_name }}.*:{{privileges |default('SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER,CREATE TEMPORARY TABLES')}}" priv: "{{ etherpad_db_name }}.*:{{privileges |default('SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER,CREATE TEMPORARY TABLES')}}"
update_password: on_create update_password: on_create
- name: Clone etherpad repo (git) - name: Clone etherpad repo (git)
git: git:
repo: "{{ git_url }}" repo: "{{ etherpad_git_url }}"
dest: "~/etherpad-lite/" dest: "~/etherpad-lite/"
version: "{{ git_version | default(omit) }}" version: "{{ etherpad_git_version | default(omit) }}"
update: yes update: yes
force: true force: true
umask: '0022' umask: '0022'
@ -76,7 +76,7 @@
- name: Check if SSL certificate is present and register result - name: Check if SSL certificate is present and register result
stat: stat:
path: "/etc/letsencrypt/live/{{ domains |first }}/fullchain.pem" path: "/etc/letsencrypt/live/{{ etherpad_domains |first }}/fullchain.pem"
register: ssl register: ssl
- name: Generate certificate only if required (first time) - name: Generate certificate only if required (first time)
@ -100,7 +100,7 @@
state: directory state: directory
mode: '0755' mode: '0755'
- name: Generate certificate with certbot - name: Generate certificate with certbot
shell: certbot certonly --webroot --webroot-path /var/lib/letsencrypt --non-interactive --agree-tos --email {{ certbot_admin_email }} -d {{ domains |first }} shell: certbot certonly --webroot --webroot-path /var/lib/letsencrypt --non-interactive --agree-tos --email {{ etherpad_certbot_admin_email }} -d {{ etherpad_domains |first }}
- name: Create the ssl dir if needed - name: Create the ssl dir if needed
file: file:
path: /etc/nginx/ssl path: /etc/nginx/ssl
@ -109,12 +109,12 @@
- name: Template ssl bloc for nginx vhost - name: Template ssl bloc for nginx vhost
template: template:
src: "ssl.conf.j2" src: "ssl.conf.j2"
dest: "/etc/nginx/ssl/{{ domains |first }}.conf" dest: "/etc/nginx/ssl/{{ etherpad_domains |first }}.conf"
when: ssl.stat.exists != true when: ssl.stat.exists != true
- name: (Re)check if SSL certificate is present and register result - name: (Re)check if SSL certificate is present and register result
stat: stat:
path: "/etc/letsencrypt/live/{{ domains |first }}/fullchain.pem" path: "/etc/letsencrypt/live/{{ etherpad_domains |first }}/fullchain.pem"
register: ssl register: ssl
- name: (Re)template conf file for nginx vhost with SSL - name: (Re)template conf file for nginx vhost with SSL

View file

@ -14,9 +14,9 @@
- name: Clone etherpad repo (git) - name: Clone etherpad repo (git)
git: git:
repo: "{{ git_url }}" repo: "{{ etherpad_git_url }}"
dest: "~/etherpad-lite/" dest: "~/etherpad-lite/"
version: "{{ git_version }}" version: "{{ etherpad_git_version }}"
update: yes update: yes
force: true force: true
become_user: "{{ service }}" become_user: "{{ service }}"

View file

@ -93,7 +93,7 @@
/* /*
* Name your instance! * Name your instance!
*/ */
"title": "{{ app_title }}", "title": "{{ etherpad_app_title }}",
/* /*
* Pathname of the favicon you want to use. If null, the skin's favicon is * Pathname of the favicon you want to use. If null, the skin's favicon is
@ -114,7 +114,7 @@
* - "colibris": the new experimental skin (since Etherpad 1.8), candidate to * - "colibris": the new experimental skin (since Etherpad 1.8), candidate to
* become the default in Etherpad 2.0 * become the default in Etherpad 2.0
*/ */
"skinName": "{{ app_skin_name }}", "skinName": "{{ etherpad_app_skin_name }}",
/* /*
* Skin Variants * Skin Variants
@ -140,7 +140,7 @@
* "full-width-editor" variant (by default editor is rendered as a page, with * "full-width-editor" variant (by default editor is rendered as a page, with
* a max-width of 900px). * a max-width of 900px).
*/ */
"skinVariants": "{{ app_skin_variants }}", "skinVariants": "{{ etherpad_app_skin_variants }}",
/* /*
* IP and port which Etherpad should bind at. * IP and port which Etherpad should bind at.
@ -152,8 +152,8 @@
* "ip": "", // <-- has to be an empty string * "ip": "", // <-- has to be an empty string
* "port" : "/somepath/etherpad.socket", // <-- path to a Unix socket * "port" : "/somepath/etherpad.socket", // <-- path to a Unix socket
*/ */
"ip": "{{ app_ip }}", "ip": "{{ etherpad_app_ip }}",
"port": {{ node_port }}, "port": {{ etherpad_node_port }},
/* /*
* Option to hide/show the settings.json in admin page. * Option to hide/show the settings.json in admin page.
@ -210,18 +210,18 @@
*/ */
"dbType" : "mysql", "dbType" : "mysql",
"dbSettings" : { "dbSettings" : {
"user": "{{ db_user }}", "user": "{{ etherpad_db_user }}",
"host": "{{ db_host }}", "host": "{{ etherpad_db_host }}",
"port": "{{ db_port }}", "port": "{{ etherpad_db_port }}",
"password": "{{ db_password }}", "password": "{{ etherpad_db_password }}",
"database": "{{ db_name }}", "database": "{{ etherpad_db_name }}",
"charset": "utf8mb4" "charset": "utf8mb4"
}, },
/* /*
* The default text of a pad * The default text of a pad
*/ */
"defaultPadText" : "{{ app_default_pad_text }}", "defaultPadText" : "{{ etherpad_app_default_pad_text }}",
/* /*
* Default Pad behavior. * Default Pad behavior.
@ -326,19 +326,19 @@
* Allow import of file types other than the supported ones: * Allow import of file types other than the supported ones:
* txt, doc, docx, rtf, odt, html & htm * txt, doc, docx, rtf, odt, html & htm
*/ */
"allowUnknownFileEnds": {{ app_file_ends }}, "allowUnknownFileEnds": {{ etherpad_app_file_ends }},
/* /*
* This setting is used if you require authentication of all users. * This setting is used if you require authentication of all users.
* *
* Note: "/admin" always requires authentication. * Note: "/admin" always requires authentication.
*/ */
"requireAuthentication": {{ app_require_authentication }}, "requireAuthentication": {{ etherpad_app_require_authentication }},
/* /*
* Require authorization by a module, or a user with is_admin set, see below. * Require authorization by a module, or a user with is_admin set, see below.
*/ */
"requireAuthorization": {{ app_require_authorization }}, "requireAuthorization": {{ etherpad_app_require_authorization }},
/* /*
* When you use NGINX or another proxy/load-balancer set this to true. * When you use NGINX or another proxy/load-balancer set this to true.
@ -349,7 +349,7 @@
* The other effect will be that the logs will contain the real client's IP, * The other effect will be that the logs will contain the real client's IP,
* instead of the reverse proxy's IP. * instead of the reverse proxy's IP.
*/ */
"trustProxy": {{ app_trust_proxy }}, "trustProxy": {{ etherpad_app_trust_proxy }},
/* /*
* Settings controlling the session cookie issued by Etherpad. * Settings controlling the session cookie issued by Etherpad.
@ -510,7 +510,7 @@
"admin": { "admin": {
// 1) "password" can be replaced with "hash" if you install ep_hash_auth // 1) "password" can be replaced with "hash" if you install ep_hash_auth
// 2) please note that if password is null, the user will not be created // 2) please note that if password is null, the user will not be created
"password": "{{ app_admin_password }}", "password": "{{ etherpad_app_admin_password }}",
"is_admin": true "is_admin": true
} }
}, },

View file

@ -2,8 +2,8 @@
# Certificates # Certificates
# you need a certificate to run in production. see https://letsencrypt.org/ # you need a certificate to run in production. see https://letsencrypt.org/
## ##
ssl_certificate /etc/letsencrypt/live/{{ domains | first }}/fullchain.pem; ssl_certificate /etc/letsencrypt/live/{{ etherpad_domains | first }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{{ domains | first }}/privkey.pem; ssl_certificate_key /etc/letsencrypt/live/{{ etherpad_domains | first }}/privkey.pem;
## ##
# Security hardening (as of Nov 15, 2020) # Security hardening (as of Nov 15, 2020)

View file

@ -6,7 +6,7 @@ map $http_upgrade $connection_upgrade {
server { server {
listen 80; listen 80;
listen [::]:80; listen [::]:80;
server_name {{ domains |first }}; server_name {{ etherpad_domains |first }};
# For certbot # For certbot
include /etc/nginx/snippets/letsencrypt.conf; include /etc/nginx/snippets/letsencrypt.conf;
@ -21,16 +21,16 @@ server {
listen 443 ssl http2; listen 443 ssl http2;
listen [::]:443 ssl http2; listen [::]:443 ssl http2;
server_name {{ domains |first }}; server_name {{ etherpad_domains |first }};
access_log /var/log/nginx/{{ service }}.access.log; access_log /var/log/nginx/{{ service }}.access.log;
error_log /var/log/nginx/{{ service }}.error.log; error_log /var/log/nginx/{{ service }}.error.log;
include /etc/nginx/snippets/letsencrypt.conf; include /etc/nginx/snippets/letsencrypt.conf;
include /etc/nginx/ssl/{{ domains | first }}.conf; include /etc/nginx/ssl/{{ etherpad_domains | first }}.conf;
location / { location / {
proxy_pass http://127.0.0.1:{{ node_port }}; proxy_pass http://127.0.0.1:{{ etherpad_node_port }};
proxy_buffering off; # be careful, this line doesn't override any proxy_buffering on set in a conf.d/file.conf proxy_buffering off; # be careful, this line doesn't override any proxy_buffering on set in a conf.d/file.conf
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_pass_header Server; proxy_pass_header Server;