Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
---
- name: Converge
  hosts: all
  become: yes
  vars:
    # for this test, each machine is an isolated mongod instance
    replicaset: false
    sharding: false

    # initially disable authorization on some hosts
    hosts_with_auth_disabled:
      - ubuntu_18
      - debian_buster

    # add some users for some of the hosts
    hosts_with_extra_user:
      - centos_8
      - ubuntu_16
      - debian_buster
    mongodb_users_empty: []
    mongodb_users_full:
      - db: somedatabase
        user: someuser
        pwd: "S0meP@ss"
        roles: readWrite
      - db: somedatabase
        user: otheruser
        pwd: "0th3rP@ss"
        roles: readWrite
    mongodb_users: "{% if inventory_hostname in hosts_with_extra_user %}{{ mongodb_users_full }}{% else %}{{ mongodb_users_empty }}{% endif %}"

  roles:
    - role: mongodb_repository
      tags: molecule-idempotence-notest
    - role: mongodb_mongod
      authorization: "{% if inventory_hostname in hosts_with_auth_disabled %}disabled{% else %}enabled{% endif %}"
      tags: molecule-idempotence-notest # avoids false positive where replacing conf file disables authorization again

  tasks:
    - name: Add EPEL repo to CentOS 7 to allow installing pip package
      become: yes
      yum:
        name: epel-release
        state: present
      when: inventory_hostname  == 'centos_7'

    - name: Install python stuff
      package:
        name:
          - "python{% if needs_3 %}3{% endif %}-setuptools"
          - "python{% if needs_3 %}3{% endif %}-pip"
      vars:
        needs_3: "{{ ansible_facts.python.version.major == 3 }}"

    - name: Install pymongo
      pip:
        name: "{{ 'pymongo==3.12.*' if ansible_python_version[0:3] | float < 3.6 else 'pymongo' }}"

    - name: Enable mongo auth
      include_role:
        name: mongodb_auth

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