From 70f74d005e2dd2795ca389ac35d93430f4363e06 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sun, 8 Jul 2018 15:22:24 +0200 Subject: [PATCH] try to add databases --- tasks/add_db_with_auth.yml | 10 ++++++++++ tasks/main.yml | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tasks/add_db_with_auth.yml diff --git a/tasks/add_db_with_auth.yml b/tasks/add_db_with_auth.yml new file mode 100644 index 0000000..ac36141 --- /dev/null +++ b/tasks/add_db_with_auth.yml @@ -0,0 +1,10 @@ +--- +- name: Create databases + mongodb_user: + login_user: "{{ mongodb_user_admin_name }}" + login_password: "{{ mongodb_user_admin_password }}" + database: unifi + name: unifiadm + password: password + roles: readWrite + state: present diff --git a/tasks/main.yml b/tasks/main.yml index 215ad27..2bd2061 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -12,6 +12,13 @@ register: __mongodb_admin_check changed_when: False failed_when: False + when: mongodb_rbac_enabled - include_tasks: auth.yml - when: not __mongodb_admin_check.rc == 0 + when: mongodb_rbac_enabled and not __mongodb_admin_check.rc == 0 + +- include_tasks: add_db_with_auth.yml + when: mongodb_rbac_enabled + +- include_tasks: add_db.yml + when: not mongodb_rbac_enabled