Skip to content

Commit c5ba6f6

Browse files
committed
Add job to create mongo users automatically
1 parent 7cedd80 commit c5ba6f6

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: mongo-create-users
2+
3+
container_image: mongo
4+
container_tag: "3.2.6"
5+
6+
advance_arg: true
7+
8+
container_run_args: >
9+
mongo mongo/admin --eval \"db.createUser({user:'{{ mongo_user }}',pwd:'{{ mongo_password }}',roles:[{role:'root',db:'admin'}]});\" &&
10+
mongo mongo/api --eval \"db.createUser({user:'{{ mongo_user }}',pwd:'{{ mongo_password }}',roles:[{role:'readWrite',db:'api'}]});\" &&
11+
mongo mongo/clio --eval \"db.createUser({user:'{{ mongo_user }}',pwd:'{{ mongo_password }}',roles:[{role:'readWrite',db:'clio'}]});\" &&
12+
mongo mongo/navi --eval \"db.createUser({user:'{{ mongo_user }}',pwd:'{{ mongo_password }}',roles:[{role:'readWrite',db:'navi'}]});\" &&
13+
echo Finished

ansible/mongo-create-users.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
- hosts: mongo
3+
vars_files:
4+
- group_vars/alpha-mongo-create-users.yml
5+
roles:
6+
- role: k8-job

0 commit comments

Comments
 (0)