Skip to content

Commit

Permalink
Rocket.Chat: Role refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
owine committed Mar 12, 2024
1 parent 80cdab9 commit 5bfacc9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
5 changes: 3 additions & 2 deletions roles/rocketchat/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ rocketchat_docker_ports: "{{ rocketchat_docker_ports_defaults
rocketchat_docker_envs_default:
TZ: "{{ tz }}"
ROOT_URL: "{{ rocketchat_web_url }}"
MONGO_URL: mongodb://rocketchat_db:27017/rocketchat
MONGO_OPLOG_URL: mongodb://rocketchat_db:27017/local
MONGO_URL: mongodb://rocketchat_db:27017/rocketchat?replicaSet=rs0
MONGO_OPLOG_URL: mongodb://rocketchat_db:27017/local?replicaSet=rs0
DEPLOY_METHOD: docker
rocketchat_docker_envs_custom: {}
rocketchat_docker_envs: "{{ rocketchat_docker_envs_default
| combine(rocketchat_docker_envs_custom) }}"
Expand Down
34 changes: 19 additions & 15 deletions roles/rocketchat/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
name: mongodb
vars:
mongodb_instances: ["rocketchat_db"]
mongodb_docker_commands: "mongod --oplogSize 128 --replSet rs0"
mongodb_docker_image_tag: "5"
mongodb_docker_envs_custom:
MONGODB_REPLICA_SET_MODE: primary
MONGODB_REPLICA_SET_NAME: rs0
MONGODB_ENABLE_JOURNAL: true

- name: Add DNS record
ansible.builtin.include_tasks: "{{ resources_tasks_path }}/dns/tasker.yml"
Expand All @@ -33,20 +37,20 @@
mode: "0775"
with_items: "{{ lookup('vars', role_name + '_paths_folders_list') }}"

# this container's job is just to run the command to initialize the replica set.
# it will run the command and will later be removed automatically
- name: Initialize MongoDB Replica Set
community.docker.docker_container:
name: "rocketchat-mongo-init-replica"
image: "mongo:latest"
command: 'bash -c "for i in `seq 1 30`; do mongo rocketchat_db/rocketchat --eval \"rs.initiate({ _id: ''rs0'', members: [ { _id: 0, host: ''localhost:27017'' } ]})\" && s=$$? && break || s=$$?; echo \"Tried $$i times. Waiting 5 secs...\"; sleep 5; done; (exit $$s)"'
networks:
- name: saltbox
comparisons:
'*': ignore
auto_remove: yes
state: started
pull: true
# # this container's job is just to run the command to initialize the replica set.
# # it will run the command and will later be removed automatically
# - name: Initialize MongoDB Replica Set
# community.docker.docker_container:
# name: "rocketchat-mongo-init-replica"
# image: "mongo:latest"
# command: 'bash -c "for i in `seq 1 30`; do mongo rocketchat_db/rocketchat --eval \"rs.initiate({ _id: ''rs0'', members: [ { _id: 0, host: ''localhost:27017'' } ]})\" && s=$$? && break || s=$$?; echo \"Tried $$i times. Waiting 5 secs...\"; sleep 5; done; (exit $$s)"'
# networks:
# - name: saltbox
# comparisons:
# '*': ignore
# auto_remove: yes
# state: started
# pull: true

- name: Create Docker container
ansible.builtin.include_tasks: "{{ resources_tasks_path }}/docker/create_docker_container.yml"

0 comments on commit 5bfacc9

Please sign in to comment.