aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/database/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'deploy/adapters/ansible/roles/database/tasks')
-rw-r--r--deploy/adapters/ansible/roles/database/tasks/main.yml35
-rw-r--r--deploy/adapters/ansible/roles/database/tasks/mariadb_cluster.yml14
-rw-r--r--deploy/adapters/ansible/roles/database/tasks/mariadb_cluster_debian.yml73
-rw-r--r--deploy/adapters/ansible/roles/database/tasks/mariadb_cluster_redhat.yml71
-rw-r--r--deploy/adapters/ansible/roles/database/tasks/mariadb_config.yml88
-rw-r--r--deploy/adapters/ansible/roles/database/tasks/mariadb_install.yml75
-rwxr-xr-xdeploy/adapters/ansible/roles/database/tasks/mongodb_config.yml70
-rwxr-xr-xdeploy/adapters/ansible/roles/database/tasks/mongodb_install.yml40
8 files changed, 0 insertions, 466 deletions
diff --git a/deploy/adapters/ansible/roles/database/tasks/main.yml b/deploy/adapters/ansible/roles/database/tasks/main.yml
deleted file mode 100644
index f28da23b..00000000
--- a/deploy/adapters/ansible/roles/database/tasks/main.yml
+++ /dev/null
@@ -1,35 +0,0 @@
-##############################################################################
-# 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
-##############################################################################
----
-- include_vars: "{{ ansible_os_family }}.yml"
- tags:
- - test_mongo
- - recovery
-
-- include: mariadb_install.yml
-
-- include: mariadb_cluster.yml
- tags:
- - recovery
-
-- include: mariadb_config.yml
- when:
- - 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
deleted file mode 100644
index 84704fa4..00000000
--- a/deploy/adapters/ansible/roles/database/tasks/mariadb_cluster.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-##############################################################################
-# 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
-##############################################################################
----
-- 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_debian.yml b/deploy/adapters/ansible/roles/database/tasks/mariadb_cluster_debian.yml
deleted file mode 100644
index 9752b550..00000000
--- a/deploy/adapters/ansible/roles/database/tasks/mariadb_cluster_debian.yml
+++ /dev/null
@@ -1,73 +0,0 @@
-##############################################################################
-# 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: get cluster status
- shell: |
- mysql --silent --skip-column-names -e 'SHOW STATUS LIKE "wsrep_evs_state"' \
- | awk '{print $2}'
- register: cluster_status
- when:
- - inventory_hostname == haproxy_hosts.keys()[0]
-
-- name: start first node to create new cluster
- shell: >
- service mysql bootstrap;
- service mysql start;
- when: |
- inventory_hostname == haproxy_hosts.keys()[0]
- and not cluster_status.stdout | search("OPERATIONAL")
-
-- name: wait for cluster ready
- shell: |
- mysql --silent --skip-column-names -e 'SHOW STATUS LIKE "wsrep_evs_state"' \
- | awk '{print $2}'
- register: cluster_status
- until: cluster_status|success
- failed_when: not cluster_status.stdout | search("OPERATIONAL")
- retries: 10
- delay: 3
- when: |
- inventory_hostname == haproxy_hosts.keys()[0]
- and not cluster_status.stdout | search("OPERATIONAL")
-
-- name: if I in the cluster nodes
- shell: |
- mysql --silent --skip-column-names \
- -e 'SHOW STATUS LIKE "wsrep_incoming_addresses"' | awk '{print $2}'
- register: cluster_nodes
- changed_when: false
-
-- name: restart other nodes and join cluster1
- shell: service mysql restart;
- when: |
- inventory_hostname != haproxy_hosts.keys()[0]
- and not cluster_nodes.stdout | search( "{{ internal_ip }}" )
- ignore_errors: "True"
-
-- name: delay 60 seconds
- shell: sleep 60
-
-- name: restart other nodes and join cluster2
- shell: service mysql restart;
- when: |
- inventory_hostname != haproxy_hosts.keys()[0]
- and not cluster_nodes.stdout | search( "{{ internal_ip }}" )
-
-- name: chmod directory
- shell: >
- chmod 755 -R /var/lib/mysql/;
- chmod 755 -R /var/log/mysql/;
- chmod 755 -R /etc/mysql/conf.d/;
-
-- name: restart first nodes
- shell: service mysql restart
- when: |
- (inventory_hostname == haproxy_hosts.keys()[0]
- and haproxy_hosts|length > 1
- and not cluster_nodes.stdout | search( '{{ internal_ip }}' ))
diff --git a/deploy/adapters/ansible/roles/database/tasks/mariadb_cluster_redhat.yml b/deploy/adapters/ansible/roles/database/tasks/mariadb_cluster_redhat.yml
deleted file mode 100644
index 77b18702..00000000
--- a/deploy/adapters/ansible/roles/database/tasks/mariadb_cluster_redhat.yml
+++ /dev/null
@@ -1,71 +0,0 @@
-##############################################################################
-# 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: Register RECOVERY
- set_fact: RECOVERY_ENV={{RECOVERY_ENV | default('False')}}
-
-- name: killall mysqld processes
- shell: sudo killall -9 mysqld
- when: RECOVERY_ENV
- ignore_errors: "True"
-
-- name: get cluster status
- shell: |
- mysql --silent --skip-column-names -e 'SHOW STATUS LIKE "wsrep_evs_state"' \
- | awk '{print $2}'
- register: cluster_status
- when:
- - inventory_hostname == haproxy_hosts.keys()[0]
-
-- name: start first node to create new cluster
- shell: service mysql start --wsrep-new-cluster
- when: |
- inventory_hostname == haproxy_hosts.keys()[0]
- and not cluster_status.stdout | search("OPERATIONAL")
-
-- name: wait for cluster ready
- shell: |
- mysql --silent --skip-column-names -e 'SHOW STATUS LIKE "wsrep_evs_state"' \
- | awk '{print $2}'
- register: cluster_status
- until: cluster_status|success
- failed_when: not cluster_status.stdout | search("OPERATIONAL")
- retries: 10
- delay: 3
- when: |
- inventory_hostname == haproxy_hosts.keys()[0]
- and not cluster_status.stdout | search("OPERATIONAL")
-
-- name: if I in the cluster nodes
- shell: |
- mysql --silent --skip-column-names \
- -e 'SHOW STATUS LIKE "wsrep_incoming_addresses"' | awk '{print $2}'
- register: cluster_nodes
- changed_when: false
-
-- name: restart other nodes and join cluster
- service:
- name: mysql
- state: restarted
- enabled: "yes"
- when: |
- inventory_hostname != haproxy_hosts.keys()[0]
- and not cluster_nodes.stdout | search( "{{ internal_ip }}")
-
-- name: remove unused user
- script: remove_user.sh
- when: ansible_os_family == "RedHat"
-
-- 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
deleted file mode 100644
index 22b5d60c..00000000
--- a/deploy/adapters/ansible/roles/database/tasks/mariadb_config.yml
+++ /dev/null
@@ -1,88 +0,0 @@
-##############################################################################
-# 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: create all needed db
- 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
- host={{ item[1] }}
- state=present
- with_nested:
- - "{{ credentials }}"
- - ['%', 'localhost']
- 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']
-
-- name: remove unused user
- script: remove_user.sh
- when: ansible_os_family == "RedHat"
-
-- name: restart mysql for centos noha
- service:
- name: mysql
- state: restarted
- when: >
- inventory_hostname == haproxy_hosts.keys()[0]
- and haproxy_hosts|length == 1
- and ansible_os_family == "RedHat"
-
-- name: restart mysql second time for centos noha
- service:
- name: mysql
- state: restarted
- when: >
- inventory_hostname == haproxy_hosts.keys()[0]
- and haproxy_hosts|length == 1
- and ansible_os_family == "RedHat"
-
-- name: restart first nodes
- service:
- name: mysql
- state: restarted
- when: inventory_hostname == haproxy_hosts.keys()[0]
- and haproxy_hosts|length > 1
-
-- 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
- service:
- name: mysql
- state: restarted
- enabled: "yes"
- when:
- - inventory_hostname != haproxy_hosts.keys()[0]
diff --git a/deploy/adapters/ansible/roles/database/tasks/mariadb_install.yml b/deploy/adapters/ansible/roles/database/tasks/mariadb_install.yml
deleted file mode 100644
index ba800dca..00000000
--- a/deploy/adapters/ansible/roles/database/tasks/mariadb_install.yml
+++ /dev/null
@@ -1,75 +0,0 @@
-##############################################################################
-# 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: disable auto start
- copy:
- content: "#!/bin/sh\nexit 101"
- dest: "/usr/sbin/policy-rc.d"
- mode: 0755
- when: ansible_os_family == "Debian"
-
-- name: change open file limit
- copy:
- content: "* - nofile 65536 }}"
- dest: "/etc/security/limits.conf"
- mode: 0755
-
-- name: install python-mysqldb
- action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
- with_items: "{{ maridb_packages | union(packages_noarch) }}"
-
-- 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 }}'
- dest: '{{ item.dest }}'
- backup: "yes"
- mode: 0644
- with_items: "{{ mysql_config }}"
-
-- name: bugfix for rsync version 3.1
- lineinfile:
- dest: /usr/bin/wsrep_sst_rsync
- state: absent
- regexp: '{{ item }}'
- with_items:
- - "\\s*uid = \\$MYUID$"
- - "\\s*gid = \\$MYGID$"
-
-- name: enable auto start
- file:
- path=/usr/sbin/policy-rc.d
- state=absent
- when: ansible_os_family == "Debian"
-
-- name: set owner
- file:
- path: /var/lib/mysql
- owner: mysql
- group: mysql
- recurse: "yes"
- state: directory
- mode: 0755
-
-- name: get logfile stat
- stat: path='{{ mysql_data_dir }}/ib_logfile0'
- register: logfile_stat
-
-- debug: msg='{{ logfile_stat.stat.exists}}'
-- debug: msg='{{ logfile_stat.stat.size }}'
- when: logfile_stat.stat.exists
-
-- name: rm logfile if exist and size mismatch
- shell: 'rm -rf {{ mysql_data_dir }}/ib_logfile*'
- when: |
- logfile_stat.stat.exists
- and logfile_stat.stat.size != 1073741824
diff --git a/deploy/adapters/ansible/roles/database/tasks/mongodb_config.yml b/deploy/adapters/ansible/roles/database/tasks/mongodb_config.yml
deleted file mode 100755
index 10f0322c..00000000
--- a/deploy/adapters/ansible/roles/database/tasks/mongodb_config.yml
+++ /dev/null
@@ -1,70 +0,0 @@
-##############################################################################
-# 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: copy mongo js
- template:
- src: '{{ item.src }}'
- dest: '{{ item.dest }}'
- with_items:
- - 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 == {{ haproxy_hosts|length }}
- retries: 60
- delay: 10
-
-- debug: msg='{{ servers.stdout |int }}'
-
-- name: wait replica servers are ready
- shell: mongo compass --eval 'printjson(rs.status())'|grep -E 'PRIMARY'|wc -l
- register: servers
- until: servers.stdout|int == 1
- retries: 60
- delay: 10
-
-- debug: msg='{{ servers.stdout |int }}'
-
-- name: Add admin user
- mongodb_user:
- login_host: "{{ internal_vip.ip }}"
- database: admin
- name: root
- password: root
- roles: 'root'
- state: present
-
-- name: create mongodb user and db
- mongodb_user:
- login_host: "{{ internal_vip.ip }}"
- login_user: root
- login_password: root
- database: ceilometer
- name: ceilometer
- password: "{{ CEILOMETER_DBPASS }}"
- roles: 'readWrite,dbAdmin'
- state: present
-
-- name: grant user privilege
- mongodb_user:
- login_host: "{{ internal_vip.ip }}"
- login_user: root
- login_password: root
- database: ceilometer
- name: ceilometer
- password: "{{ CEILOMETER_DBPASS }}"
- roles: 'readWrite,dbAdmin'
- state: present
diff --git a/deploy/adapters/ansible/roles/database/tasks/mongodb_install.yml b/deploy/adapters/ansible/roles/database/tasks/mongodb_install.yml
deleted file mode 100755
index 67bc0499..00000000
--- a/deploy/adapters/ansible/roles/database/tasks/mongodb_install.yml
+++ /dev/null
@@ -1,40 +0,0 @@
-##############################################################################
-# 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: install mongodb packages
- action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
- with_items: "{{ mongodb_packages | union(packages_noarch) }}"
-
-- name: install pymongod packages
- pip: name={{ item }} state=present extra_args='--pre'
- with_items: "{{ pip_packages }}"
-
-- name: copy ceilometer configs
- template: src=mongodb.conf dest=/opt/os_templates backup=yes
-
-- name: update mongodb config file
- shell: |
- crudini --merge {{ mongodb_config.dest }} < /opt/os_templates/mongodb.conf
-
-- name: rm prealloc files
- file:
- dest: "{{ item }}"
- state: absent
- with_fileglob:
- - "{{ 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}}
-
-- name: wait for mongod ready
- wait_for: host=0.0.0.0 port=27017 delay=10