---
- name: Converge
  hosts: all
  become: yes

  roles:
    - role: mongodb_repository
      tags: molecule-idempotence-notest
    - role: mongodb_config

  tasks:

    - name: Install python stuff
      package:
        name: ["python-setuptools", "python-pip"]
      when: ansible_hostname == "ubuntu-16"

    - name: Install pymongo
      pip:
        name: pymongo
      when: ansible_hostname == "ubuntu-16"

    - name: Install MongoDB Shell
      package:
        name: mongodb-org-shell

    - name: Init config server replicaset
      community.mongodb.mongodb_replicaset:
        login_host: localhost
        login_port: 27019
        replica_set: cfg
        members:
          - ubuntu-16.local:27019
          - ubuntu-18.local:27019
          - debian-stretch.local:27019
          - debian-buster.local:27019
          - centos-7.local:27019
      when: ansible_hostname == "ubuntu-16"
