From aa798535cdd76257ba2ec54a53bd9baf8a54a68a Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 17 Oct 2019 20:02:22 +0200 Subject: basic etherpad installation works now --- roles/etherpad-lite/tasks/main.yml | 128 +++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 roles/etherpad-lite/tasks/main.yml (limited to 'roles/etherpad-lite/tasks') diff --git a/roles/etherpad-lite/tasks/main.yml b/roles/etherpad-lite/tasks/main.yml new file mode 100644 index 00000000..05bf32ce --- /dev/null +++ b/roles/etherpad-lite/tasks/main.yml @@ -0,0 +1,128 @@ +--- +- name: create zfs datasets + when: etherpad_lite_zfs is defined + block: + - name: create zfs base dataset + zfs: + name: "{{ etherpad_lite_zfs.pool }}/{{ etherpad_lite_zfs.name }}" + state: present + extra_zfs_properties: + quota: "{{ etherpad_lite_zfs.size }}" + + - name: create zfs volumes for instances + loop: "{{ etherpad_lite_instances | dict2items }}" + loop_control: + label: "{{ item.key }} ({{ item.value.quota }})" + zfs: + name: "{{ etherpad_lite_zfs.pool }}/{{ etherpad_lite_zfs.name }}/{{ item.key }}" + state: present + extra_zfs_properties: + quota: "{{ item.value.quota }}" + + - name: configure etherpad_lite base bath + set_fact: + etherpad_lite_base_path: "{{ zfs_zpools[etherpad_lite_zfs.pool].mountpoint }}/{{ etherpad_lite_zfs.name }}" + + +- name: create instance subdirectories + when: etherpad_lite_zfs is not defined + loop: "{{ etherpad_lite_instances | list }}" + file: + path: "{{ etherpad_lite_base_path }}/{{ item }}" + state: directory + + + +- name: add group for etherpad-lite app + group: + name: epl-app + gid: "{{ etherpad_lite_app_gid }}" + +- name: add user for etherpad-lite app + user: + name: epl-app + uid: "{{ etherpad_lite_app_uid }}" + group: epl-app + password: "!" + +- name: create etherpad_lite app subdirectory + loop: "{{ etherpad_lite_instances | list }}" + file: + path: "{{ etherpad_lite_base_path }}/{{ item }}/etherpad-lite" + owner: "{{ etherpad_lite_app_uid }}" + group: "{{ etherpad_lite_app_gid }}" + state: directory + + +- name: add group for etherpad-lite db + group: + name: epl-db + gid: "{{ etherpad_lite_db_gid }}" + +- name: add user for etherpad-lite db + user: + name: epl-db + uid: "{{ etherpad_lite_db_uid }}" + group: epl-db + password: "!" + +- name: create etherpad-lite database subdirectory + loop: "{{ etherpad_lite_instances | dict2items}}" + loop_control: + label: "{{ item.key }} ({{ item.value.database.type }})" + file: + path: "{{ etherpad_lite_base_path }}/{{ item.key }}/{{ item.value.database.type }}" + owner: "{{ etherpad_lite_db_uid }}" + group: "{{ etherpad_lite_db_gid }}" + state: directory + + +- name: create etherpad-lite config directory + loop: "{{ etherpad_lite_instances | list }}" + file: + path: "{{ etherpad_lite_base_path }}/{{ item }}/config" + state: directory + +- name: create settings json + loop: "{{ etherpad_lite_instances | dict2items }}" + loop_control: + label: "{{ item.key }}" + copy: + content: "{{ item.value.settings | combine({'ip': '0.0.0.0', 'port': 9001}) | to_nice_json }}" + dest: "{{ etherpad_lite_base_path }}/{{ item.key }}/config/settings.json" + mode: 0644 + owner: "{{ etherpad_lite_app_uid }}" + group: "{{ etherpad_lite_app_gid }}" + +- name: create db credentials json + loop: "{{ etherpad_lite_instances | dict2items }}" + loop_control: + label: "{{ item.key }}" + copy: + content: "{{ item.value.credentials | to_nice_json }}" + dest: "{{ etherpad_lite_base_path }}/{{ item.key }}/config/credentials.json" + mode: 0600 + owner: "{{ etherpad_lite_app_uid }}" + group: "{{ etherpad_lite_app_gid }}" + + +- name: generate pod manifests + loop: "{{ etherpad_lite_instances | dict2items }}" + loop_control: + label: "{{ item.key }}" + template: + src: "pod-with-{{ item.value.database.type }}.yml.j2" + dest: "/etc/kubernetes/manifests/etherpad-lite-{{ item.key }}.yml" + mode: 0600 + + +- name: configure nginx vhost + loop: "{{ etherpad_lite_instances | dict2items }}" + include_role: + name: nginx/vhost + vars: + nginx_vhost: + name: "etherpad-lite-{{ item.key }}" + content: "{{ lookup('template', 'nginx-vhost.conf.j2') }}" + acme: true + hostnames: "{{ item.value.hostnames }}" -- cgit v1.2.3