--- - block: - name: Add repository for major version '{{ mongodb_version }}' yum_repository: name: mongodb description: MongoDB Repository baseurl: "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/{{ mongodb_version }}/x86_64/" gpgcheck: yes enabled: yes gpgkey: "https://www.mongodb.org/static/pgp/server-{{ mongodb_version }}.asc" - name: Install package package: name: mongodb-org state: present - name: Create system group '{{ mongodb_system_group }}' group: name: "{{ mongodb_system_group }}" gid: "{{ mongodb_system_gid | default(omit) }}" state: present - name: Create system user '{{ mongodb_system_user }}' user: name: "{{ mongodb_system_user }}" uid: "{{ mongodb_system_uid | default(omit) }}" group: "{{ mongodb_system_group }}" notify: __mongod_restart - name: Create db storage dir at '{{ mongodb_storage_dbpath }}' file: path: "{{ item }}" owner: "{{ mongodb_system_user }}" group: "{{ mongodb_system_group }}" recurse: yes state: directory with_items: - "{{ mongodb_storage_dbpath }}" - "{{ mongodb_systemlog_path | dirname if mongodb_systemlog_destination == 'file'}}" # - name: Make sure mongodb is running # systemd: # name: mongod # state: started # enabled: yes # daemon_reload: yes become: True become_user: root