2022-05-27 23:27:40 +00:00
|
|
|
---
|
2022-07-08 02:47:17 +00:00
|
|
|
- name: "Open ports for RocketChat"
|
2022-07-07 21:03:54 +00:00
|
|
|
become: true
|
2022-05-27 23:27:40 +00:00
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
proto: tcp
|
|
|
|
port: "{{ item }}"
|
|
|
|
loop:
|
|
|
|
- '3000'
|
|
|
|
- '80'
|
|
|
|
- '443'
|
|
|
|
- '22'
|
|
|
|
|
2022-05-30 04:09:48 +00:00
|
|
|
- name: Creates directory structure for rocketchat data
|
2022-05-27 23:27:40 +00:00
|
|
|
file:
|
2022-05-30 02:03:23 +00:00
|
|
|
path: /home/{{ main_user }}/rocketchat/data
|
2022-05-27 23:27:40 +00:00
|
|
|
state: directory
|
|
|
|
owner: "{{ main_user }}"
|
|
|
|
group: "{{ main_user }}"
|
|
|
|
mode: 0775
|
|
|
|
|
2022-05-30 04:09:48 +00:00
|
|
|
- name: Creates directory structure for nginx data
|
|
|
|
file:
|
|
|
|
path: /home/{{ main_user }}/rocketchat/nginx
|
|
|
|
state: directory
|
|
|
|
owner: "{{ main_user }}"
|
|
|
|
group: "{{ main_user }}"
|
|
|
|
mode: 0775
|
|
|
|
|
2022-07-08 01:33:50 +00:00
|
|
|
- name: Creates directory structure for upload data
|
2022-07-08 01:36:59 +00:00
|
|
|
become: true
|
2022-07-08 01:33:50 +00:00
|
|
|
file:
|
|
|
|
path: /home/{{ main_user }}/rocketchat/uploads
|
|
|
|
state: directory
|
|
|
|
owner: "{{ main_user }}"
|
|
|
|
group: "{{ main_user }}"
|
|
|
|
mode: 0775
|
|
|
|
|
2022-07-08 03:57:36 +00:00
|
|
|
- name: Creates backup directory outside of docker volumes to move dumps more easily off of server
|
|
|
|
file:
|
|
|
|
path: /home/{{ main_user }}/backups
|
|
|
|
state: directory
|
|
|
|
owner: "{{ main_user }}"
|
|
|
|
group: "{{ main_user }}"
|
|
|
|
mode: 0775
|
|
|
|
|
2022-07-08 01:46:37 +00:00
|
|
|
- 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
|
2022-07-08 01:46:37 +00:00
|
|
|
|
|
|
|
- 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
|
|
|
|
|
2022-07-08 02:14:35 +00:00
|
|
|
- name: copy docker compose to server (from template)
|
|
|
|
template:
|
|
|
|
src: templates/docker-compose.yml.j2
|
|
|
|
dest: /home/{{ main_user }}/rocketchat/docker-compose.yml
|
2022-05-30 03:52:02 +00:00
|
|
|
|
2022-05-30 02:03:23 +00:00
|
|
|
- name: bring down rocketchat docker-compose
|
2022-05-27 23:27:40 +00:00
|
|
|
become_user: "{{ main_user }}"
|
|
|
|
docker_compose:
|
2022-05-30 02:03:23 +00:00
|
|
|
project_src: /home/{{ main_user }}/rocketchat/
|
2022-05-27 23:27:40 +00:00
|
|
|
state: absent
|
2022-07-08 02:14:35 +00:00
|
|
|
remove_orphans: true
|
2022-05-30 02:03:23 +00:00
|
|
|
register: __remove_rocketchat
|
2022-05-27 23:27:40 +00:00
|
|
|
tags:
|
|
|
|
- bring-down
|
|
|
|
|
|
|
|
- name: update permissions
|
2022-07-07 21:03:54 +00:00
|
|
|
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
|
|
|
|
|
2022-05-30 02:03:23 +00:00
|
|
|
- name: setup nginx reverse proxy from template
|
|
|
|
template:
|
2022-05-30 04:03:36 +00:00
|
|
|
src: templates/nginx.conf.j2
|
2022-05-30 02:03:23 +00:00
|
|
|
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:
|
2022-05-30 02:03:23 +00:00
|
|
|
project_src: /home/{{ main_user }}/rocketchat/
|
2022-05-27 23:27:40 +00:00
|
|
|
state: present
|
2022-05-30 02:03:23 +00:00
|
|
|
register: __rocketchat
|
2022-05-27 23:27:40 +00:00
|
|
|
|
2022-07-08 02:47:17 +00:00
|
|
|
- name: Get the current datetime
|
|
|
|
debug:
|
|
|
|
var: ansible_date_time
|
|
|
|
|
|
|
|
- name: Backup existing RocketChat mongo database
|
2022-07-08 02:48:50 +00:00
|
|
|
when: backup_db
|
2022-07-08 02:47:17 +00:00
|
|
|
community.docker.docker_container_exec:
|
2022-07-08 03:26:07 +00:00
|
|
|
container: rocketchat_mongo_1
|
2022-07-08 02:50:05 +00:00
|
|
|
command: mongodump --archive=/dump/{{ ansible_date_time.iso8601 }} --gzip
|
2022-07-08 03:33:20 +00:00
|
|
|
# chdir: /home/{{ main_user }}/rocketchat
|
|
|
|
# chdir: /
|
2022-07-08 02:47:17 +00:00
|
|
|
register: __backup_result
|
2022-07-08 04:09:19 +00:00
|
|
|
tags: mongodump
|
2022-07-08 02:47:17 +00:00
|
|
|
|
2022-07-08 03:57:36 +00:00
|
|
|
- name: Copy backup we just took to home/{{ main_user }}/backups
|
|
|
|
when: backup_db and not __backup_result.failed
|
|
|
|
ansible.builtin.copy:
|
2022-07-08 04:04:31 +00:00
|
|
|
src: /home/{{ main_user }}/rocketchat/data/dump/{{ ansible_date_time.iso8601 }}
|
2022-07-08 03:57:36 +00:00
|
|
|
dest: /home/{{ main_user }}/backups/{{ ansible_date_time.iso8601 }}.gzip
|
|
|
|
remote_src: yes
|
2022-07-08 04:09:19 +00:00
|
|
|
tags: mongodump
|
2022-07-08 03:57:36 +00:00
|
|
|
|
|
|
|
- name: Pull newly created mongodump into local backups directory
|
|
|
|
when: backup_db and not __backup_result.failed
|
|
|
|
ansible.builtin.fetch:
|
|
|
|
src: /home/{{ main_user }}/backups/{{ ansible_date_time.iso8601 }}.gzip
|
2022-07-08 03:59:19 +00:00
|
|
|
dest: "{{ local_backup_dir }}"
|
2022-07-08 04:09:19 +00:00
|
|
|
tags: mongodump
|
2022-07-08 03:57:36 +00:00
|
|
|
|
2022-07-08 05:06:42 +00:00
|
|
|
- name: Set feature compability version if we are upgrading mongoDB
|
2022-07-08 05:18:38 +00:00
|
|
|
when: set_feature_compat_version
|
2022-07-08 05:06:42 +00:00
|
|
|
community.docker.docker_container_exec:
|
|
|
|
container: rocketchat_mongo_1
|
|
|
|
command: >
|
|
|
|
bash -c 'mongo --eval "db.adminCommand( { setFeatureCompatibilityVersion: \"{{ prev_mongo_version }}\" } )"'
|
|
|
|
# chdir: /home/{{ main_user }}/rocketchat
|
|
|
|
# chdir: /
|
|
|
|
#docker-compose exec mongo
|
|
|
|
register: __set_feature_compability_version_mongo
|
|
|
|
tags: mongoupgrade
|
|
|
|
|
2022-05-27 23:27:40 +00:00
|
|
|
- name: debug docker compose down
|
|
|
|
debug:
|
2022-05-30 02:03:23 +00:00
|
|
|
var: __remove_rocketchat
|
2022-07-08 05:06:42 +00:00
|
|
|
tags: bring-down
|
2022-05-27 23:27:40 +00:00
|
|
|
|
2022-05-30 02:03:23 +00:00
|
|
|
- name: debug docker compose up debug
|
2022-05-27 23:27:40 +00:00
|
|
|
debug:
|
2022-05-30 02:03:23 +00:00
|
|
|
var: __rocketchat
|
2022-07-08 02:47:17 +00:00
|
|
|
|
|
|
|
- name: debug mongo backup
|
2022-07-08 03:57:36 +00:00
|
|
|
when: backup_db
|
2022-07-08 02:47:17 +00:00
|
|
|
debug:
|
2022-07-08 04:09:19 +00:00
|
|
|
var: __backup_result
|
|
|
|
tags: mongodump
|
2022-07-08 05:06:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
- name: debug mongo upgrade set feature compatability version
|
|
|
|
when: prev_mongo_version and prev_mongo_version != mongo_version
|
|
|
|
debug:
|
|
|
|
var: __set_feature_compability_version_mongo
|
|
|
|
tags: mongoupgrade
|