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

142 lines
3.6 KiB
YAML
Raw Permalink Normal View History

2023-12-12 22:36:35 +01:00
---
- name: "include tasks nginx-docker-proxy-domain.yml"
include_tasks: nginx-docker-proxy-domain.yml
loop: "{{ domains }}"
loop_control:
loop_var: domain
2023-12-12 22:36:35 +01:00
- 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:
2023-12-12 22:36:35 +01:00
state: directory
register: matrix_inventory_tmp_dir
delegate_to: localhost
become: false
2023-12-12 22:36:35 +01:00
- name: protect inventory directory
file:
path: "{{ matrix_inventory_tmp_dir.path }}"
2023-12-21 19:50:19 +01:00
mode: '0700'
delegate_to: localhost
become: false
2023-12-21 19:50:19 +01:00
# Host file
- name: set the hosts files path
set_fact:
hosts_path: "{{ matrix_inventory_tmp_dir.path }}/hosts.yml"
- name: create hosts.yml
2023-12-19 14:07:05 +01:00
template:
src: "hosts.yml.j2"
dest: "{{hosts_path}}"
become: false
delegate_to: localhost
2023-12-19 14:07:05 +01:00
2023-12-21 19:50:19 +01:00
# 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}}"
2023-12-21 20:29:44 +01:00
state: directory
recurse: yes
2023-12-21 19:50:19 +01:00
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: mode_debug | bool
2023-12-12 22:36:35 +01:00
- name: install requirements
local_action: command just roles
args:
chdir: "{{ local_repository_directory }}"
become: false
2023-12-12 22:36:35 +01:00
2023-12-21 19:50:19 +01:00
- 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
#
2023-12-12 22:36:35 +01:00
#- 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