From e5b79820c816d15908b3217054a1cfdc5ce315b1 Mon Sep 17 00:00:00 2001 From: Kristjan Kullerkann Date: Mon, 3 Sep 2018 23:06:22 +0300 Subject: [PATCH] Oplog user creation Add functionality to create oplog users --- README.md | 8 ++++++++ tasks/main.yml | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/README.md b/README.md index 931fec9..2791b51 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,14 @@ mongodb_users: database: app_development } ``` +Example vars for oplog user: +```yaml +mongodb_oplog_users: + - { + user: oplog, + password: passw0rd +} +``` Required vars to change on production: ```yaml mongodb_user_admin_password diff --git a/tasks/main.yml b/tasks/main.yml index 01bba78..ee3af44 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -88,6 +88,28 @@ no_log: true tags: [mongodb] +- name: create oplog user with replicaset + mongodb_user_fixed: + database: admin + user: "{{ item.user }}" + password: "{{ item.password }}" + update_password: "{{ mongodb_user_update_password }}" + roles: + - db: local + role: read + login_user: "{{ mongodb_user_admin_name }}" + login_password: "{{ mongodb_user_admin_password }}" + login_port: "{{ mongodb_login_port|default(27017) }}" + login_host: "{{ mongodb_login_host|default('localhost') }}" + with_items: + - "{{ mongodb_oplog_users | default([]) }}" + when: ( mongodb_replication_replset + and mongodb_replication_replset != '' + and mongodb_security_authorization == 'enabled' + and mongodb_master is defined and mongodb_master ) + no_log: false + tags: [mongodb] + - name: Include MMS Agent configuration include: mms-agent.yml when: mongodb_mms_api_key != ""