mongodb: manage the keyfile needed by a cluster configuration.

This commit is contained in:
Andrea Dell'Amico 2020-02-12 18:17:42 +01:00
parent f78a20bab8
commit bb88b7519a
4 changed files with 17 additions and 2 deletions

View File

@ -86,3 +86,4 @@ mongodb_ganglia_auth_enabled: False
mongodb_ganglia_db: admin mongodb_ganglia_db: admin
mongodb_ganglia_auth_mechanism: MONGODB-CR mongodb_ganglia_auth_mechanism: MONGODB-CR
# User and password are stored in the variables mongo_monitoring_u and mongo_monitoring_pwd # User and password are stored in the variables mongo_monitoring_u and mongo_monitoring_pwd

View File

@ -5,5 +5,6 @@
- name: Restart mongodb - name: Restart mongodb
service: name=mongodb state=restarted service: name=mongodb state=restarted
ignore_errors: true
when: "'{{ mongodb_start_server }}' == 'yes'" when: "'{{ mongodb_start_server }}' == 'yes'"

View File

@ -3,3 +3,4 @@
- import_tasks: mongodb-letsencrypt-acmetool.yml - import_tasks: mongodb-letsencrypt-acmetool.yml
when: mongodb_ssl_letsencrypt_managed when: mongodb_ssl_letsencrypt_managed

View File

@ -37,7 +37,7 @@
template: src=mongod-{{ mongodb_version }}.conf.j2 dest=/etc/mongod.conf owner=root group=root mode=0444 backup=yes template: src=mongod-{{ mongodb_version }}.conf.j2 dest=/etc/mongod.conf owner=root group=root mode=0444 backup=yes
when: mongodb_install_conf when: mongodb_install_conf
notify: Restart mongodb notify: Restart mongodb
tags: [ 'mongodb', 'mongodb_update_conf' ] tags: [ 'mongodb', 'mongodb_update_conf', 'mongodb_keyfile' ]
when: when:
- mongodb_install_server - mongodb_install_server
@ -75,7 +75,7 @@
- name: Install/Update the mongodb configuration - name: Install/Update the mongodb configuration
template: src=mongod-{{ mongodb_version }}.conf.j2 dest=/etc/mongodb.conf owner=root group=root mode=0444 backup=yes template: src=mongod-{{ mongodb_version }}.conf.j2 dest=/etc/mongodb.conf owner=root group=root mode=0444 backup=yes
when: mongodb_install_conf when: mongodb_install_conf
notify: Restart mongodb notify: Restart mongod
tags: [ 'mongodb', 'mongodb_update_conf' ] tags: [ 'mongodb', 'mongodb_update_conf' ]
when: when:
@ -100,6 +100,18 @@
when: mongodb_install_server when: mongodb_install_server
tags: mongodb tags: mongodb
- block:
- name: Create the mongodb conf directory
file: dest={{ mongodb_conf_path }} state=directory owner={{ mongodb_user }} group={{ mongodb_group }} mode=0755
- name: Install the keyfile if it is a replica cluster
copy: src='vault-{{ mongodb_replicaset }}-keyfile' dest={{ mongodb_conf_path }}/{{ mongodb_keyfile_name }} owner=mongodb group=mongodb mode=0400
notify: Restart mongod
when: mongodb_cluster_enabled
tags: [ 'mongodb', 'mongodb_keyfile', 'mongodb_update_conf' ]
- block: - block:
- name: Ensure mongodb is started and enabled - name: Ensure mongodb is started and enabled
service: name=mongodb state=started enabled=yes service: name=mongodb state=started enabled=yes