Просмотр исходного кода

First pass at creating defaults and tasks for Conduit

pull/2002/head
Charles Wright 3 лет назад
Родитель
Сommit
c484c6294d
7 измененных файлов: 153 добавлений и 0 удалений
  1. +49
    -0
      roles/matrix-conduit/defaults/main.yml
  2. +7
    -0
      roles/matrix-conduit/tasks/conduit/setup.yml
  3. +31
    -0
      roles/matrix-conduit/tasks/conduit/setup_install.yml
  4. +30
    -0
      roles/matrix-conduit/tasks/conduit/setup_uninstall.yml
  5. +5
    -0
      roles/matrix-conduit/tasks/init.yml
  6. +17
    -0
      roles/matrix-conduit/tasks/main.yml
  7. +14
    -0
      roles/matrix-conduit/tasks/setup_conduit.yml

+ 49
- 0
roles/matrix-conduit/defaults/main.yml Просмотреть файл

@@ -0,0 +1,49 @@
---
# Conduit is a simple, fast and reliable chat server powered by Matrix
# See: https://conduit.rs

matrix_conduit_enabled: true

matrix_conduit_docker_image: "{{ matrix_conduit_docker_image_name_prefix}}matrixconduit/matrix-conduit:{{ matrix_conduit_docker_image_tag }}"
matrix_conduit_docker_image_name_prefix: "docker.io/"
matrix_conduit_docker_image_tag: "v0.4.0"
matrix_conduit_docker_image_force_pull: "{{ matrix_conduit_docker_image.endswith(':latest') }}"

matrix_conduit_base_path: "{{ matrix_base_data_path }}/conduit"
matrix_conduit_config_dir_path: "{{ matrix_conduit_base_path }}/config"
matrix_conduit_storage_path: "{{ matrix_conduit_base_path }}/storage"

matrix_conduit_port_number: 6167

# List of systemd services that matrix-conduit.service depends on
matrix_conduit_systemd_required_services_list: ["docker.service"]

# List of systemd services that matrix-conduit.service wants
matrix_conduit_systemd_wanted_services_list: []

# Extra arguments for the Docker container
matrix_conduit_container_extra_arguments: []

# Specifies which template files to use when configuring Conduit.
# If you'd like to have your own different configuration, feel free to copy and paste
# the original files into your inventory (e.g. in `inventory/host_vars/<host>/`)
# and then change the specific host's `vars.yaml` file like this:
# matrix_conduit_template_conduit_config: "{{ playbook_dir }}/inventory/host_vars/<host>/conduit.yaml.j2"
matrix_conduit_template_conduit_config: "{{ role_path }}/templates/conduit/conduit.toml.j2"

# Max size for uploads, in bytes
matrix_conduit_max_request_size: "20_000_000"

# Enables registration. If set to false, no users can register on this server.
matrix_conduit_allow_registration: true

matrix_conduit_allow_federation: true

# Enable the display name lightning bolt on registration.
matrix_conduit_enable_lightning_bolt: true

matrix_conduit_trusted_servers:
- "matrix.org"

# How many requests Conduit sends to other servers at the same time
matrix_conduit_max_concurrent_requests: 100

+ 7
- 0
roles/matrix-conduit/tasks/conduit/setup.yml Просмотреть файл

@@ -0,0 +1,7 @@
---

- import_tasks: "{{ role_path }}/tasks/conduit/setup_install.yml"
when: matrix_conduit_enabled|bool

- import_tasks: "{{ role_path }}/tasks/conduit/setup_uninstall.yml"
when: "not matrix_conduit_enabled|bool"

+ 31
- 0
roles/matrix-conduit/tasks/conduit/setup_install.yml Просмотреть файл

@@ -0,0 +1,31 @@
---
- name: Ensure Conduit Docker image is pulled
docker_image:
name: "{{ matrix_conduit_docker_image }}"
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
force_source: "{{ matrix_conduit_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_conduit_docker_image_force_pull }}"
register: result
retries: "{{ matrix_container_retries_count }}"
delay: "{{ matrix_container_retries_delay }}"
until: result is not failed

- name: Ensure Conduit configuration installed
template:
src: "{{ role_path }}/templates/conduit/conduit.toml.j2"
dest: "{{ matrix_conduit_config_dir_path }}/conduit.toml"
mode: 0644
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"

- name: Ensure matrix-conduit.service installed
template:
src: "{{ role_path }}/templates/conduit/systemd/matrix-conduit.service.j2"
dest: "{{ matrix_systemd_path }}/matrix-conduit.service"
mode: 0644
register: matrix_conduit_systemd_service_result

- name: Ensure systemd reloaded after matrix-conduit.service installation
service:
daemon_reload: true
when: "matrix_conduit_systemd_service_result.changed|bool"

+ 30
- 0
roles/matrix-conduit/tasks/conduit/setup_uninstall.yml Просмотреть файл

@@ -0,0 +1,30 @@
---

- name: Check existence of matrix-conduit service
stat:
path: "{{ matrix_systemd_path }}/matrix-conduit.service"
register: matrix_conduit_service_stat

- name: Ensure matrix-conduit is stopped
service:
name: matrix-conduit
state: stopped
daemon_reload: true
register: stopping_result
when: "matrix_conduit_service_stat.stat.exists"

- name: Ensure matrix-conduit.service doesn't exist
file:
path: "{{ matrix_systemd_path }}/matrix-conduit.service"
state: absent
when: "matrix_conduit_service_stat.stat.exists"

- name: Ensure systemd reloaded after matrix-conduit.service removal
service:
daemon_reload: true
when: "matrix_conduit_service_stat.stat.exists"

- name: Ensure Conduit Docker image doesn't exist
docker_image:
name: "{{ matrix_conduit_docker_image }}"
state: absent

+ 5
- 0
roles/matrix-conduit/tasks/init.yml Просмотреть файл

@@ -0,0 +1,5 @@
---

- set_fact:
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-conduit.service'] }}"
when: matrix_conduit_enabled|bool

+ 17
- 0
roles/matrix-conduit/tasks/main.yml Просмотреть файл

@@ -0,0 +1,17 @@
---

- import_tasks: "{{ role_path }}/tasks/init.yml"
tags:
- always

- import_tasks: "{{ role_path }}/tasks/setup_conduit.yml"
when: run_setup|bool
tags:
- setup-all
- setup-conduit

- name: Mark matrix-conduit role as executed
set_fact:
matrix_conduit_role_executed: true
tags:
- always

+ 14
- 0
roles/matrix-conduit/tasks/setup_conduit.yml Просмотреть файл

@@ -0,0 +1,14 @@
---
- name: Ensure Conduit paths exist
file:
path: "{{ item.path }}"
state: directory
mode: 0750
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
with_items:
- {path: "{{ matrix_conduit_config_dir_path }}", when: true}
- {path: "{{ matrix_conduit_data_dir_path }}", when: true}
when: "matrix_conduit_enabled|bool and item.when"

- import_tasks: "{{ role_path }}/tasks/conduit/setup.yml"

Загрузка…
Отмена
Сохранить