From d25113e8fab871b2ead95ca976c5a43e4759ea26 Mon Sep 17 00:00:00 2001 From: Sergei Antipov Date: Mon, 2 Mar 2015 16:07:44 +0600 Subject: [PATCH] Fixed issue #3 --- tasks/auth_initialization.yml | 34 +++++++++++++++---------------- tasks/auth_initialization_ald.yml | 32 +++++++++++++++-------------- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/tasks/auth_initialization.yml b/tasks/auth_initialization.yml index 3d3be5e..a787026 100644 --- a/tasks/auth_initialization.yml +++ b/tasks/auth_initialization.yml @@ -3,22 +3,6 @@ - include: auth_initialization_ald.yml when: ansible_local.mongodb.mongodb.mongodb_login_port is defined -- name: create administrative user siteRootAdmin - mongodb_user: - database: admin - name: "{{ item.name }}" - password: "{{ item.password }}" - roles: "{{ item.roles }}" - login_host: 127.0.0.1 - with_items: - - { - name: "{{ mongodb_root_admin_name }}", - password: "{{ mongodb_root_admin_password }}", - roles: "root" - } - register: rootadmin_user_result - when: ansible_local.mongodb.mongodb.mongodb_login_port is undefined - - name: create administrative user siteUserAdmin mongodb_user: database: admin @@ -35,6 +19,22 @@ register: useradmin_user_result when: ansible_local.mongodb.mongodb.mongodb_login_port is undefined +- name: create administrative user siteRootAdmin + mongodb_user: + database: admin + name: "{{ item.name }}" + password: "{{ item.password }}" + roles: "{{ item.roles }}" + login_host: 127.0.0.1 + with_items: + - { + name: "{{ mongodb_root_admin_name }}", + password: "{{ mongodb_root_admin_password }}", + roles: "root" + } + register: rootadmin_user_result + when: ansible_local.mongodb.mongodb.mongodb_login_port is undefined + - name: create normal users mongodb_user: database: "{{ item.database }}" @@ -59,5 +59,5 @@ - name: Create facts file for mongodb copy: dest: /etc/ansible/facts.d/mongodb.fact - content: "[mongodb]\nmongodb_login_port={{ mongodb_conf_port }}\n" + content: "[mongodb]\nmongodb_login_port={{ mongodb_conf_port }}\n\n" when: rootadmin_user_result|changed or useradmin_user_result|changed diff --git a/tasks/auth_initialization_ald.yml b/tasks/auth_initialization_ald.yml index 0fa9d9a..5fd7ead 100644 --- a/tasks/auth_initialization_ald.yml +++ b/tasks/auth_initialization_ald.yml @@ -1,18 +1,3 @@ -- name: create administrative user siteRootAdmin port=yes - mongodb_user: - database: admin - name: "{{ item.name }}" - password: "{{ item.password }}" - roles: "{{ item.roles }}" - login_host: 127.0.0.1 - login_port: "{{ ansible_local.mongodb.mongodb.mongodb_login_port }}" - with_items: - - { - name: "{{ mongodb_root_admin_name }}", - password: "{{ mongodb_root_admin_password }}", - roles: "root" - } - - name: create administrative user siteUserAdmin port=yes mongodb_user: database: admin @@ -28,6 +13,23 @@ roles: "userAdminAnyDatabase" } +- name: create administrative user siteRootAdmin port=yes + mongodb_user: + database: admin + name: "{{ item.name }}" + password: "{{ item.password }}" + roles: "{{ item.roles }}" + login_host: 127.0.0.1 + login_port: "{{ ansible_local.mongodb.mongodb.mongodb_login_port }}" + login_user: "{{ mongodb_user_admin_name }}" + login_password: "{{ mongodb_user_admin_password }}" + with_items: + - { + name: "{{ mongodb_root_admin_name }}", + password: "{{ mongodb_root_admin_password }}", + roles: "root" + } + - name: create normal users mongodb_user: database: "{{ item.database }}"