Skip to content
Snippets Groups Projects
Commit 78aee8bb authored by Mathieu Leguay's avatar Mathieu Leguay
Browse files

[DLAB-4126] Fix authentication detection for mongo

parent d915c01e
No related branches found
No related tags found
1 merge request!1Feature/design/1
--- ---
- name: Check if authent is enabled
command: "mongo --host mongodb://{{ mongod_uri }}/admin?replicaSet={{ mongod_replicaset_name }} -u {{ mongodb.admin.user }} -p {{ mongodb.admin.password }} --quiet --eval 'db.help()'"
register: mongo_authent_enabled
failed_when: false
no_log: "{{ hide_passwords_during_deploy }}"
when: mongodb.docker is not defined or not mongodb.docker.enable
- name: Load script in database (docker)
shell: "docker exec --tty {{ mongodb.docker.image_name }} /bin/bash -c \"mongo --host mongodb://{{ mongod_uri }}/admin?replicaSet={{ mongod_replicaset_name }} -u {{ mongodb.admin.user }} -p {{ mongodb.admin.password }} --quiet --eval 'db.help()'\""
no_log: "{{ hide_passwords_during_deploy }}"
failed_when: false
register: mongo_authent_enabled
when: mongodb.docker is defined and mongodb.docker.enable
# Set mongo_no_auth facts # Set mongo_no_auth facts
- name: Set default mongo facts - name: Set default mongo facts
set_fact: set_fact:
mongo_credentials: "" mongo_credentials: ""
mongo_no_auth: false mongo_no_auth: false
- name: Set mongo_no_auth fact to true - block:
set_fact: - name: Check if authent is enabled
mongo_no_auth: true command: "mongo --host mongodb://{{ mongod_uri }}/admin?replicaSet={{ mongod_replicaset_name }} -u {{ mongodb.admin.user }} -p {{ mongodb.admin.password }} --quiet --eval 'db.help()'"
when: "mongo_authent_enabled.rc != 0" register: mongo_authent_enabled
failed_when: false
no_log: "{{ hide_passwords_during_deploy }}"
- name: Set mongo_no_auth fact to true
set_fact:
mongo_no_auth: true
when: "mongo_authent_enabled.rc != 0"
when: mongodb.docker is not defined or not mongodb.docker.enable
- block:
- name: Load script in database (docker)
shell: "docker exec --tty {{ mongodb.docker.image_name }} /bin/bash -c \"mongo --host mongodb://{{ mongod_uri }}/admin?replicaSet={{ mongod_replicaset_name }} -u {{ mongodb.admin.user }} -p {{ mongodb.admin.password }} --quiet --eval 'db.help()'\""
no_log: "{{ hide_passwords_during_deploy }}"
failed_when: false
register: mongo_authent_enabled
- name: Set mongo_no_auth fact to true
set_fact:
mongo_no_auth: true
when: "mongo_authent_enabled.rc != 0"
when: mongodb.docker is defined and mongodb.docker.enable
# When authentication is required, we set mongodb admin credentials # When authentication is required, we set mongodb admin credentials
- name: Set mongodb authentication credentials - name: Set mongodb authentication credentials
set_fact: set_fact:
mongo_credentials: " -u {{ mongodb.admin.user }} -p {{ mongodb.admin.password }} --authenticationDatabase {{ mongodb.admin.db }} " mongo_credentials: " -u {{ mongodb.admin.user }} -p {{ mongodb.admin.password }} --authenticationDatabase {{ mongodb.admin.db }} "
when: "mongo_authent_enabled.rc == 0" when: not mongo_no_auth
no_log: "{{ hide_passwords_during_deploy }}" no_log: "{{ hide_passwords_during_deploy }}"
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment