summaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/database/tasks
diff options
context:
space:
mode:
authorcarey.xu <carey.xuhan@huawei.com>2015-09-30 11:26:46 +0800
committercarey.xu <carey.xuhan@huawei.com>2015-10-09 15:03:51 +0800
commit00aaaac786bcec0d2de7c14c4f3c5a89ba2553f5 (patch)
tree05b45bee93c88f363cb78d79f9dac26cdf12afe6 /deploy/adapters/ansible/roles/database/tasks
parent9a95593b0c8cdefb6ad4a3c836b699f42b1f7323 (diff)
compass4nfv support ceilometer
JIRA: COMPASS-53 Change-Id: Ie8fc0f3f03f1de3c9fcf37778e025175ed391bc5 Signed-off-by: carey.xu <carey.xuhan@huawei.com>
Diffstat (limited to 'deploy/adapters/ansible/roles/database/tasks')
-rw-r--r--deploy/adapters/ansible/roles/database/tasks/main.yml7
-rw-r--r--deploy/adapters/ansible/roles/database/tasks/mariadb.yml60
-rw-r--r--deploy/adapters/ansible/roles/database/tasks/mongodb.yml32
3 files changed, 78 insertions, 21 deletions
diff --git a/deploy/adapters/ansible/roles/database/tasks/main.yml b/deploy/adapters/ansible/roles/database/tasks/main.yml
index 71916751..ad5c5b71 100644
--- a/deploy/adapters/ansible/roles/database/tasks/main.yml
+++ b/deploy/adapters/ansible/roles/database/tasks/main.yml
@@ -1,14 +1,11 @@
---
- include_vars: "{{ ansible_os_family }}.yml"
-- name: copy data.sh
- template: src=data.j2 dest=/opt/data.sh mode=777
- tags:
- - mysql_user
-
- include: mysql.yml
when: haproxy_hosts is not defined
- include: mariadb.yml
when: haproxy_hosts is defined
+- include: mongodb.yml
+
diff --git a/deploy/adapters/ansible/roles/database/tasks/mariadb.yml b/deploy/adapters/ansible/roles/database/tasks/mariadb.yml
index 3626777b..37c9a2c9 100644
--- a/deploy/adapters/ansible/roles/database/tasks/mariadb.yml
+++ b/deploy/adapters/ansible/roles/database/tasks/mariadb.yml
@@ -24,32 +24,60 @@
- name: update wsrep_sst_rsync gid
lineinfile: dest=/usr/bin/wsrep_sst_rsync state=absent regexp="\s*gid = \$MYGID$" backup=yes
+- stat: path=/opt/mysql_init_complete
+ register: mysql_init_complete
+
- name: restart first mysql server
shell: service mysql restart --wsrep-cluster-address="gcomm://"
- when: inventory_hostname == haproxy_hosts.keys()[0]
- register: result
- until: result|success
- retries: 5
- delay: 5
+ args:
+ creates: /opt/mysql_init_complete
+ when: inventory_hostname == haproxy_hosts.keys()[0] and mysql_init_complete.stat.exists == False
tags:
- mysql_restart
+ #register: result
+ #until: result|success
+ #retries: 5
+ #delay: 5
- name: restart other mysql server
- service: name=mysql state=restarted enabled=yes
- when: inventory_hostname != haproxy_hosts.keys()[0]
- register: result
- until: result|success
- retries: 5
- delay: 5
+ shell: service mysql restart
+ args:
+ creates: /opt/mysql_init_complete
tags:
- mysql_restart
+ when: inventory_hostname != haproxy_hosts.keys()[0] and mysql_init_complete.stat.exists == False
+ #register: result
+ #until: result|success
+ #retries: 5
+ #delay: 5
- name: generate mysql service list
shell: echo {{ item }} >> /opt/service
with_items: services_noarch
-- name: create database/user
- shell: /opt/data.sh
- run_once: True
- tags:
- - mysql_user
+- name: create all needed db
+ run_once: yes
+ mysql_db: name={{ item.db }} state=present
+ with_items: "{{ credentials }}"
+
+- name: create service db user
+ run_once: yes
+ mysql_user:
+ name={{ item[0].user }}
+ password={{ item[0].password }}
+ priv=*.*:ALL,GRANT
+ host={{ item[1] }}
+ state=present
+ with_nested:
+ - "{{ credentials }}"
+ - ['%', 'localhost', inventory_hostname]
+
+- name: create wsrep db user
+ run_once: yes
+ mysql_user:
+ name={{ WSREP_SST_USER }}
+ password={{ WSREP_SST_PASS }}
+ priv=*.*:ALL,GRANT
+ host={{ item }}
+ state=present
+ with_items: ['%', 'localhost', inventory_hostname]
diff --git a/deploy/adapters/ansible/roles/database/tasks/mongodb.yml b/deploy/adapters/ansible/roles/database/tasks/mongodb.yml
new file mode 100644
index 00000000..a0edcce8
--- /dev/null
+++ b/deploy/adapters/ansible/roles/database/tasks/mongodb.yml
@@ -0,0 +1,32 @@
+---
+- name: install mongodb packages
+ action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
+ with_items: mongodb_packages | union(packages_noarch)
+
+- name: copy ceilometer configs
+ template: src=mongodb.conf dest=/opt/os_templates backup=yes
+
+- name: update mongodb config file
+ shell: crudini --merge /etc/mongodb.conf < /opt/os_templates/mongodb.conf
+
+- name: rm prealloc files
+ file:
+ dest: "{{ item }}"
+ state: absent
+ with_fileglob:
+ - /var/lib/mongodb/journal/*
+
+- name: manually restart mongodb server
+ service: name=mongodb state=restarted
+
+- wait_for: port=27017 delay=3 timeout=10 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