kolla-ansible/ansible/roles/mongodb/tasks/bootstrap_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

25 lines
848 B
YAML

---
- name: Copying the mongodb replication set bootstrap script
template:
src: bootstrap_cluster.js.j2
dest: /tmp/mongodb_bootstrap_replication_set.js
delegate_to: localhost
run_once: True
- name: Bootstrapping the mongodb replication set
become: true
command: "docker exec -t mongodb mongo --host {{ api_interface_address }} --port {{ mongodb_port }} --quiet --eval '{{ lookup('file','/tmp/mongodb_bootstrap_replication_set.js') }}'"
register: bootstrap_mongodb_cluster
failed_when: (bootstrap_mongodb_cluster.stdout|from_json).ok != 1
delegate_to: "{{ groups['mongodb'][0] }}"
run_once: True
- name: Deleting the mongodb replication set bootstrap script
file:
path: /tmp/mongodb_bootstrap_replication_set.js
state: absent
delegate_to: localhost
changed_when: false
failed_when: false
run_once: True