kolla-ansible/ansible/roles/mariadb/tasks/bootstrap.yml
SamYaple 6d8959a962 Update all bootstraps to use Label
Add bootstrap label to all bootstrap containers to ensure that when
the a new container is launched a difference is seen between it and
the bootstrap container since we cannot rely on ENV variables for
this. This only affects mariadb at this stage, but it is needed to
ensure rabbitmq works when we switch to named volumes.

Change-Id: Ia022af26212d2e5445c06149848831037a508407
Closes-Bug: #1538136
2016-01-28 20:26:41 +00:00

68 lines
2.0 KiB
YAML

---
- name: Cleaning up temp file on localhost
local_action: file path=/tmp/kolla_mariadb_cluster state=absent
changed_when: False
always_run: True
run_once: True
- name: Creating temp file on localhost
local_action: copy content=None dest=/tmp/kolla_mariadb_cluster mode=0600
changed_when: False
always_run: True
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=0600
changed_when: False
always_run: True
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
always_run: True
run_once: True
- name: Starting MariaDB bootstrap container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
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: "mariadb"
restart_policy: "never"
volumes:
- "{{ node_config_directory }}/mariadb/:{{ container_config_directory }}/:ro"
- "mariadb:/var/lib/mysql"
when:
- delegate_host == 'None'
- inventory_hostname == groups['mariadb'][0]
- name: Waiting for MariaDB service to be ready
command: "docker exec mariadb ls /var/lib/mysql/mariadb.pid"
register: bootstrap_result
when:
- delegate_host == 'None'
- inventory_hostname == groups['mariadb'][0]
until: bootstrap_result | success
changed_when: False
retries: 6
delay: 10