aboutsummaryrefslogtreecommitdiff
path: root/ansible/roles/mariadb/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'ansible/roles/mariadb/tasks')
-rw-r--r--ansible/roles/mariadb/tasks/bootstrap.yml10
-rw-r--r--ansible/roles/mariadb/tasks/bootstrap_cluster.yml39
-rw-r--r--ansible/roles/mariadb/tasks/check.yml8
-rw-r--r--ansible/roles/mariadb/tasks/config.yml34
-rw-r--r--ansible/roles/mariadb/tasks/deploy.yml23
-rw-r--r--ansible/roles/mariadb/tasks/lookup_cluster.yml35
-rw-r--r--ansible/roles/mariadb/tasks/main.yml2
-rw-r--r--ansible/roles/mariadb/tasks/precheck.yml1
-rw-r--r--ansible/roles/mariadb/tasks/pull.yml7
-rw-r--r--ansible/roles/mariadb/tasks/reconfigure.yml66
-rw-r--r--ansible/roles/mariadb/tasks/recover_cluster.yml94
-rw-r--r--ansible/roles/mariadb/tasks/register.yml21
-rw-r--r--ansible/roles/mariadb/tasks/start.yml31
-rw-r--r--ansible/roles/mariadb/tasks/upgrade.yml8
14 files changed, 0 insertions, 379 deletions
diff --git a/ansible/roles/mariadb/tasks/bootstrap.yml b/ansible/roles/mariadb/tasks/bootstrap.yml
deleted file mode 100644
index 6647cb598..000000000
--- a/ansible/roles/mariadb/tasks/bootstrap.yml
+++ /dev/null
@@ -1,10 +0,0 @@
----
-- include: lookup_cluster.yml
-
-- include: bootstrap_cluster.yml
- when:
- - delegate_host == 'None'
- - inventory_hostname == groups['mariadb'][0]
-
-- include: recover_cluster.yml
- when: mariadb_recover | default(False)
diff --git a/ansible/roles/mariadb/tasks/bootstrap_cluster.yml b/ansible/roles/mariadb/tasks/bootstrap_cluster.yml
deleted file mode 100644
index 51915f4e3..000000000
--- a/ansible/roles/mariadb/tasks/bootstrap_cluster.yml
+++ /dev/null
@@ -1,39 +0,0 @@
----
-- name: Running MariaDB bootstrap container
- kolla_docker:
- action: "start_container"
- common_options: "{{ docker_common_options }}"
- detach: False
- environment:
- KOLLA_BOOTSTRAP:
- KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
- DB_ROOT_PASSWORD: "{{ database_password }}"
- DB_MAX_TIMEOUT: "{{ database_max_timeout }}"
- image: "{{ mariadb_image_full }}"
- labels:
- BOOTSTRAP:
- name: "bootstrap_mariadb"
- restart_policy: "never"
- volumes:
- - "{{ node_config_directory }}/mariadb/:{{ container_config_directory }}/:ro"
- - "/etc/localtime:/etc/localtime:ro"
- - "kolla_logs:/var/log/kolla/"
- - "mariadb:/var/lib/mysql"
-
-- name: Starting first MariaDB container
- kolla_docker:
- action: "start_container"
- common_options: "{{ docker_common_options }}"
- environment:
- KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
- BOOTSTRAP_ARGS: "--wsrep-new-cluster"
- image: "{{ mariadb_image_full }}"
- labels:
- BOOTSTRAP:
- name: "mariadb"
- restart_policy: "never"
- volumes:
- - "{{ node_config_directory }}/mariadb/:{{ container_config_directory }}/:ro"
- - "/etc/localtime:/etc/localtime:ro"
- - "kolla_logs:/var/log/kolla/"
- - "mariadb:/var/lib/mysql"
diff --git a/ansible/roles/mariadb/tasks/check.yml b/ansible/roles/mariadb/tasks/check.yml
deleted file mode 100644
index 5389e78ae..000000000
--- a/ansible/roles/mariadb/tasks/check.yml
+++ /dev/null
@@ -1,8 +0,0 @@
----
-- name: Waiting for MariaDB service to be ready through VIP
- command: "docker exec mariadb mysql -h {{ kolla_internal_fqdn }} -P {{ mariadb_port }} -u haproxy -e 'show databases;'"
- register: result
- until: result | success
- changed_when: False
- retries: 6
- delay: 10
diff --git a/ansible/roles/mariadb/tasks/config.yml b/ansible/roles/mariadb/tasks/config.yml
deleted file mode 100644
index a748c1adf..000000000
--- a/ansible/roles/mariadb/tasks/config.yml
+++ /dev/null
@@ -1,34 +0,0 @@
----
-- name: Ensuring config directories exist
- file:
- path: "{{ node_config_directory }}/{{ item }}"
- state: "directory"
- recurse: yes
- with_items:
- - "mariadb"
-
-- name: Copying over config.json files for services
- template:
- src: "{{ item }}.json.j2"
- dest: "{{ node_config_directory }}/{{ item }}/config.json"
- with_items:
- - "mariadb"
-
-- name: Copying over galera.cnf
- merge_configs:
- vars:
- service_name: "{{ item }}"
- sources:
- - "{{ role_path }}/templates/galera.cnf.j2"
- - "{{ node_custom_config }}/galera.cnf"
- - "{{ node_custom_config }}/mariadb/{{ inventory_hostname }}/galera.cnf"
- dest: "{{ node_config_directory }}/{{ item }}/galera.cnf"
- with_items:
- - "mariadb"
-
-- name: Copying over wsrep-notify.sh
- template:
- src: "{{ role_path }}/templates/wsrep-notify.sh.j2"
- dest: "{{ node_config_directory }}/{{ item }}/wsrep-notify.sh"
- with_items:
- - "mariadb"
diff --git a/ansible/roles/mariadb/tasks/deploy.yml b/ansible/roles/mariadb/tasks/deploy.yml
deleted file mode 100644
index 93f19edce..000000000
--- a/ansible/roles/mariadb/tasks/deploy.yml
+++ /dev/null
@@ -1,23 +0,0 @@
----
-- include: config.yml
-
-- include: bootstrap.yml
-
-- include: start.yml
-
-# We use register as a test to see whether the database is active and ready to
-# communicate. This run on all hosts that have a database and attempts to talk
-# to the local database rather than the vip,
-- include: register.yml
-
-# This will restart the container we initially used to bootstrap the cluster to
-# make it match the other containers environment-wise. This also prevents a
-# change from showing up when rerunning the playbooks
-- include: start.yml
-
-# Since the last start.yml may have recreated some containers we must wait and
-# check the health again to ensure the hosts are active.
-- include: register.yml
-
-# Test haproxy user through VIP
-- include: check.yml
diff --git a/ansible/roles/mariadb/tasks/lookup_cluster.yml b/ansible/roles/mariadb/tasks/lookup_cluster.yml
deleted file mode 100644
index efca14ee0..000000000
--- a/ansible/roles/mariadb/tasks/lookup_cluster.yml
+++ /dev/null
@@ -1,35 +0,0 @@
----
-- name: Cleaning up temp file on localhost
- local_action: file path=/tmp/kolla_mariadb_cluster state=absent
- changed_when: False
- check_mode: no
- run_once: True
-
-- name: Creating temp file on localhost
- local_action: copy content=None dest=/tmp/kolla_mariadb_cluster mode=0644
- changed_when: False
- check_mode: no
- run_once: True
-
-- name: Creating mariadb volume
- kolla_docker:
- action: "create_volume"
- common_options: "{{ docker_common_options }}"
- name: "mariadb"
- register: mariadb_volume
-
-- name: Writing hostname of host with existing cluster files to temp file
- local_action: copy content={{ ansible_hostname }} dest=/tmp/kolla_mariadb_cluster mode=0644
- changed_when: False
- check_mode: no
- when: not mariadb_volume | changed
-
-- name: Registering host from temp file
- set_fact:
- delegate_host: "{{ lookup('file', '/tmp/kolla_mariadb_cluster') }}"
-
-- name: Cleaning up temp file on localhost
- local_action: file path=/tmp/kolla_mariadb_cluster state=absent
- changed_when: False
- check_mode: no
- run_once: True
diff --git a/ansible/roles/mariadb/tasks/main.yml b/ansible/roles/mariadb/tasks/main.yml
deleted file mode 100644
index b017e8b4a..000000000
--- a/ansible/roles/mariadb/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include: "{{ action }}.yml"
diff --git a/ansible/roles/mariadb/tasks/precheck.yml b/ansible/roles/mariadb/tasks/precheck.yml
deleted file mode 100644
index ed97d539c..000000000
--- a/ansible/roles/mariadb/tasks/precheck.yml
+++ /dev/null
@@ -1 +0,0 @@
----
diff --git a/ansible/roles/mariadb/tasks/pull.yml b/ansible/roles/mariadb/tasks/pull.yml
deleted file mode 100644
index 13d27693b..000000000
--- a/ansible/roles/mariadb/tasks/pull.yml
+++ /dev/null
@@ -1,7 +0,0 @@
----
-- name: Pulling mariadb image
- kolla_docker:
- action: "pull_image"
- common_options: "{{ docker_common_options }}"
- image: "{{ mariadb_image_full }}"
- when: inventory_hostname in groups['mariadb']
diff --git a/ansible/roles/mariadb/tasks/reconfigure.yml b/ansible/roles/mariadb/tasks/reconfigure.yml
deleted file mode 100644
index 92bf538c4..000000000
--- a/ansible/roles/mariadb/tasks/reconfigure.yml
+++ /dev/null
@@ -1,66 +0,0 @@
----
-- name: Ensuring the containers up
- kolla_docker:
- name: "{{ item.name }}"
- action: "get_container_state"
- register: container_state
- failed_when: container_state.Running == false
- when: inventory_hostname in groups[item.group]
- with_items:
- - { name: mariadb, group: mariadb }
-
-- include: config.yml
-
-- name: Check the configs
- command: docker exec {{ item.name }} /usr/local/bin/kolla_set_configs --check
- changed_when: false
- failed_when: false
- register: check_results
- when: inventory_hostname in groups[item.group]
- with_items:
- - { name: mariadb, group: mariadb }
-
-# NOTE(jeffrey4l): when config_strategy == 'COPY_ALWAYS'
-# and container env['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE',
-# just remove the container and start again
-- name: Containers config strategy
- kolla_docker:
- name: "{{ item.name }}"
- action: "get_container_env"
- register: container_envs
- when: inventory_hostname in groups[item.group]
- with_items:
- - { name: mariadb, group: mariadb }
-
-- name: Remove the containers
- kolla_docker:
- name: "{{ item[0]['name'] }}"
- action: "remove_container"
- register: remove_containers
- when:
- - config_strategy == "COPY_ONCE" or item[1]['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE'
- - item[2]['rc'] == 1
- - inventory_hostname in groups[item[0]['group']]
- with_together:
- - [{ name: mariadb, group: mariadb }]
- - "{{ container_envs.results }}"
- - "{{ check_results.results }}"
-
-- include: start.yml
- when: remove_containers.changed
-
-- name: Restart containers
- kolla_docker:
- name: "{{ item[0]['name'] }}"
- action: "restart_container"
- when:
- - config_strategy == 'COPY_ALWAYS'
- - item[1]['KOLLA_CONFIG_STRATEGY'] != 'COPY_ONCE'
- - item[2]['rc'] == 1
- - inventory_hostname in groups[item[0]['group']]
- with_together:
- - [{ name: mariadb, group: mariadb }]
- - "{{ container_envs.results }}"
- - "{{ check_results.results }}"
-
-- include: check.yml
diff --git a/ansible/roles/mariadb/tasks/recover_cluster.yml b/ansible/roles/mariadb/tasks/recover_cluster.yml
deleted file mode 100644
index bf62a85f4..000000000
--- a/ansible/roles/mariadb/tasks/recover_cluster.yml
+++ /dev/null
@@ -1,94 +0,0 @@
----
-- fail:
- msg: "MariaDB cluster was not found. Is your inventory correct?"
- when: delegate_host == 'None'
-
-- name: Checking if and mariadb containers are running
- kolla_docker:
- name: "mariadb"
- action: "get_container_state"
- register: container_state
-
-- fail:
- msg: "There are running MariaDB nodes, please stop them first."
- when: container_state.Running | bool
- any_errors_fatal: True
-
-- name: Cleaning up temp file on mariadb hosts
- file: path=/tmp/kolla_mariadb_grastate.dat state=absent
- changed_when: false
- check_mode: no
-
-- name: Cleaning up temp file on localhost
- local_action: file path=/tmp/kolla_mariadb_recover_inventory_name state=absent
- changed_when: false
- check_mode: no
- run_once: true
-
-- block:
- - name: Copying grastate.dat file from mariadb container
- command: docker cp mariadb:/var/lib/mysql/grastate.dat /tmp/kolla_mariadb_grastate.dat
- changed_when: false
-
- - name: Print the content of grastate.dat file
- command: cat /tmp/kolla_mariadb_grastate.dat
- register: cat_grastate
- changed_when: false
-
- - name: Registering mariadb seqno variable
- set_fact:
- seqno: "{{ (cat_grastate.stdout|from_yaml).seqno }}"
- changed_when: false
-
- - name: Comparing seqno value on all mariadb hosts
- shell: "if [[ {{ hostvars[inventory_hostname]['seqno'] }} -lt {{ hostvars[item]['seqno'] }} ]]; then echo {{ hostvars[item]['seqno'] }}; fi"
- with_items: "{{ groups['mariadb'] }}"
- changed_when: false
- register: seqno_compare
-
- - name: Writing hostname of host with the largest seqno to temp file
- local_action: copy content={{ inventory_hostname }} dest=/tmp/kolla_mariadb_recover_inventory_name mode=0644
- changed_when: false
- when: seqno_compare.results | map(attribute='stdout') | join('') == ""
-
- - name: Registering mariadb_recover_inventory_name from temp file
- set_fact:
- mariadb_recover_inventory_name: "{{ lookup('file', '/tmp/kolla_mariadb_recover_inventory_name') }}"
- when:
- - mariadb_recover_inventory_name is not defined
-
-- name: Cleaning up temp file on mariadb hosts
- file: path=/tmp/kolla_mariadb_grastate.dat state=absent
- changed_when: false
- check_mode: no
-
-- name: Cleaning up temp file on localhost
- local_action: file path=/tmp/kolla_mariadb_recover_inventory_name state=absent
- changed_when: false
- check_mode: no
- run_once: true
-
-- name: Starting first MariaDB container
- kolla_docker:
- action: "start_container"
- common_options: "{{ docker_common_options }}"
- environment:
- KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
- BOOTSTRAP_ARGS: "--wsrep-new-cluster"
- image: "{{ mariadb_image_full }}"
- labels:
- BOOTSTRAP:
- name: "mariadb"
- restart_policy: "never"
- volumes:
- - "{{ node_config_directory }}/mariadb/:{{ container_config_directory }}/:ro"
- - "/etc/localtime:/etc/localtime:ro"
- - "kolla_logs:/var/log/kolla/"
- - "mariadb:/var/lib/mysql"
- when:
- - (mariadb_recover_inventory_name is not defined and inventory_hostname == groups['mariadb'][0]) or
- (mariadb_recover_inventory_name is defined and inventory_hostname == mariadb_recover_inventory_name)
-
-- name: Reset bootstrap fact
- set_fact:
- delegate_host: "None"
diff --git a/ansible/roles/mariadb/tasks/register.yml b/ansible/roles/mariadb/tasks/register.yml
deleted file mode 100644
index bd9a3e7c8..000000000
--- a/ansible/roles/mariadb/tasks/register.yml
+++ /dev/null
@@ -1,21 +0,0 @@
----
-- name: Creating haproxy mysql user
- command: docker exec -t kolla_toolbox /usr/bin/ansible localhost
- -m mysql_user
- -a "login_host='{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}'
- login_port='{{ mariadb_port }}'
- login_user='{{ database_user }}'
- login_password='{{ database_password }}'
- name='haproxy'
- password=''
- host='%'
- priv=*.*:USAGE"
- register: haproxy_user
- changed_when: "{{ haproxy_user.stdout.find('localhost | SUCCESS => ') != -1 and (haproxy_user.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
- until: haproxy_user.stdout.split()[2] == 'SUCCESS'
- retries: 10
- delay: 5
-
-- name: Cleaning up facts
- set_fact:
- delegate_host: "bootstraped"
diff --git a/ansible/roles/mariadb/tasks/start.yml b/ansible/roles/mariadb/tasks/start.yml
deleted file mode 100644
index f71ad37a5..000000000
--- a/ansible/roles/mariadb/tasks/start.yml
+++ /dev/null
@@ -1,31 +0,0 @@
----
-- name: Starting mariadb container
- kolla_docker:
- action: "start_container"
- common_options: "{{ docker_common_options }}"
- image: "{{ mariadb_image_full }}"
- name: "mariadb"
- volumes:
- - "{{ node_config_directory }}/mariadb/:{{ container_config_directory }}/:ro"
- - "/etc/localtime:/etc/localtime:ro"
- - "mariadb:/var/lib/mysql"
- - "kolla_logs:/var/log/kolla/"
- when: delegate_host != 'None' or
- ( groups['mariadb'] | length ) == 1 or
- ( delegate_host == 'None' and mariadb_recover_inventory_name is not defined and inventory_hostname != groups['mariadb'][0] ) or
- ( delegate_host == 'None' and mariadb_recover_inventory_name is defined and inventory_hostname != mariadb_recover_inventory_name )
-
-
-# TODO(jeffrey4l), remove the task check when the wair_for bug is fixed
-# https://github.com/ansible/ansible-modules-core/issues/2788
-- name: Waiting for MariaDB service to be ready
- wait_for:
- host: "{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}"
- port: "{{ mariadb_port }}"
- connect_timeout: 1
- timeout: 60
- search_regex: "MariaDB"
- register: check_mariadb_port
- until: check_mariadb_port | success
- retries: 10
- delay: 6
diff --git a/ansible/roles/mariadb/tasks/upgrade.yml b/ansible/roles/mariadb/tasks/upgrade.yml
deleted file mode 100644
index fafc44ff3..000000000
--- a/ansible/roles/mariadb/tasks/upgrade.yml
+++ /dev/null
@@ -1,8 +0,0 @@
----
-- include: config.yml
-
-- include: lookup_cluster.yml
-
-- include: start.yml
-
-- include: check.yml