kolla-ansible/ansible/roles/mariadb/tasks/lookup_cluster.yml
Michal Nasiadka 1009931162 Change local_action to delegate_to: localhost
As part of the effort to implement Ansible code linting in CI
(using ansible-lint) - we need to implement recommendations from
ansible-lint output [1].

One of them is to stop using local_action in favor of delegate_to -
to increase readability and and match the style of typical ansible
tasks.

[1]: https://review.opendev.org/694779/

Partially implements: blueprint ansible-lint

Change-Id: I46c259ddad5a6aaf9c7301e6c44cd8a1d5c457d3
2019-11-22 15:04:44 +00:00

52 lines
1.2 KiB
YAML

---
- name: Cleaning up temp file on localhost
file:
path: /tmp/kolla_mariadb_cluster
state: absent
delegate_to: localhost
changed_when: False
check_mode: no
run_once: True
# NOTE(mnasiadka): Due to the way that we are setting fact has_cluster - content needs to be ''
- name: Creating temp file on localhost
copy:
content: ''
dest: /tmp/kolla_mariadb_cluster
mode: 0644
delegate_to: localhost
changed_when: False
check_mode: no
run_once: True
- name: Creating mariadb volume
become: true
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
copy:
content: "{{ ansible_hostname }}"
dest: /tmp/kolla_mariadb_cluster
mode: 0644
delegate_to: localhost
changed_when: False
check_mode: no
when: mariadb_volume is not changed
- name: Registering host from temp file
set_fact:
has_cluster: "{{ lookup('file', '/tmp/kolla_mariadb_cluster') | length > 0 }}"
- name: Cleaning up temp file on localhost
file:
path: /tmp/kolla_mariadb_cluster
state: absent
delegate_to: localhost
changed_when: False
check_mode: no
run_once: True