forked from RocketChat/Rocket.Chat.Ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MongoDB installation Updates (see below):
- Explicitly define the mongodb upstart init conf path - Mongodb repo updates for 3.4 - Allow tuning of mongodb service name - New vars: - `rocket_chat_mongodb_service_name`: mongod (string) - `rocket_chat_mongodb_org_pkgs`: false (bool) - `rocket_chat_mongodb_org_version`: 3.4 (string) - Implement suggestions from RocketChat#40 RocketChat#50 - Allow fine-grained tuning of `MONGO_URL` inside service files - Configure `rocket_chat_mongodb_URI` with jinja2 logic - New vars: - `rocket_chat_mongodb_user`: ~ (string) - `rocket_chat_mongodb_password`: ~ (string) - `rocket_chat_mongodb_database`: rocketchat (string) - `rocket_chat_mongodb_use_tls`: false (bool) - `rocket_chat_mongodb_URI`: computed result - Move replSet task into mongodb.yml - Change idempotency of replSet command - Now actually check on the JSON output of the - Add MongoDB.org offical package install task for RHEL - Vaariabilize `rocket_chat_mongodb_config` for debian packages - Set the variable explicitly in the org packages task to match the official location - Fixes: RocketChat#40 RocketChat#50 RocketChat#54 RocketChat#71 Mongodb changes from @photoninger (Thanks also for RocketChat#71 as a reference!) - Add mongodb_service_name to README - Variablize mongodb log to match service name Fixes: RocketChat#71
- Loading branch information
Showing
17 changed files
with
177 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,99 @@ | ||
--- | ||
# tasks/mongodb.yml: MongoDB configuration for RocketChat.Ansible | ||
- name: Install Official MongoDB.org packages | ||
block: | ||
|
||
- name: Ensure the MongoDB repository key has been imported | ||
apt_key: | ||
keyserver: "{{ rocket_chat_mongodb_keyserver }}" | ||
id: "{{ rocket_chat_mongodb_gpg_key }}" | ||
when: ansible_os_family == "Debian" | ||
tags: repo | ||
|
||
- name: Ensure the MongoDB repository is present | ||
apt_repository: | ||
repo: "{{ rocket_chat_mongodb_apt_repo }}" | ||
state: present | ||
when: ansible_os_family == "Debian" | ||
tags: repo | ||
|
||
- name: Ensure MongoDB Server is present | ||
- name: Set official package names | ||
set_fact: | ||
rocket_chat_mongodb_packages: | ||
- mongodb-org | ||
- mongodb-org-server | ||
rocket_chat_mongodb_config: /etc/mongod.conf | ||
|
||
- name: Debian/Ubuntu MongoDB.org official pkgs tasks | ||
block: | ||
|
||
- name: Ensure the MongoDB repository key has been imported [Debian] | ||
apt_key: | ||
keyserver: "{{ rocket_chat_mongodb_keyserver }}" | ||
id: "{{ rocket_chat_mongodb_gpg_key }}" | ||
tags: repo | ||
|
||
- name: Ensure the MongoDB repository is present [Debian] | ||
apt_repository: | ||
repo: "{{ rocket_chat_mongodb_apt_repo }}" | ||
state: present | ||
tags: repo | ||
register: rocket_chat_mongodb_repo_state | ||
|
||
when: | ||
- rocket_chat_mongodb_apt_repo is defined | ||
- (ansible_os_family | lower) == "debian" | ||
|
||
- name: RHEL-based MongoDB.org official pkgs tasks | ||
block: | ||
|
||
- name: Ensure the MongoDB repository key has been imported [RHEL] | ||
rpm_key: | ||
key: "{{ rocket_chat_mongodb_rpm_repo.pgp_key }}" | ||
state: present | ||
tags: repo | ||
|
||
- name: Ensure the MongoDB repository is present [RHEL] | ||
yum_repository: | ||
name: "{{ rocket_chat_mongodb_rpm_repo.name }}" | ||
baseurl: "{{ rocket_chat_mongodb_rpm_repo.baseurl }}" | ||
state: present | ||
description: "{{ rocket_chat_mongodb_rpm_repo.desc }}" | ||
gpgcheck: "{{ rocket_chat_mongodb_rpm_repo.gpgcheck }}" | ||
gpgkey: "{{ rocket_chat_mongodb_rpm_repo.pgp_key }}" | ||
tags: repo | ||
register: rocket_chat_mongodb_repo_state | ||
|
||
when: | ||
- rocket_chat_mongodb_rpm_repo is defined | ||
- (ansible_os_family | lower) = "redhat" | ||
|
||
when: | ||
- rocket_chat_mongodb_org_pkgs | ||
|
||
- name: Ensure MongoDB Server is installed | ||
package: | ||
name: "{{ rocket_chat_mongodb_packages }}" | ||
state: present | ||
state: "{{ (rocket_chat_mongodb_repo_state | changed) | ternary('latest','present') }}" | ||
|
||
- name: Deploy MongoDB service configuration | ||
template: | ||
src: "{{ rocket_chat_mongodb_config_template }}" | ||
dest: /etc/mongod.conf | ||
dest: "{{ rocket_chat_mongodb_config }}" | ||
notify: Restart the MongoDB service | ||
|
||
- meta: flush_handlers | ||
|
||
- name: Ensure the MongoDB service is started/enabled | ||
service: | ||
name: mongod | ||
name: "{{ rocket_chat_mongodb_service_name }}" | ||
state: started | ||
enabled: yes | ||
|
||
- name: Wait for MongoDB to come online | ||
wait_for: | ||
port: "{{ rocket_chat_mongodb_port }}" | ||
host: "{{ rocket_chat_mongodb_server }}" | ||
state: started | ||
|
||
- name: Ensure the MongoDB replSets have been initiated | ||
shell: >- | ||
mongo --quiet --eval | ||
'rs.initiate({_id:"{{ rocket_chat_mongodb_repl_setname }}", | ||
members: [{"_id":1, "host": | ||
"{{ rocket_chat_mongodb_server }}:{{ rocket_chat_mongodb_port }}"}]})' | ||
become: yes | ||
become_user: mongodb | ||
args: | ||
executable: /bin/bash | ||
register: replSet_result | ||
changed_when: | ||
- not (replSet_result.stdout | search(' Object')) | ||
- ('ok' in (replSet_result.stdout | from_json)) | ||
- (((replSet_result.stdout | from_json).ok | int) == 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1 @@ | ||
--- | ||
rocket_chat_service_update_command: systemctl daemon-reload | ||
rocket_chat_service_template: | ||
src: rocketchat.service.j2 | ||
dest: /etc/systemd/system/rocketchat.service | ||
|
||
rocket_chat_mongodb_apt_repo: "deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.2 main" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
rocket_chat_mongodb_service_name: mongodb | ||
rocket_chat_mongodb_org_pkgs: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1 @@ | ||
--- | ||
rocket_chat_service_update_command: systemctl daemon-reload | ||
rocket_chat_service_template: | ||
src: rocketchat.service.j2 | ||
dest: /etc/systemd/system/rocketchat.service | ||
|
||
rocket_chat_mongodb_apt_repo: "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | ||
rocket_chat_mongodb_gpg_key: EA312927 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
rocket_chat_mongodb_org_pkgs: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
# rocket_chat_mongodb_repl_result_obj: "\ | ||
# {{ replSet_result['stdout_lines'][\ | ||
# ((replSet_result['stdout_lines'].index('{'))|int):\ | ||
# ((replSet_result['stdout_lines'].index('}'))|int)+1]\ | ||
# | join | from_json }}" | ||
|
||
rocket_chat_mongodb_URI: "\ | ||
{% set temp_out = | ||
rocket_chat_mongodb_server ~ ':' ~ rocket_chat_mongodb_port -%} | ||
{% if rocket_chat_mongodb_user and rocket_chat_mongodb_password -%} | ||
{% set temp_out = | ||
rocket_chat_mongodb_user | ||
~ ':' ~ rocket_chat_mongodb_password | ||
~ '@' ~ temp_out -%} | ||
{% endif -%} | ||
{% set temp_out = | ||
temp_out ~ '/' ~ rocket_chat_mongodb_database -%} | ||
{% if (rocket_chat_mongodb_use_tls | bool) == true -%} | ||
{% set temp_out = temp_out ~ '?ssl=true' -%} | ||
{% endif -%} | ||
{{ temp_out }}" |