Jeffrey Zhang c567055176 Fix ansible warning
- rename action and serial to kolla_ansible and kolla_serial
- use become instead of "sudo <command>" in shell
- Remove quota for failed_when and changed_when in rabbitmq tasks

Change-Id: I78cb60168aaa40bb6439198283546b7faf33917c
Implements: blueprint migrate-to-ansible-2-2-0
2018-05-11 02:54:02 +00:00

125 lines
3.8 KiB
YAML

---
- name: Starting first MariaDB container
vars:
service_name: "mariadb"
service: "{{ mariadb_services[service_name] }}"
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
environment:
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
BOOTSTRAP_ARGS: "--wsrep-new-cluster"
image: "{{ service.image }}"
labels:
BOOTSTRAP:
name: "{{ service.container_name }}"
restart_policy: "never"
volumes: "{{ service.volumes }}"
when:
- bootstrap_host is defined
- bootstrap_host == inventory_hostname
notify:
- wait first mariadb container
- restart slave mariadb
- restart master mariadb
# TODO(jeffrey4l), remove the task check when the wait_for bug is fixed
# https://github.com/ansible/ansible-modules-core/issues/2788
- name: wait first mariadb container
wait_for:
host: "{{ api_interface_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
when:
- bootstrap_host is defined
- bootstrap_host == inventory_hostname
- name: restart slave mariadb
vars:
service_name: "mariadb"
service: "{{ mariadb_services[service_name] }}"
mariadb_container: "{{ check_mariadb_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
kolla_docker:
action: "recreate_or_restart_container"
common_options: "{{ docker_common_options }}"
name: "{{ service.container_name }}"
image: "{{ service.image }}"
volumes: "{{ service.volumes }}"
when:
- kolla_action != "config"
- inventory_hostname != master_host
- inventory_hostname in groups[service.group]
- service.enabled | bool
- mariadb_config_json.changed | bool
or mariadb_galera_conf.changed | bool
or mariadb_wsrep_notify.changed | bool
or mariadb_container.changed | bool
or bootstrap_host is defined
notify:
- wait for slave mariadb
# TODO(jeffrey4l), remove the task check when the wait_for bug is fixed
# https://github.com/ansible/ansible-modules-core/issues/2788
- name: wait for slave mariadb
wait_for:
host: "{{ api_interface_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
when:
- kolla_action != "config"
- inventory_hostname != master_host
- name: restart master mariadb
vars:
service_name: "mariadb"
service: "{{ mariadb_services[service_name] }}"
mariadb_container: "{{ check_mariadb_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
kolla_docker:
action: "recreate_or_restart_container"
common_options: "{{ docker_common_options }}"
name: "{{ service.container_name }}"
image: "{{ service.image }}"
volumes: "{{ service.volumes }}"
when:
- kolla_action != "config"
- inventory_hostname == master_host
- inventory_hostname in groups[service.group]
- service.enabled | bool
- mariadb_config_json.changed | bool
or mariadb_galera_conf.changed | bool
or mariadb_wsrep_notify.changed | bool
or mariadb_container.changed | bool
or bootstrap_host is defined
notify:
- Waiting for master mariadb
# TODO(jeffrey4l), remove the task check when the wait_for bug is fixed
# https://github.com/ansible/ansible-modules-core/issues/2788
- name: Waiting for master mariadb
wait_for:
host: "{{ api_interface_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
when:
- kolla_action != "config"
- inventory_hostname == master_host