Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mar/databases playbooks #13

Merged
merged 15 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions mongo_4_4.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Manages a mongo cluster.
# To set up a new mongo cluster, make sure you've configured MONGO_RS_CONFIG
# as used by mongo_replica_set in the mongo_4_4 role.
#
# If you are initializing a cluster, your command might look like:
marbonilla marked this conversation as resolved.
Show resolved Hide resolved
# ansible-playbook mongo_4_4.yml -i 203.0.113.11,203.0.113.12,203.0.113.13 -e@/path/to/edx.yml -e@/path/to/ed.yml
# If you just want to deploy an updated replica set config, you can run
# ansible-playbook mongo_4_4.yml -i any-cluster-ip -e@/path/to/edx.yml -e@/path/to/ed.yml --tags configure_replica_set
#
# ADDING A NEW CLUSTER MEMBER
# If you are adding a member to a cluster, you must be sure that the new machine is not first in your inventory
# ansible-playbook mongo_4_4.yml -i 203.0.113.11,203.0.113.12,new-machine-ip -e@/path/to/edx.yml -e@/path/to/ed.yml
# If you are needing more information, please see this link: https://github.com/openedx/configuration/blob/master/playbooks/mongo_4_4.yml

- name: Deploy MongoDB
hosts: mongo_servers
become: True
gather_facts: True
roles:
- role: mongo_4_4
10 changes: 10 additions & 0 deletions mysql_8_0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
# Playbook to provision MySQL

- name: Configure db MySQL instances
hosts: mysql_servers
become: True
gather_facts: True
roles:
# The geerlingguy role does not allow to install a custom MySQL repository, reason why we use a helper role to install MySQL 8.0
- role: mysql_8_0
86 changes: 86 additions & 0 deletions roles/mongo_4_4/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
mongo_logappend: true

#This way, when mongod receives a SIGUSR1, it'll close and reopen its log file handle
mongo_logrotate: reopen

MONGO_VERSION_MAJOR_MINOR: "4.4"
MONGO_VERSION_PATCH: "24"
PYMONGO_VERSION: "4.5.0"
MONGO_VERSION: "{{ MONGO_VERSION_MAJOR_MINOR }}.{{ MONGO_VERSION_PATCH }}"
mongo_port: "27017"
mongo_extra_conf: ''
mongo_key_file: '/etc/mongodb_key'

mongo_data_dir: "{{ COMMON_DATA_DIR }}/mongo"
mongo_log_dir: "{{ COMMON_LOG_DIR }}/mongo"
mongo_journal_dir: "{{ COMMON_DATA_DIR }}/mongo/mongodb/journal"
mongo_user: mongodb

# In Ubuntu 22, 'mongo-org' is not available, so it is necessary to use the MongoDB focal repository to obtain the packages
# We use this information as a reference: https://blog.yucas.net/2023/03/13/install-mongodb-4-4-5-0-over-ubuntu-22-04/
MONGODB_REPO: "deb https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/{{ MONGO_VERSION_MAJOR_MINOR }} multiverse"
jfavellar90 marked this conversation as resolved.
Show resolved Hide resolved

mongodb_debian_pkgs:
- "mongodb-org={{ MONGO_VERSION }}"
- "mongodb-org-server={{ MONGO_VERSION }}"
- "mongodb-org-shell={{ MONGO_VERSION }}"
- "mongodb-org-mongos={{ MONGO_VERSION }}"
- "mongodb-org-tools={{ MONGO_VERSION }}"

marbonilla marked this conversation as resolved.
Show resolved Hide resolved
mongo_configure_replica_set: true

# Vars Meant to be overridden
MONGO_ADMIN_USER: 'admin'
MONGO_ADMIN_PASSWORD: 'password'
MONGO_USERS:
- user: cs_comments_service
password: password
database: cs_comments_service
roles: readWrite
- user: edxapp
password: password
database: edxapp
roles: readWrite

# This default setting is approriate for a single machine installation
# This will need to be overridden for setups where mongo is on its own server
# and/or you are configuring mongo replication. If the override value is
# 0.0.0.0 mongo will listen on all IPs. The value may also be set to a
# specific IP.
MONGO_BIND_IP: '0.0.0.0'

MONGO_REPL_SET: "rs0"
MONGO_AUTH: true

MONGO_CLUSTER_KEY: "CHANGEME"
jfavellar90 marked this conversation as resolved.
Show resolved Hide resolved

# Cluster member configuration
# Fed directly into mongodb_replica_set module
MONGO_RS_CONFIG:
_id: '{{ MONGO_REPL_SET }}'
members:
- host: '127.0.0.1'

# Storage engine options in 3.2: "mmapv1" or "wiredTiger"
# 3.2 and 3.4 default to wiredTiger
MONGO_STORAGE_ENGINE: "wiredTiger"

# List of dictionaries as described in the mount_ebs role's default
# for the volumes.
# Useful if you want to store your mongo data and/or journal on separate
# disks from the root volume. By default, they will end up mongo_data_dir
# on the root disk.
MONGO_VOLUMES: []

# WiredTiger takes a number of optional configuration settings
# which can be defined as a yaml structure in your secure configuration.
MONGO_STORAGE_ENGINE_OPTIONS: !!null

mongo_logpath: "{{ mongo_log_dir }}/mongodb.log"
mongo_dbpath: "{{ mongo_data_dir }}/mongodb"

# In environments that do not require durability (devstack / Jenkins)
# you can disable the journal to reduce disk usage
mongo_enable_journal: true

MONGO_LOG_SERVERSTATUS: true
jfavellar90 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description="Disable Transparent Hugepage before MongoDB boots"
Before=mongod.service

[Service]
Type=oneshot
ExecStart=/bin/bash -c 'echo never > /sys/kernel/mm/transparent_hugepage/enabled'
ExecStart=/bin/bash -c 'echo never > /sys/kernel/mm/transparent_hugepage/defrag'

[Install]
RequiredBy=mongod.service
5 changes: 5 additions & 0 deletions roles/mongo_4_4/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
dependencies:
- common
- role: mount_ebs
volumes: "{{ MONGO_VOLUMES }}"
Loading
Loading