Merge "Add an ansible role for mongodb"

This commit is contained in:
Jenkins 2016-02-02 21:25:19 +00:00 committed by Gerrit Code Review
commit 572e80e6d0
19 changed files with 183 additions and 3 deletions

View File

@ -84,6 +84,9 @@ rabbitmq_management_port: "15672"
rabbitmq_cluster_port: "25672"
rabbitmq_epmd_port: "4369"
mongodb_port: "27017"
mongodb_web_port: "28017"
haproxy_stats_port: "1984"
keystone_public_port: "5000"
@ -178,6 +181,8 @@ enable_ironic: "no"
enable_magnum: "no"
enable_mistral: "no"
enable_elk: "no"
enable_mongodb: "no"
ironic_keystone_user: "ironic"
# Nova fake driver and the number of fake driver per compute node

View File

@ -27,6 +27,9 @@ control
[rabbitmq:children]
control
[mongodb:children]
control
[keystone:children]
control

View File

@ -39,6 +39,9 @@ control
[rabbitmq:children]
control
[mongodb:children]
control
[keystone:children]
control

View File

@ -42,6 +42,14 @@ listen rabbitmq_management
{% endfor %}
{% endif %}
{% if enable_mongodb | bool %}
listen mongodb
bind {{ kolla_internal_address }}:{{ mongodb_port }}
{% for host in groups['mongodb'] %}
server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ mongodb_port }} check inter 2000 rise 2 fall 5
{% endfor %}
{% endif %}
{% if enable_keystone | bool %}
listen keystone_public
bind {{ kolla_internal_address }}:{{ keystone_public_port }}

View File

@ -0,0 +1,15 @@
---
project_name: "mongodb"
####################
# Docker
####################
mongodb_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-mongodb"
mongodb_tag: "{{ openstack_release }}"
mongodb_image_full: "{{ mongodb_image }}:{{ mongodb_tag }}"
####################
# Mongodb
####################

View File

@ -0,0 +1,3 @@
---
dependencies:
- { role: common }

View File

@ -0,0 +1,15 @@
---
- name: Starting mongodb bootstrap container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
detach: False
environment:
KOLLA_BOOTSTRAP:
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
image: "{{ mongodb_image_full }}"
name: "bootstrap_mongodb"
restart_policy: "never"
volumes:
- "{{ node_config_directory }}/mongodb/:{{ container_config_directory }}/:ro"
- "mongodb:/var/lib/mongodb/"

View File

@ -0,0 +1,23 @@
---
- name: Ensuring config directories exist
file:
path: "{{ node_config_directory }}/{{ item }}"
state: "directory"
recurse: yes
with_items:
- "mongodb"
- name: Copying over config.json files for services
template:
src: "{{ item }}.json.j2"
dest: "{{ node_config_directory }}/{{ item }}/config.json"
with_items:
- "mongodb"
- name: Copying over mongodb.conf
template:
src: "{{ item }}.j2"
dest: "{{ node_config_directory }}/mongodb/{{ item }}"
with_items:
- "mongodb.conf"

View File

@ -0,0 +1,9 @@
---
- include: config.yml
when: inventory_hostname in groups['mongodb']
- include: bootstrap.yml
when: inventory_hostname in groups['mongodb']
- include: start.yml
when: inventory_hostname in groups['mongodb']

View File

@ -0,0 +1,2 @@
---
- include: "{{ action }}.yml"

View File

@ -0,0 +1,7 @@
---
- name: Pulling mongodb image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ mongodb_image_full }}"
when: inventory_hostname in groups['mongodb']

View File

@ -0,0 +1,11 @@
---
- name: Starting mongodb container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ mongodb_image_full }}"
name: "mongodb"
privileged: True
volumes:
- "{{ node_config_directory }}/mongodb/:{{ container_config_directory }}/:ro"
- "mongodb:/var/lib/mongodb"

View File

@ -0,0 +1,15 @@
# mongodb.conf
# Where to store the data.
dbpath = /var/lib/mongodb
# where to log
logpath = /var/log/mongodb/mongodb.log
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

View File

@ -0,0 +1,11 @@
{
"command": "/usr/bin/mongod --unixSocketPrefix=/var/run/mongodb --config /etc/mongodb.conf run",
"config_files": [
{
"source": "{{ container_config_directory }}/mongodb.conf",
"dest": "/etc/mongodb.conf",
"owner": "mongodb",
"perm": "0644"
}
]
}

View File

@ -359,6 +359,30 @@
state: stopped
when: inventory_hostname in groups['rabbitmq']
- name: Checking free port for Mongodb
wait_for:
host: "{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}"
port: "{{ mongodb_port }}"
connect_timeout: 1
state: stopped
when: inventory_hostname in groups['mongodb']
- name: Checking free port for Mongodb Web
wait_for:
host: "{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}"
port: "{{ mongodb_web_port }}"
connect_timeout: 1
state: stopped
when: inventory_hostname in groups['mongodb']
- name: Checking free port for Mongodb HAProxy
wait_for:
host: "{{ kolla_internal_address }}"
port: "{{ mongodb_port }}"
connect_timeout: 1
state: stopped
when: inventory_hostname in groups['haproxy']
- name: Checking free port for Rsync
wait_for:
host: "{{ hostvars[inventory_hostname]['ansible_' + storage_interface]['ipv4']['address'] }}"

View File

@ -168,3 +168,10 @@
- { role: mistral,
tags: mistral,
when: enable_mistral | bool }
- hosts:
- mongodb
roles:
- { role: mongodb,
tags: mongodb,
when: enable_mongodb | bool }

View File

@ -15,9 +15,17 @@ RUN apt-get install -y --no-install-recommends mongodb-server \
{% endif %}
RUN mkdir -p /data/db
RUN mkdir -p /var/lib/mongodb /home/mongodb \
&& chown -R mongodb: /var/lib/mongodb /home/mongodb
# TODO(SamYaple): updated mongodb to match the rest of Kolla
#ENTRYPOINT exec /bin/mongod --dbpath /data/db --logpath /var/log/mongodb/mongo.log --noprealloc --smallfiles
COPY mongodb_sudoers /etc/sudoers.d/mongodb_sudoers
COPY extend_start.sh /usr/local/bin/kolla_extend_start
RUN usermod -a -G kolla mongodb \
&& chmod 755 /usr/local/bin/kolla_extend_start \
&& chmod 750 /etc/sudoers.d \
&& chmod 440 /etc/sudoers.d/mongodb_sudoers
{{ include_footer }}
USER mongodb

View File

@ -0,0 +1,10 @@
#!/bin/bash
echo "run extended start"
# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
# of the KOLLA_BOOTSTRAP variable being set, including empty.
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
sudo chown mongodb: /var/lib/mongodb/
exit 0
fi

View File

@ -0,0 +1 @@
%kolla ALL=(root) NOPASSWD: /usr/bin/chown mongodb\: /var/lib/mongodb/, /bin/chown mongodb\: /var/lib/mongodb/