---
- include: mongodb_rhel_dependencies.yaml

- name: yum | Add mongodb key
  become: yes
  rpm_key:
    key: https://www.mongodb.org/static/pgp/server-3.4.asc
    state: present
  tags: [databases, mongodb]

- name: yum | Add mongodb repository
  become: yes
  yum_repository:
    name: mongodb-org-3.4
    description: MongoDB Repository
    gpgcheck: yes
    enabled: yes
    baseurl: https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
    gpgkey: https://www.mongodb.org/static/pgp/server-3.4.asc
    state: present
  register: mongodb_repo_add
  tags: [databases, mongodb]

- name: yum | Install mongodb
  become: yes
  yum:
    name: mongodb-org
    state: state: "{{ 'latest' if mongodb_repo_add.changed or 'present' }}"
  notify:
    - restart mongod
  tags: [databases, mongodb]

---
- include: mongodb_rhel_dependencies.yaml

- name: yum | Add mongodb key
  become: yes
  rpm_key:
    key: https://www.mongodb.org/static/pgp/server-3.4.asc
    state: present
  tags: [databases, mongodb]

- name: yum | Add mongodb repository
  become: yes
  yum_repository:
    name: mongodb-org-3.4
    description: MongoDB Repository
    gpgcheck: yes
    enabled: yes
    baseurl: https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
    gpgkey: https://www.mongodb.org/static/pgp/server-3.4.asc
    state: present
  register: mongodb_repo_add
  tags: [databases, mongodb]

- name: yum | Install mongodb
  become: yes
  yum:
    name: mongodb-org
    state: "{{ 'latest' if mongodb_repo_add.changed or 'present' }}"
  notify:
    - restart mongod
  tags: [databases, mongodb]

Fix the typo in state
Fix the typo in state
