---
- name: Copying the mongodb replication set bootstrap script
  template: src=bootstrap_cluster.js.j2 dest=/tmp/mongodb_bootstrap_replication_set.js
  delegate_to: "{{ groups['mongodb'][0] }}"
  run_once: True

- name: Bootstraping the mongodb replication set
  command: "docker exec -t mongodb mongo {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }} --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
  changed_when: false
  failed_when: false
  delegate_to: "{{ groups['mongodb'][0] }}"
  run_once: True

---
- name: Copying the mongodb replication set bootstrap script
  local_action: template src=bootstrap_cluster.js.j2 dest=/tmp/mongodb_bootstrap_replication_set.js
  run_once: True

- name: Bootstraping the mongodb replication set
  command: "docker exec -t mongodb mongo {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }} --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
  local_action: file path=/tmp/mongodb_bootstrap_replication_set.js state=absent
  changed_when: false
  failed_when: false
  run_once: True

Copy mongodb_bootstrap_replication_set.js to /tmp on the deployment host
Copy mongodb_bootstrap_replication_set.js to /tmp on the deployment host

Change-Id: I502801c0ce6b9ff6b8216d3fce9957061593674d
Closes-bug: #1622993
