Skip to content
Snippets Groups Projects
Commit ea747d7c authored by Jenkins's avatar Jenkins Committed by Gerrit Code Review
Browse files

Merge "Implement mongodb replication set cluster"

parents 6e6894fc 066173be
No related branches found
No related tags found
No related merge requests found
......@@ -7,9 +7,7 @@ project_name: "ceilometer"
####################
ceilometer_database_name: "ceilometer"
ceilometer_database_user: "ceilometer"
# TODO(HuiKang): Update this so that connection to mongodb could be through
# haproxy; haproxy conf needs configurations for mongodb.
ceilometer_database_address: "{{ hostvars[groups['mongodb'][0]]['ansible_' + hostvars[groups['mongodb'][0]]['api_interface']]['ipv4']['address'] }}"
ceilometer_database_address: "{% for host in groups['mongodb'] %}{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ mongodb_port }}{% if not loop.last %},{% endif %}{% endfor %}"
####################
......
......@@ -9,6 +9,9 @@ mongodb_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_
mongodb_tag: "{{ openstack_release }}"
mongodb_image_full: "{{ mongodb_image }}:{{ mongodb_tag }}"
####################
# Mongodb
####################
mongodb_replication_set_name: "rs0"
---
- name: Copying the mongodb replication set bootstrap script
template: src=bootstrap_cluster.js.j2 dest=/tmp/mongodb_bootstrap_replication_set.js
delegate_to: "{{ groups['mongodb'][0] }}"
run_once: True
- name: Bootstraping the mongodb replication set
command: "docker exec -t mongodb mongo {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }} --quiet --eval '{{ lookup('file','/tmp/mongodb_bootstrap_replication_set.js') }}'"
register: bootstrap_mongodb_cluster
failed_when: "{{ (bootstrap_mongodb_cluster.stdout|from_json).ok != 1 }}"
delegate_to: "{{ groups['mongodb'][0] }}"
run_once: True
- name: Deleting the mongodb replication set bootstrap script
file: path=/tmp/mongodb_bootstrap_replication_set.js state=absent
changed_when: false
failed_when: false
delegate_to: "{{ groups['mongodb'][0] }}"
run_once: True
......@@ -11,3 +11,16 @@
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
- "mongodb:/var/lib/mongodb"
- name: Waiting for the mongodb startup
wait_for: host={{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }} port={{ mongodb_port }}
- name: Checking current replication status
command: "docker exec -t mongodb mongo {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }} --quiet --eval rs.status().ok"
register: mongodb_replication_status
changed_when: false
delegate_to: "{{ groups['mongodb'][0] }}"
run_once: True
- include: "bootstrap_cluster.yml"
when: mongodb_replication_status.stdout != "1"
printjson(rs.initiate(
{
"_id" : "{{ mongodb_replication_set_name }}",
"version" : 1,
"members" : [
{% for host in groups["mongodb"] %}
{
"_id" : {{ loop.index }},
"host" : "{{ hostvars[host]['ansible_' + storage_interface]['ipv4']['address'] }}:{{ mongodb_port }}"
}{% if not loop.last %},{% endif %}
{% endfor %}
]
}
))
# mongodb.conf
systemLog:
destination: file
logAppend: true
path: /var/log/kolla/mongodb/mongodb.log
# Where to store the data.
dbpath = /var/lib/mongodb
storage:
dbPath: /var/lib/mongodb
# Enable journaling, http://www.mongodb.org/display/DOCS/Journaling
journal:
enabled: true
# where to log
logpath = /var/log/kolla/mongodb/mongodb.log
net:
bindIp: {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}
port: {{ mongodb_port }}
logappend = true
bind_ip = {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}
port = {{ mongodb_port }}
# Enable journaling, http://www.mongodb.org/display/DOCS/Journaling
journal = true
replication:
replSetName: {{ mongodb_replication_set_name }}
---
features:
- Implement MongoDB replicate set cluster
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment