Skip to content

Commit e5b7982

Browse files
Oplog user creation
Add functionality to create oplog users
1 parent 5e349fb commit e5b7982

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,14 @@ mongodb_users:
151151
database: app_development
152152
}
153153
```
154+
Example vars for oplog user:
155+
```yaml
156+
mongodb_oplog_users:
157+
- {
158+
user: oplog,
159+
password: passw0rd
160+
}
161+
```
154162
Required vars to change on production:
155163
```yaml
156164
mongodb_user_admin_password

tasks/main.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,28 @@
8888
no_log: true
8989
tags: [mongodb]
9090

91+
- name: create oplog user with replicaset
92+
mongodb_user_fixed:
93+
database: admin
94+
user: "{{ item.user }}"
95+
password: "{{ item.password }}"
96+
update_password: "{{ mongodb_user_update_password }}"
97+
roles:
98+
- db: local
99+
role: read
100+
login_user: "{{ mongodb_user_admin_name }}"
101+
login_password: "{{ mongodb_user_admin_password }}"
102+
login_port: "{{ mongodb_login_port|default(27017) }}"
103+
login_host: "{{ mongodb_login_host|default('localhost') }}"
104+
with_items:
105+
- "{{ mongodb_oplog_users | default([]) }}"
106+
when: ( mongodb_replication_replset
107+
and mongodb_replication_replset != ''
108+
and mongodb_security_authorization == 'enabled'
109+
and mongodb_master is defined and mongodb_master )
110+
no_log: false
111+
tags: [mongodb]
112+
91113
- name: Include MMS Agent configuration
92114
include: mms-agent.yml
93115
when: mongodb_mms_api_key != ""

0 commit comments

Comments
 (0)