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