diff options
author | Sacha Chua <sacha@sachachua.com> | 2022-10-16 18:11:09 -0400 |
---|---|---|
committer | Sacha Chua <sacha@sachachua.com> | 2022-10-16 18:11:09 -0400 |
commit | 12c465a8f6e127a599b0477094552fc90c7e2ce0 (patch) | |
tree | 81abef4c2a2d0230ca403eed1133815f2e37a740 /roles/pad/tasks | |
parent | 84ccb907a14bd8bd06afec7b5ac836fa7a0883f6 (diff) | |
parent | 54af5163644ef58a641e86288c7af8653970a319 (diff) | |
download | emacsconf-ansible-12c465a8f6e127a599b0477094552fc90c7e2ce0.tar.xz emacsconf-ansible-12c465a8f6e127a599b0477094552fc90c7e2ce0.zip |
Merge branch 'main' of git.emacsconf.org:pub/emacsconf-ansible into main
Diffstat (limited to 'roles/pad/tasks')
-rw-r--r-- | roles/pad/tasks/loadtest.yml | 11 | ||||
-rw-r--r-- | roles/pad/tasks/main.yml | 120 | ||||
-rw-r--r-- | roles/pad/tasks/mariadb.yml | 42 |
3 files changed, 173 insertions, 0 deletions
diff --git a/roles/pad/tasks/loadtest.yml b/roles/pad/tasks/loadtest.yml new file mode 100644 index 0000000..28deefc --- /dev/null +++ b/roles/pad/tasks/loadtest.yml @@ -0,0 +1,11 @@ +--- +- name: Install loadtest configuration + become: true + template: + src: loadtest.settings.json + dest: "{{ etherpad_path }}/settings.json" +- name: Restart Etherpad + become: true + service: + name: etherpad + state: restarted diff --git a/roles/pad/tasks/main.yml b/roles/pad/tasks/main.yml new file mode 100644 index 0000000..01b2da7 --- /dev/null +++ b/roles/pad/tasks/main.yml @@ -0,0 +1,120 @@ +--- +# tasks file for pad +- name: Set up packages as root + block: + - name: Add GPG + apt: + update_cache: yes + name: + - gpg + - sudo + - name: Add nodesource key + apt_key: + url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key + state: present + - name: Add nodesource repository + ansible.builtin.apt_repository: + repo: deb https://deb.nodesource.com/node_13.x buster main + update_cache: yes + - name: Install packages + apt: + update_cache: yes + name: + - git + - systemd + - sudo + - nodejs + - mariadb-server + - mariadb-client + state: present + - name: Create etherpad user + user: + name: etherpad + home: /home/etherpad + shell: /bin/bash + state: present +- include: mariadb.yml + become: true +- name: Set up etherpad as the etherpad user + tags: etherpad-src + become: true + block: + - name: Install etherpad + git: + repo: https://github.com/ether/etherpad-lite.git + dest: "{{ etherpad_path }}" + depth: 1 + - name: Configure etherpad + template: + src: templates/settings.json + dest: "{{ etherpad_path }}/settings.json" + - name: Install dependencies + shell: cd {{ etherpad_path }}; . src/bin/functions.sh; src/bin/installDeps.sh + # - name: Install etherpad plugins + # npm: + # name: ep_scrolltoanchor + # path: "{{ etherpad_path }}" + - name: Change ownership + file: + dest: /home/etherpad/etherpad + owner: "{{ etherpad_user }}" + group: "{{ etherpad_group }}" + recurse: true + - name: Set etherpad API key + copy: + content: "{{ etherpad_api_key }}" + dest: "{{ etherpad_path }}/APIKEY.txt" + owner: "{{ etherpad_user }}" + mode: "0600" +- name: Install init.d configuration + tags: system + become: true + template: + src: etherpad.init.d + dest: /etc/init.d/etherpad + owner: root + group: root + mode: 0755 + when: use_initd +- name: Install systemd configuration + tags: system + become: true + template: + src: etherpad.service + dest: /etc/systemd/system/etherpad.service + owner: root + group: root + mode: 0755 + when: not use_initd +- name: Restart Etherpad + become: true + service: + name: etherpad + state: restarted +- tags: create-pads + include_vars: + file: talks.json + name: talks +- name: Set slugs + tags: create-pads + set_fact: + slugs: +- name: Wait for OK + tags: create-pads + uri: + url: "http://localhost:9001/api/1/createPad?apikey={{ etherpad_api_key }}&padID={{etherpad_year}}" + register: _result + until: _result.status == 200 + retries: 720 + delay: 5 +- debug: + var: _result + tags: create-pads +- name: Create pads + tags: create-pads + uri: + url: "http://localhost:9001/api/1/createPad?apikey={{ etherpad_api_key }}&padID={{etherpad_year}}-{{ item.slug }}" + loop: "{{ talks | json_query('talks[*]') }}" +- include: loadtest.yml + become: true + when: load_test is defined diff --git a/roles/pad/tasks/mariadb.yml b/roles/pad/tasks/mariadb.yml new file mode 100644 index 0000000..ec81430 --- /dev/null +++ b/roles/pad/tasks/mariadb.yml @@ -0,0 +1,42 @@ +--- +- name: Install MySQL packages + apt: + name: + - mariadb-server + - mariadb-client + - python3-mysqldb +- name: Ensure mysql is configured to bind only to localhost + ini_file: + dest: /etc/mysql/my.cnf + section: mysqld + option: "bind-address" + value: "127.0.0.1" +- name: Start MariaDB + service: + name: mysql + state: restarted + enabled: yes + runlevel: + - 3 + - 5 +- name: Ensure anonymous users are not in the database + mysql_user: + name: "" + host: "{{ item }}" + state: absent + with_items: + - localhost + - 127.0.0.1 + - ::1 + - "%" +- name: Ensure emacsconf-pad database exists + mysql_db: + name: "{{ etherpad_database_name }}" + collation: utf8mb4_general_ci + state: present +- name: Grant permissions to user + mysql_user: + name: "{{ etherpad_database_user }}" + state: present + priv: "{{ etherpad_database_name }}.*:ALL" + password: "{{ etherpad_database_password }}" |