aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/database/tasks
diff options
context:
space:
mode:
authorshuai chen <chenshuai@huawei.com>2016-02-24 07:41:29 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-02-24 07:41:29 +0000
commite38c1a6d08b10ea81d208bd40b9df1a13d28db8c (patch)
tree44beff459154f239469579882e559c2027649d95 /deploy/adapters/ansible/roles/database/tasks
parent3eab3cd722870e6c02ee1337d3536dc68f89b13e (diff)
parente72bc045fd467a442a0ffb1c78e710a270a59dfa (diff)
Merge "Support version Liberty of OpenStack for CENTOS7"
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_cluster.yml3
-rwxr-xr-xdeploy/adapters/ansible/roles/database/tasks/mariadb_cluster_redhat.yml37
-rw-r--r--deploy/adapters/ansible/roles/database/tasks/mariadb_config.yml12
-rw-r--r--deploy/adapters/ansible/roles/database/tasks/mariadb_install.yml4
-rwxr-xr-xdeploy/adapters/ansible/roles/database/tasks/mongodb_install.yml5
6 files changed, 63 insertions, 5 deletions
diff --git a/deploy/adapters/ansible/roles/database/tasks/main.yml b/deploy/adapters/ansible/roles/database/tasks/main.yml
index 1918f06a..124b2639 100644
--- a/deploy/adapters/ansible/roles/database/tasks/main.yml
+++ b/deploy/adapters/ansible/roles/database/tasks/main.yml
@@ -8,6 +8,8 @@
##############################################################################
---
- include_vars: "{{ ansible_os_family }}.yml"
+ tags:
+ - test_mongo
- include: mariadb_install.yml
- include: mariadb_cluster.yml
@@ -17,8 +19,13 @@
- inventory_hostname == haproxy_hosts.keys()[0]
- include: mongodb_install.yml
+ tags:
+ - test_mongo
+
- include: mongodb_config.yml
when:
- inventory_hostname == haproxy_hosts.keys()[0]
+ tags:
+ - test_mongo
- meta: flush_handlers
diff --git a/deploy/adapters/ansible/roles/database/tasks/mariadb_cluster.yml b/deploy/adapters/ansible/roles/database/tasks/mariadb_cluster.yml
index 16bbabce..84704fa4 100644
--- a/deploy/adapters/ansible/roles/database/tasks/mariadb_cluster.yml
+++ b/deploy/adapters/ansible/roles/database/tasks/mariadb_cluster.yml
@@ -9,3 +9,6 @@
---
- include: mariadb_cluster_debian.yml
when: ansible_os_family == "Debian"
+
+- include: mariadb_cluster_redhat.yml
+ when: ansible_os_family == "RedHat"
diff --git a/deploy/adapters/ansible/roles/database/tasks/mariadb_cluster_redhat.yml b/deploy/adapters/ansible/roles/database/tasks/mariadb_cluster_redhat.yml
new file mode 100755
index 00000000..2fbde33b
--- /dev/null
+++ b/deploy/adapters/ansible/roles/database/tasks/mariadb_cluster_redhat.yml
@@ -0,0 +1,37 @@
+##############################################################################
+# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+---
+- name: start first node to create new cluster
+ shell: service mysql start --wsrep-new-cluster
+ when:
+ - inventory_hostname == haproxy_hosts.keys()[0]
+
+- name: wait for cluster ready
+ command: mysql -e"show status like 'wsrep%'"
+ register: cluster_status
+ until: cluster_status|success
+ failed_when: not cluster_status.stdout | search("ON")
+ retries: 10
+ delay: 3
+ when:
+ - inventory_hostname == haproxy_hosts.keys()[0]
+
+- name: restart other nodes and join cluster
+ service:
+ name: mysql
+ state: restarted
+ enabled: yes
+ when:
+ - inventory_hostname != haproxy_hosts.keys()[0]
+
+- name: restart first nodes
+ service:
+ name: mysql
+ state: restarted
+ when: inventory_hostname == haproxy_hosts.keys()[0] and haproxy_hosts|length > 1
diff --git a/deploy/adapters/ansible/roles/database/tasks/mariadb_config.yml b/deploy/adapters/ansible/roles/database/tasks/mariadb_config.yml
index d4ef6dd1..f9811dfa 100644
--- a/deploy/adapters/ansible/roles/database/tasks/mariadb_config.yml
+++ b/deploy/adapters/ansible/roles/database/tasks/mariadb_config.yml
@@ -8,11 +8,14 @@
##############################################################################
---
- name: create all needed db
- mysql_db: name={{ item.db }} state=present
+ mysql_db: login_unix_socket=/var/run/mysqld/mysqld.sock name={{ item.db }} state=present
with_items: "{{ credentials }}"
+ tags:
+ - test_db
- name: create service db user
mysql_user:
+ login_unix_socket=/var/run/mysqld/mysqld.sock
name={{ item[0].user }}
password={{ item[0].password }}
priv=*.*:ALL,GRANT
@@ -20,13 +23,16 @@
state=present
with_nested:
- "{{ credentials }}"
- - ['%', 'localhost', inventory_hostname]
+ - ['%', 'localhost', '{{ inventory_hostname }}']
+ tags:
+ - test_user
- name: create wsrep db user
mysql_user:
+ login_unix_socket=/var/run/mysqld/mysqld.sock
name={{ WSREP_SST_USER }}
password={{ WSREP_SST_PASS }}
priv=*.*:ALL,GRANT
host={{ item }}
state=present
- with_items: ['%', 'localhost', inventory_hostname]
+ with_items: ['%', 'localhost', '{{ inventory_hostname }}']
diff --git a/deploy/adapters/ansible/roles/database/tasks/mariadb_install.yml b/deploy/adapters/ansible/roles/database/tasks/mariadb_install.yml
index 62257810..14fe1634 100644
--- a/deploy/adapters/ansible/roles/database/tasks/mariadb_install.yml
+++ b/deploy/adapters/ansible/roles/database/tasks/mariadb_install.yml
@@ -24,6 +24,10 @@
dest: "/etc/security/limits.conf"
mode: 0755
+- name: create conf dir for wsrep
+ file: path=/etc/my.cnf.d state=directory mode=0755
+ when: ansible_os_family == "RedHat"
+
- name: update mariadb config file
template:
src: '{{ item.src }}'
diff --git a/deploy/adapters/ansible/roles/database/tasks/mongodb_install.yml b/deploy/adapters/ansible/roles/database/tasks/mongodb_install.yml
index 4eb91560..dea15a83 100755
--- a/deploy/adapters/ansible/roles/database/tasks/mongodb_install.yml
+++ b/deploy/adapters/ansible/roles/database/tasks/mongodb_install.yml
@@ -19,17 +19,18 @@
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
+ shell: crudini --merge {{ mongodb_config.dest }} < /opt/os_templates/mongodb.conf
- name: rm prealloc files
file:
dest: "{{ item }}"
state: absent
with_fileglob:
- - /var/lib/mongodb/journal/*
+ - "{{ mongodb_config.journal }}"
- name: manually restart mongodb server
service: name={{ mongodb_service }} state=restarted enabled=yes
+ ignore_errors: true
- name: write mongodb to monitor list
lineinfile: dest=/opt/service create=yes line={{ mongodb_service}}