ansible-role-rocketchat/tasks/rocketchat.yml

110 lines
2.7 KiB
YAML
Raw Normal View History

2022-05-27 23:27:40 +00:00
---
- name: "Open ports for RocketChat"
become: true
2022-05-27 23:27:40 +00:00
ufw:
rule: allow
proto: tcp
port: "{{ item }}"
loop:
- '3000'
- '80'
- '443'
- '22'
- name: Creates directory structure for rocketchat data
2022-05-27 23:27:40 +00:00
file:
path: /home/{{ main_user }}/rocketchat/data
2022-05-27 23:27:40 +00:00
state: directory
owner: "{{ main_user }}"
group: "{{ main_user }}"
mode: 0775
- name: Creates directory structure for nginx data
file:
path: /home/{{ main_user }}/rocketchat/nginx
state: directory
owner: "{{ main_user }}"
group: "{{ main_user }}"
mode: 0775
- name: Creates directory structure for upload data
2022-07-08 01:36:59 +00:00
become: true
file:
path: /home/{{ main_user }}/rocketchat/uploads
state: directory
owner: "{{ main_user }}"
group: "{{ main_user }}"
mode: 0775
- name: Ensure mmap to wiredTiger mongoDB repo checkout exists
ansible.builtin.git:
repo: 'https://github.com/RocketChat/docker-mmap-to-wiredtiger-migration.git'
dest: /home/{{ main_user }}/rocketchat/rocketchat-migration
2022-07-08 03:14:31 +00:00
update: no
- name: Copy docker folder from mmap to wiredTiger mongoDB migration repo
ansible.builtin.copy:
src: /home/{{ main_user }}/rocketchat/rocketchat-migration/docker
dest: /home/{{ main_user }}/rocketchat/docker
remote_src: yes
- name: copy docker compose to server (from template)
template:
src: templates/docker-compose.yml.j2
dest: /home/{{ main_user }}/rocketchat/docker-compose.yml
- name: bring down rocketchat docker-compose
2022-05-27 23:27:40 +00:00
become_user: "{{ main_user }}"
docker_compose:
project_src: /home/{{ main_user }}/rocketchat/
2022-05-27 23:27:40 +00:00
state: absent
remove_orphans: true
register: __remove_rocketchat
2022-05-27 23:27:40 +00:00
tags:
- bring-down
- name: update permissions
become: true
2022-05-27 23:27:40 +00:00
file:
path: /home/{{ main_user }}
state: directory
recurse: yes
owner: "{{ main_user }}"
group: "{{ main_user }}"
mode: 0775
- name: setup nginx reverse proxy from template
template:
2022-05-30 04:03:36 +00:00
src: templates/nginx.conf.j2
dest: /home/{{ main_user }}/rocketchat/nginx/nginx.conf
2022-05-27 23:27:40 +00:00
- name: docker compose up
become_user: "{{ main_user }}"
docker_compose:
project_src: /home/{{ main_user }}/rocketchat/
2022-05-27 23:27:40 +00:00
state: present
register: __rocketchat
2022-05-27 23:27:40 +00:00
- name: Get the current datetime
debug:
var: ansible_date_time
- name: Backup existing RocketChat mongo database
when: backup_db
community.docker.docker_container_exec:
2022-07-08 03:26:07 +00:00
container: rocketchat_mongo_1
command: mongodump --archive=/dump/{{ ansible_date_time.iso8601 }} --gzip
chdir: /home/{{ main_user }}/rocketchat
register: __backup_result
2022-05-27 23:27:40 +00:00
- name: debug docker compose down
debug:
var: __remove_rocketchat
2022-05-27 23:27:40 +00:00
- name: debug docker compose up debug
2022-05-27 23:27:40 +00:00
debug:
var: __rocketchat
- name: debug mongo backup
debug:
var: __backup_result