Fixed issue #3

This commit is contained in:
Sergei Antipov 2015-03-02 16:07:44 +06:00
parent ec4de12ae7
commit d25113e8fa
2 changed files with 34 additions and 32 deletions

View File

@ -3,22 +3,6 @@
- include: auth_initialization_ald.yml - include: auth_initialization_ald.yml
when: ansible_local.mongodb.mongodb.mongodb_login_port is defined 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 - name: create administrative user siteUserAdmin
mongodb_user: mongodb_user:
database: admin database: admin
@ -35,6 +19,22 @@
register: useradmin_user_result register: useradmin_user_result
when: ansible_local.mongodb.mongodb.mongodb_login_port is undefined 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 - name: create normal users
mongodb_user: mongodb_user:
database: "{{ item.database }}" database: "{{ item.database }}"
@ -59,5 +59,5 @@
- name: Create facts file for mongodb - name: Create facts file for mongodb
copy: copy:
dest: /etc/ansible/facts.d/mongodb.fact 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 when: rootadmin_user_result|changed or useradmin_user_result|changed

View File

@ -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 - name: create administrative user siteUserAdmin port=yes
mongodb_user: mongodb_user:
database: admin database: admin
@ -28,6 +13,23 @@
roles: "userAdminAnyDatabase" 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 - name: create normal users
mongodb_user: mongodb_user:
database: "{{ item.database }}" database: "{{ item.database }}"