- name: create administrative user siteRootAdmin port=yes mongodb_user: database: admin name: "{{ item.name }}" password: "{{ item.password }}" roles: "{{ item.roles }}" login_host: 127.0.0.1 login_port: "{{ ansible_local.mongodb.mongodb.mongodb_login_port }}" with_items: - { name: "{{ mongodb_root_admin_name }}", password: "{{ mongodb_root_admin_password }}", roles: "root" } - name: create administrative user siteUserAdmin port=yes mongodb_user: database: admin name: "{{ item.name }}" password: "{{ item.password }}" roles: "{{ item.roles }}" login_host: 127.0.0.1 login_port: "{{ ansible_local.mongodb.mongodb.mongodb_login_port }}" with_items: - { name: "{{ mongodb_user_admin_name }}", password: "{{ mongodb_user_admin_password }}", roles: "userAdminAnyDatabase" } - name: create normal users mongodb_user: database: "{{ item.database }}" name: "{{ item.name }}" password: "{{ item.password }}" roles: "{{ item.roles }}" replica_set: "{{ mongodb_conf_replSet }}" login_host: 127.0.0.1 login_port: "{{ ansible_local.mongodb.mongodb.mongodb_login_port }}" login_user: "{{ mongodb_user_admin_name }}" login_password: "{{ mongodb_user_admin_password }}" with_items: - "{{ mongodb_users }}"