computer-playbook/roles/docker-matrix/tasks/main.yml

142 lines
3.6 KiB
YAML

---
- name: "include tasks nginx-docker-proxy-domain.yml"
include_tasks: nginx-docker-proxy-domain.yml
loop: "{{ domains }}"
loop_control:
loop_var: domain
- name: Clone the git repository
git:
repo: https://github.com/spantaleev/matrix-docker-ansible-deploy.git
dest: "{{ local_repository_directory }}"
update: yes
delegate_to: localhost
become: false
- name: create temporary inventory directory
tempfile:
state: directory
register: matrix_inventory_tmp_dir
delegate_to: localhost
become: false
- name: protect inventory directory
file:
path: "{{ matrix_inventory_tmp_dir.path }}"
mode: '0700'
delegate_to: localhost
become: false
# Host file
- name: set the hosts files path
set_fact:
hosts_path: "{{ matrix_inventory_tmp_dir.path }}/hosts.yml"
- name: create hosts.yml
template:
src: "hosts.yml.j2"
dest: "{{hosts_path}}"
become: false
delegate_to: localhost
# Vars file
- name: set the vars folder path
set_fact:
vars_folder_path: "{{ matrix_inventory_tmp_dir.path }}/host_vars/{{inventory_hostname}}/"
- name: create vars directory
file:
path: "{{vars_folder_path}}"
mode: '0700'
delegate_to: localhost
become: false
- name: set the vars path
set_fact:
vars_file_path: "{{ vars_folder_path }}vars.yml"
- name: create vars.yml
template:
src: "vars.yml.j2"
dest: "{{vars_file_path}}"
become: false
delegate_to: localhost
- name: show variable information
debug:
msg: "hosts_path: {{hosts_path}}\nmatrix_inventory_tmp_dir:{{ matrix_inventory_tmp_dir }}"
when: verbose | bool
- name: install requirements
local_action: command just roles
args:
chdir: "{{ local_repository_directory }}"
become: false
- name: play matrix-docker-ansible-deploy
local_action: "command ansible-playbook -i {{hosts_path}} {{local_repository_directory}}/setup.yml -vvv --tags={{matrix_playbook_tags}}"
become: false
#- name: delete inventory directory
# file:
# path: "{{ matrix_inventory_tmp_dir.path }}"
# state: absent
# delegate_to: localhost
# become: false
#
#- name: "create {{docker_compose_instance_directory}}"
# file:
# path: "{{docker_compose_instance_directory}}"
# state: directory
# mode: 0755
#
#- name: "create {{docker_compose_instance_directory}}mautrix_whatsapp"
# file:
# path: "{{docker_compose_instance_directory}}mautrix_whatsapp"
# state: directory
# mode: 0755
#
#- name: add whatsapp-bridge-config.yml
# template:
# src: "whatsapp-bridge-config.yml.j2"
# dest: "{{docker_compose_instance_directory}}mautrix_whatsapp/config.yml"
# notify: recreate matrix
#
#- name: add element-config.json
# template:
# src: "element-config.json.j2"
# dest: "{{docker_compose_instance_directory}}element-config.json"
# notify: recreate matrix
#
#- name: add homeserver.yaml
# template:
# src: "homeserver.yaml.j2"
# dest: "{{docker_compose_instance_directory}}homeserver.yaml"
# notify: recreate matrix
#
#- name: add log.config
# template:
# src: "log.config.j2"
# dest: "{{docker_compose_instance_directory}}{{synapse_domain}}.log.config"
# notify: recreate matrix
#
## https://github.com/matrix-org/synapse/issues/6303
#- name: set correct folder permissions
# command:
# cmd: "docker run --rm --mount type=volume,src=matrix_synapse_data,dst=/data -e SYNAPSE_SERVER_NAME={{synapse_domain}} -e SYNAPSE_REPORT_STATS=no --entrypoint /bin/sh matrixdotorg/synapse:latest -c 'chown -vR 991:991 /data'"
#
#- name: add docker-compose.yml
# template:
# src: "docker-compose.yml.j2"
# dest: "{{docker_compose_instance_directory}}docker-compose.yml"
# notify: recreate matrix