Commit fa684743 by Feanil Patel

Merge pull request #383 from edx/feanil/mongo_rs

Feanil/mongo rs
parents dc073224 48a45aa1
---
- hosts: tag_aws_cloudformation_stack-name_feanilsandbox:&tag_group_edxapp
- hosts: tag_aws_cloudformation_stack-name_feanilsandbox:&tag_role_edxapp
sudo: True
vars_files:
- "{{ secure_dir }}/vars/dev/feanilsandbox.yml"
......@@ -18,7 +18,7 @@
edxapp_lms_env: 'lms.envs.load_test'
edx_platform_commit: 'release'
- splunkforwarder
- hosts: tag_aws_cloudformation_stack-name_feanilsandbox:&tag_group_worker
- hosts: tag_aws_cloudformation_stack-name_feanilsandbox:&tag_role_worker
sudo: True
vars_files:
- "{{ secure_dir }}/vars/dev/feanilsandbox.yml"
......@@ -38,7 +38,7 @@
celery_worker: True
edx_platform_commit: 'release'
- splunkforwarder
- hosts: tag_aws_cloudformation_stack-name_feanilsandbox:&tag_group_xserver
- hosts: tag_aws_cloudformation_stack-name_feanilsandbox:&tag_role_xserver
sudo: True
vars_files:
- "{{ secure_dir }}/vars/dev/feanilsandbox.yml"
......@@ -51,7 +51,7 @@
- xserver
- xserver
- splunkforwarder
- hosts: tag_aws_cloudformation_stack-name_feanilsandbox:&tag_group_rabbitmq
- hosts: tag_aws_cloudformation_stack-name_feanilsandbox:&tag_role_rabbitmq
serial: 1
sudo: True
vars_files:
......@@ -62,7 +62,7 @@
- supervisor
- rabbitmq
- splunkforwarder
- hosts: tag_aws_cloudformation_stack-name_feanilsandbox:&tag_group_xqueue
- hosts: tag_aws_cloudformation_stack-name_feanilsandbox:&tag_role_xqueue
sudo: True
vars_files:
- "{{ secure_dir }}/vars/dev/feanilsandbox.yml"
......@@ -75,3 +75,12 @@
- xqueue
- xqueue
- splunkforwarder
- hosts: tag_aws_cloudformation_stack-name_feanilsandbox:&tag_role_mongo
sudo: True
vars_files:
- "{{ secure_dir }}/vars/dev/feanilsandbox.yml"
- "{{ secure_dir }}/vars/users.yml"
roles:
- common
- role: 'mongo'
mongo_clustered: true
mongo_logappend: true
mongo_version: 2.4.7
mongo_bind_ip: 127.0.0.1
mongo_port: "27017"
mongo_extra_conf: ''
mongo_key_file: '/etc/mongodb_key'
mongo_repl_set: rs0
mongo_cluster_members:
mongo_cluster_members: []
mongo_data_dir: "{{ COMMON_DATA_DIR }}/mongo"
mongo_log_dir: "{{ COMMON_LOG_DIR }}/mongo"
......@@ -19,3 +20,8 @@ MONGO_USERS:
mongo_logpath: "{{ mongo_log_dir }}/mongodb.log"
mongo_dbpath: "{{ mongo_data_dir }}/mongodb"
# If the system is running out of an Amazon Web Services
# cloudformation stack, this group name can used to pull out
# the name of the stack the mongo server resides in.
mongo_aws_stack_name: "tag_aws_cloudformation_stack-name_"
......@@ -9,8 +9,14 @@ logpath={{ mongo_logpath }}
logappend={{ mongo_logappend }}
{# Bind to all ips(default) if in clustered mode,
otherwise only to the specified local ip.
#}
{% if mongo_clustered is not defined %}
bind_ip = {{ mongo_bind_ip }}
#port = 27017
{% endif %}
port = {{ mongo_port }}
# Enable journaling, http://www.mongodb.org/display/DOCS/Journaling
journal=true
......
{# Generate a list of hosts if no cluster members are give. Otherwise use the
hosts provided in the variable.
#}
{%- if mongo_cluster_members|length == 0 -%}
{%- set hosts = [] -%}
{%- set all_mongo_hosts = [] -%}
{%- do all_mongo_hosts.extend(groups.tag_role_mongo) -%}
{%- do all_mongo_hosts.extend(groups.tag_group_mongo) -%}
{%- for name in group_names -%}
{%- if name.startswith(mongo_aws_stack_name) -%}
{%- for host in all_mongo_hosts -%}
{%- if host in groups[name] -%}
{% do hosts.append("ip-" + host.replace('.','-') + ":" + mongo_port) %}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endfor -%}
{%- else -%}
{%- set hosts = mongo_cluster_members -%}
{%- endif -%}
config = {_id: '{{ mongo_repl_set }}', members: [
{% for host in mongo_cluster_members %}
{%- for host in hosts -%}
{_id: {{ loop.index }}, host: '{{ host }}'}{% if not loop.last %},{% endif %}
{% endfor %}
{%- endfor -%}
]};
rs.initiate(config)
......
......@@ -4,9 +4,12 @@
{%- if rabbitmq_clustered_hosts|length == 0 -%}
{%- set hosts= [] -%}
{%- set all_rabbit_hosts = [] -%}
{%- do all_rabbit_hosts.extend(groups.tag_role_rabbitmq) -%}
{%- do all_rabbit_hosts.extend(groups.tag_group_rabbitmq) -%}
{%- for name in group_names -%}
{%- if name.startswith(rabbitmq_aws_stack_name) -%}
{%- for host in groups.tag_group_rabbitmq -%}
{%- for host in all_rabbit_hosts -%}
{%- if host in groups[name] -%}
{% do hosts.append("rabbit@ip-" + host.replace('.','-')) %}
{%- endif -%}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment