summaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/database/tasks
diff options
context:
space:
mode:
authorgrakiss <grakiss.wanglei@huawei.com>2016-02-15 22:14:45 -0500
committergrakiss <grakiss.wanglei@huawei.com>2016-02-24 01:54:19 -0500
commite72bc045fd467a442a0ffb1c78e710a270a59dfa (patch)
treede36cb10caf65af125d3815733c92abd561d8866 /deploy/adapters/ansible/roles/database/tasks
parent00ba12cbc900cb1cb38bee938544cc95583ab416 (diff)
Support version Liberty of OpenStack for CENTOS7
JIRA:COMPASS-315 -Support version Liberty of OpenStack for CENTOS7 Change-Id: I81abbb37a295a0ea733398ad1f278bafc3525d87 Signed-off-by: grakiss <grakiss.wanglei@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_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}}