mirror of
https://git.lapiole.org/dani/ansible-roles.git
synced 2025-07-27 00:05:44 +02:00
Update to 2021-12-01 19:13
This commit is contained in:
9
roles/etherpad/tasks/archive_post.yml
Normal file
9
roles/etherpad/tasks/archive_post.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
|
||||
- import_tasks: ../includes/webapps_compress_archive.yml
|
||||
vars:
|
||||
- root_dir: "{{ etherpad_root_dir }}"
|
||||
- version: "{{ current_version }}"
|
||||
when: install_mode == 'upgrade'
|
||||
tags: etherpad
|
||||
|
28
roles/etherpad/tasks/archive_pre.yml
Normal file
28
roles/etherpad/tasks/archive_pre.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
|
||||
- name: Create archive dir
|
||||
file: path={{ etherpad_root_dir }}/archives/{{ etherpad_current_version }} state=directory mode=700
|
||||
tags: etherpad
|
||||
|
||||
- name: Archive previous version
|
||||
synchronize:
|
||||
src: "{{ etherpad_root_dir }}/{{ etherpad_web_dir.stat.exists | ternary('web','app') }}" # previous versions were installed in the web subdir, now in app)
|
||||
dest: "{{ etherpad_root_dir }}/archives/{{ etherpad_current_version }}/"
|
||||
compress: False
|
||||
delete: True
|
||||
delegate_to: "{{ inventory_hostname }}"
|
||||
tags: etherpad
|
||||
|
||||
- name: Dump the database
|
||||
mysql_db:
|
||||
state: dump
|
||||
name: "{{ etherpad_db_name }}"
|
||||
target: "{{ etherpad_root_dir }}/archives/{{ etherpad_current_version }}/{{ etherpad_db_name }}.sql.xz"
|
||||
login_host: "{{ etherpad_db_server | default(mysql_server) }}"
|
||||
login_user: "{{ etherpad_db_user }}"
|
||||
login_password: "{{ etherpad_db_pass }}"
|
||||
quick: True
|
||||
single_transaction: True
|
||||
environment:
|
||||
XZ_OPT: -T0
|
||||
tags: etherpad
|
10
roles/etherpad/tasks/cleanup.yml
Normal file
10
roles/etherpad/tasks/cleanup.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
|
||||
- name: Remove temp and obsolete files
|
||||
file: path={{ etherpad_root_dir }}/{{ item }} state=absent
|
||||
loop:
|
||||
- tmp/etherpad-lite-{{ etherpad_version }}
|
||||
- tmp/etherpad-lite-{{ etherpad_version }}.tar.gz
|
||||
- web
|
||||
- db_dumps
|
||||
tags: etherpad
|
15
roles/etherpad/tasks/conf.yml
Normal file
15
roles/etherpad/tasks/conf.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
|
||||
- name: Configure random keys
|
||||
copy: content={{ item.value }} dest={{ etherpad_root_dir }}/app/{{ item.file }} owner={{ etherpad_user }} group={{ etherpad_user }} mode=600
|
||||
loop:
|
||||
- file: SESSIONKEY.txt
|
||||
value: "{{ etherpad_session_key }}"
|
||||
- file: APIKEY.txt
|
||||
value: "{{ etherpad_api_key }}"
|
||||
tags: etherpad
|
||||
|
||||
- name: Deploy service configuration
|
||||
template: src=settings.json.j2 dest={{ etherpad_root_dir }}/app/settings.json
|
||||
notify: restart etherpad
|
||||
tags: etherpad
|
18
roles/etherpad/tasks/directories.yml
Normal file
18
roles/etherpad/tasks/directories.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
|
||||
- name: Create directories
|
||||
file: path={{ etherpad_root_dir }}/{{ item.dir }} state=directory owner={{ item.owner | default(omit) }} group={{ item.group | default(omit) }} mode={{ item.mode | default(omit) }}
|
||||
loop:
|
||||
- dir: meta
|
||||
mode: 700
|
||||
- dir: tmp
|
||||
mode: 770
|
||||
group: "{{ etherpad_user }}"
|
||||
- dir: backup
|
||||
mode: 700
|
||||
- dir: archives
|
||||
mode: 700
|
||||
- dir: app
|
||||
owner: "{{ etherpad_user }}"
|
||||
tags: etherpad
|
||||
|
46
roles/etherpad/tasks/facts.yml
Normal file
46
roles/etherpad/tasks/facts.yml
Normal file
@@ -0,0 +1,46 @@
|
||||
---
|
||||
|
||||
- block:
|
||||
- import_tasks: ../includes/webapps_set_install_mode.yml
|
||||
vars:
|
||||
root_dir: "{{ etherpad_root_dir }}"
|
||||
version: "{{ etherpad_version }}"
|
||||
- set_fact: etherpad_install_mode={{ install_mode }}
|
||||
- set_fact: etherpad_current_version={{ current_version | default('') }}
|
||||
tags: etherpad
|
||||
|
||||
- when: etherpad_db_pass is not defined
|
||||
block:
|
||||
- import_tasks: ../includes/get_rand_pass.yml
|
||||
vars:
|
||||
- pass_file: "{{etherpad_root_dir }}/meta/ansible_dbpass"
|
||||
- set_fact: etherpad_db_pass={{ rand_pass }}
|
||||
tags: etherpad
|
||||
|
||||
- block:
|
||||
- import_tasks: ../includes/get_rand_pass.yml
|
||||
vars:
|
||||
- pass_file: "{{etherpad_root_dir }}/meta/ansible_session_key"
|
||||
- set_fact: etherpad_session_key={{ rand_pass }}
|
||||
tags: etherpad
|
||||
|
||||
- when: etherpad_api_key is not defined
|
||||
block:
|
||||
- import_tasks: ../includes/get_rand_pass.yml
|
||||
vars:
|
||||
- pass_file: "{{etherpad_root_dir }}/meta/ansible_api_key"
|
||||
- set_fact: etherpad_api_key={{ rand_pass }}
|
||||
tags: etherpad
|
||||
|
||||
- when: etherpad_admin_pass is not defined
|
||||
block:
|
||||
- import_tasks: ../includes/get_rand_pass.yml
|
||||
vars:
|
||||
- pass_file: "{{etherpad_root_dir }}/meta/ansible_admin_pass"
|
||||
- set_fact: etherpad_admin_pass={{ rand_pass }}
|
||||
tags: etherpad
|
||||
|
||||
- name: Check if web dir exists
|
||||
stat: path={{ etherpad_root_dir }}/web
|
||||
register: etherpad_web_dir
|
||||
tags: etherpad
|
78
roles/etherpad/tasks/install.yml
Normal file
78
roles/etherpad/tasks/install.yml
Normal file
@@ -0,0 +1,78 @@
|
||||
---
|
||||
|
||||
- name: Install dependencies
|
||||
yum:
|
||||
name:
|
||||
- nodejs
|
||||
notify: restart etherpad
|
||||
tags: etherpad
|
||||
|
||||
- when: etherpad_install_mode != 'none'
|
||||
block:
|
||||
- name: Download etherpad
|
||||
get_url:
|
||||
url: "{{ etherpad_archive_url }}"
|
||||
dest: "{{ etherpad_root_dir }}/tmp"
|
||||
checksum: "sha1:{{ etherpad_archive_sha1 }}"
|
||||
|
||||
- name: Extract etherpad
|
||||
unarchive:
|
||||
src: "{{ etherpad_root_dir }}/tmp/etherpad-lite-{{ etherpad_version }}.tar.gz"
|
||||
dest: "{{ etherpad_root_dir }}/tmp/"
|
||||
remote_src: True
|
||||
|
||||
- name: Move etherpad to its correct dir
|
||||
synchronize:
|
||||
src: "{{ etherpad_root_dir }}/tmp/etherpad-lite-{{ etherpad_version }}/"
|
||||
dest: "{{ etherpad_root_dir }}/app/"
|
||||
recursive: True
|
||||
delete: True
|
||||
compress: False
|
||||
delegate_to: "{{ inventory_hostname }}"
|
||||
become_user: "{{ etherpad_user }}"
|
||||
|
||||
tags: etherpad
|
||||
|
||||
- name: Install node modules
|
||||
npm:
|
||||
path: "{{ etherpad_root_dir }}/app/src"
|
||||
state: "{{ (etherpad_install_mode == 'none') | ternary('present','latest') }}"
|
||||
become_user: "{{ etherpad_user }}"
|
||||
notify: restart etherpad
|
||||
tags: etherpad
|
||||
|
||||
- name: Install plugins
|
||||
npm:
|
||||
name: ep_{{ item }}
|
||||
path: "{{ etherpad_root_dir }}/app/src"
|
||||
state: "{{ (etherpad_install_mode == 'none') | ternary('present','latest') }}"
|
||||
loop: "{{ etherpad_plugins }}"
|
||||
become_user: "{{ etherpad_user }}"
|
||||
notify: restart etherpad
|
||||
tags: etherpad
|
||||
|
||||
- import_tasks: ../includes/webapps_create_mysql_db.yml
|
||||
vars:
|
||||
- db_name: "{{ etherpad_db_name }}"
|
||||
- db_user: "{{ etherpad_db_user }}"
|
||||
- db_server: "{{ etherpad_db_server }}"
|
||||
- db_pass: "{{ etherpad_db_pass }}"
|
||||
tags: etherpad
|
||||
|
||||
- name: Deploy systemd unit
|
||||
template: src=etherpad.service.j2 dest=/etc/systemd/system/etherpad_{{ etherpad_id }}.service
|
||||
register: etherpad_unit
|
||||
notify: restart etherpad
|
||||
tags: etherpad
|
||||
|
||||
- name: Reload systemd
|
||||
systemd: daemon_reload=True
|
||||
when: etherpad_unit.changed
|
||||
tags: etherpad
|
||||
|
||||
- name: Deploy pre/post backup scripts
|
||||
template: src={{ item }}_backup.sh.j2 dest=/etc/backup/{{ item }}.d/etherpad_{{ etherpad_id }}.sh mode=750
|
||||
loop:
|
||||
- pre
|
||||
- post
|
||||
tags: etherpad
|
10
roles/etherpad/tasks/iptables.yml
Normal file
10
roles/etherpad/tasks/iptables.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
|
||||
- name: Handle Etherpad port
|
||||
iptables_raw:
|
||||
name: etherpad_{{ etherpad_id }}_port
|
||||
state: "{{ (etherpad_src_ip | length > 0) | ternary('present','absent') }}"
|
||||
rules: "-A INPUT -m state --state NEW -p tcp --dport {{ etherpad_port }} -s {{ etherpad_src_ip | join(',') }} -j ACCEPT"
|
||||
when: iptables_manage | default(True)
|
||||
tags: etherpad
|
||||
|
17
roles/etherpad/tasks/main.yml
Normal file
17
roles/etherpad/tasks/main.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
|
||||
- include: user.yml
|
||||
- include: directories.yml
|
||||
- include: facts.yml
|
||||
- include: archive_pre.yml
|
||||
when: etherpad_install_mode == 'upgrade'
|
||||
- include: install.yml
|
||||
- include: conf.yml
|
||||
- include: iptables.yml
|
||||
when: iptables_manage | default(True)
|
||||
- include: service.yml
|
||||
- include: write_version.yml
|
||||
- include: archive_post.yml
|
||||
when: etherpad_install_mode == 'upgrade'
|
||||
- include: cleanup.yml
|
||||
|
7
roles/etherpad/tasks/service.yml
Normal file
7
roles/etherpad/tasks/service.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
|
||||
- name: Start and enable the service
|
||||
service: name=etherpad_{{ etherpad_id }} state=started enabled=True
|
||||
register: etherpad_started
|
||||
tags: etherpad
|
||||
|
7
roles/etherpad/tasks/user.yml
Normal file
7
roles/etherpad/tasks/user.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
|
||||
- import_tasks: ../includes/create_system_user.yml
|
||||
vars:
|
||||
user: "{{ etherpad_user }}"
|
||||
home: "{{ etherpad_root_dir }}"
|
||||
tags: etherpad
|
8
roles/etherpad/tasks/write_version.yml
Normal file
8
roles/etherpad/tasks/write_version.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
|
||||
- import_tasks: ../includes/webapps_post.yml
|
||||
vars:
|
||||
- root_dir: "{{ etherpad_root_dir }}"
|
||||
- version: "{{ etherpad_version }}"
|
||||
tags: etherpad
|
||||
|
Reference in New Issue
Block a user