---
- name: apt | Add mongodb key
  become: yes
  apt_key:
    # Don't use mongodb.org key location due to SNI verification problems under Ubuntu Trusty
    url: "hkp://keyserver.ubuntu.com:80"
    id: "{{ mongodb_apt_keys[mongodb_major_minor_version] }}"
    state: present
  tags: [databases, mongodb]

- name: apt | Add mongodb repository
  become: yes
  apt_repository:
    repo: 'deb http://repo.mongodb.org/apt/{{ ansible_distribution|lower }} {{ ansible_distribution_release|lower }}/mongodb-org/{{ mongodb_major_minor_version }} multiverse'
    state: present
  tags: [databases, mongodb]

- name: apt | Install mongodb
  become: yes
  apt:
    name: mongodb-org={{ mongodb_version }}*
    state: present
  notify: Restart mongod
  tags: [databases, mongodb]

---
- name: apt | Add mongodb key
  become: yes
  apt_key:
    # Don't use mongodb.org key location due to SNI verification problems under Ubuntu Trusty
    keyserver: "hkp://keyserver.ubuntu.com:80"
    id: "{{ mongodb_apt_keys[mongodb_major_minor_version] }}"
    state: present
  tags: [databases, mongodb]

- name: apt | Add mongodb repository
  become: yes
  apt_repository:
    repo: 'deb http://repo.mongodb.org/apt/{{ ansible_distribution|lower }} {{ ansible_distribution_release|lower }}/mongodb-org/{{ mongodb_major_minor_version }} multiverse'
    state: present
  tags: [databases, mongodb]

- name: apt | Install mongodb
  become: yes
  apt:
    name: mongodb-org={{ mongodb_version }}*
    state: present
  notify: Restart mongod
  tags: [databases, mongodb]

Fix apt_key keyserver for mongodb role
Fix apt_key keyserver for mongodb role
