summaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible
diff options
context:
space:
mode:
authorcarey.xu <carey.xuhan@huawei.com>2015-12-17 18:16:12 +0800
committercarey.xu <carey.xuhan@huawei.com>2015-12-25 13:18:21 +0800
commitbb31ed2d10f1876a50353abb258c2a5be13e2da2 (patch)
tree7e716df5ccc99bb19b624ff41ffd77cc0e60fb10 /deploy/adapters/ansible
parent21e1b393c0fc7f52c831882b53454877f6942495 (diff)
deploy mongodb as cluster for HA
JIRA: COMPASS-207 Change-Id: I1069bcc2d0dd97dd6a4c7bb61351be993d86b33a Signed-off-by: carey.xu <carey.xuhan@huawei.com>
Diffstat (limited to 'deploy/adapters/ansible')
-rw-r--r--deploy/adapters/ansible/roles/common/tasks/main.yml9
-rw-r--r--deploy/adapters/ansible/roles/database/tasks/main.yml5
-rwxr-xr-xdeploy/adapters/ansible/roles/database/tasks/mongodb_config.yml35
-rwxr-xr-x[-rw-r--r--]deploy/adapters/ansible/roles/database/tasks/mongodb_install.yml (renamed from deploy/adapters/ansible/roles/database/tasks/mongodb.yml)13
-rw-r--r--deploy/adapters/ansible/roles/database/templates/mongodb.conf3
-rw-r--r--deploy/adapters/ansible/roles/database/templates/replica.js8
-rw-r--r--deploy/adapters/ansible/roles/glance/tasks/nfs.yml6
-rw-r--r--deploy/adapters/ansible/roles/glance/vars/Debian.yml1
-rw-r--r--deploy/adapters/ansible/roles/keystone/vars/main.yml6
9 files changed, 69 insertions, 17 deletions
diff --git a/deploy/adapters/ansible/roles/common/tasks/main.yml b/deploy/adapters/ansible/roles/common/tasks/main.yml
index da114631..1276429d 100644
--- a/deploy/adapters/ansible/roles/common/tasks/main.yml
+++ b/deploy/adapters/ansible/roles/common/tasks/main.yml
@@ -54,6 +54,11 @@
shell: hwclock --systohc
ignore_errors: True
+- name: create fireball keys dir
+ file: path=~/.fireball.keys state=directory mode=0700
+ delegate_to: 127.0.0.1
+ run_once: true
+
- name: restart services
service: name={{ item }} state=restarted enabled=yes
with_items: services| union(services_noarch)
@@ -61,3 +66,7 @@
- name: write services to monitor list
lineinfile: dest=/opt/service create=yes line='{{ item }}'
with_items: services| union(services_noarch)
+
+- name: kill daemon for accelerate
+ shell: lsof -ni :5099|grep LISTEN|awk '{print $2}'|xargs kill -9
+ ignore_errors: true
diff --git a/deploy/adapters/ansible/roles/database/tasks/main.yml b/deploy/adapters/ansible/roles/database/tasks/main.yml
index 20b6fe4b..bfdcb75b 100644
--- a/deploy/adapters/ansible/roles/database/tasks/main.yml
+++ b/deploy/adapters/ansible/roles/database/tasks/main.yml
@@ -9,4 +9,7 @@
when:
- inventory_hostname == haproxy_hosts.keys()[0]
-- include: mongodb.yml
+- include: mongodb_install.yml
+- include: mongodb_config.yml
+ when:
+ - inventory_hostname == haproxy_hosts.keys()[0]
diff --git a/deploy/adapters/ansible/roles/database/tasks/mongodb_config.yml b/deploy/adapters/ansible/roles/database/tasks/mongodb_config.yml
new file mode 100755
index 00000000..573b30a9
--- /dev/null
+++ b/deploy/adapters/ansible/roles/database/tasks/mongodb_config.yml
@@ -0,0 +1,35 @@
+---
+- name: copy replica js
+ template:
+ src: replica.js
+ dest: /opt/replica.js
+
+- name: init replica servers
+ shell: mongo compass /opt/replica.js
+
+- name: wait replica servers are ready
+ shell: mongo compass --eval 'printjson(rs.status())'|grep -E 'PRIMARY|SECONDARY'|wc -l
+ register: servers
+ until: servers.stdout|int == 3
+ retries: 20
+ delay: 3
+
+- debug: msg='{{ servers.stdout |int }}'
+
+- name: create mongodb user and db
+ mongodb_user:
+ login_host: "{{ internal_vip.ip }}"
+ database: ceilometer
+ name: ceilometer
+ password: "{{ CEILOMETER_DBPASS }}"
+ roles: 'readWrite,dbAdmin'
+ state: present
+
+- name: grant user privilege
+ mongodb_user:
+ login_host: "{{ internal_vip.ip }}"
+ database: ceilometer
+ name: ceilometer
+ password: "{{ CEILOMETER_DBPASS }}"
+ roles: 'readWrite,dbAdmin'
+ state: present
diff --git a/deploy/adapters/ansible/roles/database/tasks/mongodb.yml b/deploy/adapters/ansible/roles/database/tasks/mongodb_install.yml
index ada7f7ef..1e7988d2 100644..100755
--- a/deploy/adapters/ansible/roles/database/tasks/mongodb.yml
+++ b/deploy/adapters/ansible/roles/database/tasks/mongodb_install.yml
@@ -26,14 +26,5 @@
- name: write mongodb to monitor list
lineinfile: dest=/opt/service create=yes line={{ mongodb_service}}
-- wait_for: port=27017 delay=3 timeout=60 host={{ internal_vip.ip }}
-
-- name: create mongodb user
- run_once: True
- mongodb_user:
- login_host: "{{ internal_vip.ip }}"
- database: ceilometer
- name: ceilometer
- password: "{{ CEILOMETER_DBPASS }}"
- roles: 'readWrite,dbAdmin'
- state: present
+- name: wait for mongod ready
+ wait_for: host=0.0.0.0 port=27017 delay=10
diff --git a/deploy/adapters/ansible/roles/database/templates/mongodb.conf b/deploy/adapters/ansible/roles/database/templates/mongodb.conf
index 68b84d7a..18306154 100644
--- a/deploy/adapters/ansible/roles/database/templates/mongodb.conf
+++ b/deploy/adapters/ansible/roles/database/templates/mongodb.conf
@@ -1,4 +1,5 @@
# mongodb.conf
-bind_ip = {{ internal_vip.ip }}
+bind_ip = 0.0.0.0
+replSet = compass
port = 27017
smallfiles = true
diff --git a/deploy/adapters/ansible/roles/database/templates/replica.js b/deploy/adapters/ansible/roles/database/templates/replica.js
new file mode 100644
index 00000000..3282cd6a
--- /dev/null
+++ b/deploy/adapters/ansible/roles/database/templates/replica.js
@@ -0,0 +1,8 @@
+config = { _id:"compass", members:[
+{% for host in haproxy_hosts.values() %}
+{% set pair = '%s:27017' % host %}
+ {_id:{{ loop.index0 }},host:"{{ pair }}"},
+{% endfor %}
+]
+};
+rs.initiate(config);
diff --git a/deploy/adapters/ansible/roles/glance/tasks/nfs.yml b/deploy/adapters/ansible/roles/glance/tasks/nfs.yml
index ff72ecb7..758ec082 100644
--- a/deploy/adapters/ansible/roles/glance/tasks/nfs.yml
+++ b/deploy/adapters/ansible/roles/glance/tasks/nfs.yml
@@ -10,9 +10,13 @@
local_action: file path=/opt/images state=directory mode=0777
run_once: True
+- name: remove nfs config item if exist
+ local_action: lineinfile dest=/etc/exports state=absent
+ regexp="^/opt/images"
+ run_once: True
+
- name: update nfs config
local_action: lineinfile dest=/etc/exports state=present
- regexp="/opt/images *(rw,insecure,sync,all_squash)"
line="/opt/images *(rw,insecure,sync,all_squash)"
run_once: True
diff --git a/deploy/adapters/ansible/roles/glance/vars/Debian.yml b/deploy/adapters/ansible/roles/glance/vars/Debian.yml
index e7fe2da7..5cee8f90 100644
--- a/deploy/adapters/ansible/roles/glance/vars/Debian.yml
+++ b/deploy/adapters/ansible/roles/glance/vars/Debian.yml
@@ -1,6 +1,7 @@
---
packages:
- glance
+ - nfs-common
nfs_services: []
diff --git a/deploy/adapters/ansible/roles/keystone/vars/main.yml b/deploy/adapters/ansible/roles/keystone/vars/main.yml
index d743b4ee..dc660e97 100644
--- a/deploy/adapters/ansible/roles/keystone/vars/main.yml
+++ b/deploy/adapters/ansible/roles/keystone/vars/main.yml
@@ -40,9 +40,9 @@ os_services:
type: metering
region: regionOne
description: "OpenStack Telemetry"
- publicurl: "http://{{ public_vip.ip }}:8777/v2.0"
- internalurl: "http://{{ internal_vip.ip }}:8777/v2.0"
- adminurl: "http://{{ internal_vip.ip }}:8777/v2.0"
+ publicurl: "http://{{ public_vip.ip }}:8777"
+ internalurl: "http://{{ internal_vip.ip }}:8777"
+ adminurl: "http://{{ internal_vip.ip }}:8777"
- name: cinder
type: volume