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

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

  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: Initialise replicaset
      community.mongodb.mongodb_replicaset:
        login_host: localhost
        replica_set: rs0
        validate: yes
        members:
          - ubuntu-16.local:27017
          - ubuntu-18.local:27017
          - debian-stretch.local:27017
          - debian-buster.local:27017
          - centos-7.local:27017
      when: ansible_hostname == "ubuntu-16"
