Skip to content

Commit 68e1860

Browse files
authored
Merge pull request #216 from rohit-gohri/extra_settings
add support for extending config
2 parents 4531d91 + 2342a17 commit 68e1860

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ mongodb_set_parameters:
108108
"authenticationMechanisms": "SCRAM-SHA-1,MONGODB-CR",
109109
}
110110

111+
## Extend config with arbitrary values
112+
# Example :
113+
mongodb_config:
114+
replication:
115+
- "enableMajorityReadConcern: false"
116+
111117
# MMS Agent
112118
mongodb_mms_agent_pkg: https://cloud.mongodb.com/download/agent/monitoring/mongodb-mms-monitoring-agent_7.2.0.488-1_amd64.ubuntu1604.deb
113119
mongodb_mms_group_id: ""

defaults/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,6 @@ mongodb_root_backup_password: passw0rd
124124

125125
# setParameter config
126126
mongodb_set_parameters:
127+
128+
# custom config options
129+
mongodb_config:

templates/mongod.conf.j2

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,22 @@ net:
1313
ssl:
1414
mode: {{ mongodb_net_ssl_mode }}
1515
PEMKeyFile: {{ mongodb_net_ssl_pemfile }}
16+
{%- endif %}
17+
{%- if mongodb_config['net'] is defined and mongodb_config['net'] is iterable %}
18+
{%- for item in mongodb_config['net'] -%}
19+
{{ item }}
20+
{% endfor %}
1621
{% endif %}
1722

1823
processManagement:
1924
fork: {{ mongodb_processmanagement_fork | to_nice_json}}
2025
{% if mongodb_pidfile_path is defined and mongodb_pidfile_path != '' -%}
2126
pidFilePath: {{ mongodb_pidfile_path }}
27+
{%- endif %}
28+
{%- if mongodb_config['processManagement'] is defined and mongodb_config['processManagement'] is iterable %}
29+
{%- for item in mongodb_config['processManagement'] -%}
30+
{{ item }}
31+
{% endfor %}
2232
{% endif %}
2333

2434
{% if mongodb_replication_replset -%}
@@ -27,6 +37,11 @@ replication:
2737
replSetName: {{ mongodb_replication_replset }}
2838
{% if mongodb_storage_engine == 'mmapv1' -%}
2939
secondaryIndexPrefetch: {{ mongodb_replication_replindexprefetch }}
40+
{%- endif %}
41+
{%- if mongodb_config['replication'] is defined and mongodb_config['replication'] is iterable %}
42+
{%- for item in mongodb_config['replication'] -%}
43+
{{ item }}
44+
{% endfor %}
3045
{% endif %}
3146
{% endif %}
3247

@@ -36,6 +51,11 @@ security:
3651
keyFile: {{ mongodb_security_keyfile }}
3752
{% endif -%}
3853
javascriptEnabled: {{ mongodb_security_javascript_enabled | to_nice_json }}
54+
{%- if mongodb_config['security'] is defined and mongodb_config['security'] is iterable %}
55+
{%- for item in mongodb_config['security'] -%}
56+
{{ item }}
57+
{% endfor %}
58+
{% endif %}
3959

4060
storage:
4161
dbPath: {{ mongodb_storage_dbpath }}
@@ -57,6 +77,11 @@ storage:
5777
cacheSizeGB: {{ mongodb_wiredtiger_cache_size }}
5878
{% endif -%}
5979
directoryForIndexes: {{ mongodb_wiredtiger_directory_for_indexes | to_nice_json }}
80+
{%- endif %}
81+
{%- if mongodb_config['storage'] is defined and mongodb_config['storage'] is iterable %}
82+
{%- for item in mongodb_config['storage'] -%}
83+
{{ item }}
84+
{% endfor %}
6085
{% endif %}
6186

6287
systemLog:
@@ -65,22 +90,37 @@ systemLog:
6590
logAppend: {{ mongodb_systemlog_logappend | to_nice_json }}
6691
logRotate: {{ mongodb_systemlog_logrotate }}
6792
path: {{ mongodb_systemlog_path }}
93+
{%- endif %}
94+
{%- if mongodb_config['systemLog'] is defined and mongodb_config['systemLog'] is iterable %}
95+
{%- for item in mongodb_config['systemLog'] -%}
96+
{{ item }}
97+
{% endfor %}
6898
{% endif %}
6999

70100
operationProfiling:
71101
slowOpThresholdMs: {{ mongodb_operation_profiling_slow_op_threshold_ms }}
72102
mode: {{ mongodb_operation_profiling_mode }}
103+
{%- if mongodb_config['operationProfiling'] is defined and mongodb_config['operationProfiling'] is iterable %}
104+
{%- for item in mongodb_config['operationProfiling'] -%}
105+
{{ item }}
106+
{% endfor %}
107+
{% endif %}
73108

74109
{% if mongodb_major_version is version("4.0", ">=") -%}
75110
cloud:
76111
monitoring:
77112
free:
78113
state: {{ mongodb_cloud_monitoring_free_state }}
79-
{% endif -%}
114+
{%- if mongodb_config['cloud'] is defined and mongodb_config['cloud'] is iterable %}
115+
{%- for item in mongodb_config['cloud'] -%}
116+
{{ item }}
117+
{% endfor %}
118+
{% endif %}
119+
{% endif %}
80120

81121
{% if mongodb_set_parameters -%}
82122
setParameter:
83123
{% for key, value in mongodb_set_parameters.items() -%}
84124
{{ key }}: {{ value }}
85-
{% endfor -%}
125+
{% endfor %}
86126
{% endif %}

0 commit comments

Comments
 (0)