Update configuration management using Ansible templates to be more flexible

This commit is contained in:
Guillaume Dedrie 2014-08-25 16:10:18 +02:00
parent 28916916ee
commit c816661c18
4 changed files with 53 additions and 129 deletions

View File

@ -18,22 +18,29 @@ mongodb_packages:
- mongodb-10gen
# Configuration
mongodb_dbpath: /var/lib/mongodb
mongodb_logpath: /var/log/mongodb/mongodb.log
mongodb_port: 27017
mongodb_nojournal: true
mongodb_cpu: true
mongodb_verbose: true
mongodb_quota: false
mongodb_auth: false
mongodb_objcheck: false
mongodb_diaglog: 0
mongodb_nohints: false
mongodb_nohttpinterface: false
mongodb_noscripting: false
mongodb_notablescan: false
mongodb_noprealloc: false
mongodb_replSet: "" # Set for enable replication
# A list of hashes that are used to configure MongoDB. Any valid configuration parameters can be defined here.
mongodb_conf:
dbpath: /var/lib/mongodb/
logpath: /var/log/mongodb/mongod.log
logappend: "true"
port: 27017
bind_ip: 127.0.0.1
nojournal: "true"
# auth: "true"
noauth: "true"
cpu: "true"
verbose: "true"
vvvv: "true"
quota: "false"
auth: "false"
objcheck: "false"
# diaglog: 0 # deprecated
nohints: "false"
nohttpinterface: "false"
noscripting: "false"
notablescan: "false"
noprealloc: "false"
# replSet: "" # Set for enable replication
# Log rotation
mongodb_logrotate: yes # Rotate mongodb logs.

View File

@ -6,23 +6,29 @@ mongodb_packages:
- python-pymongo
- mongodb-org
# Configuration
mongodb_dbpath: /var/lib/mongodb
mongodb_logpath: /var/log/mongodb/mongod.log
mongodb_port: 27017
mongodb_nojournal: true
mongodb_cpu: true
mongodb_verbose: true
mongodb_quota: false
mongodb_auth: false
mongodb_objcheck: false
mongodb_diaglog: 0
mongodb_nohints: false
mongodb_nohttpinterface: false
mongodb_noscripting: false
mongodb_notablescan: false
mongodb_noprealloc: false
mongodb_replSet: "" # Set for enable replication
mongodb_conf:
dbpath: /var/lib/mongodb/
logpath: /var/log/mongodb/mongod.log
logappend: "true"
port: 27017
bind_ip: 127.0.0.1
nojournal: "true"
# auth: "true"
noauth: "true"
cpu: "true"
verbose: "true"
vvvv: "true"
quota: "false"
auth: "false"
objcheck: "false"
# diaglog: 0 # deprecated
nohints: "false"
nohttpinterface: "false"
noscripting: "false"
notablescan: "false"
noprealloc: "false"
# replSet: "" # Set for enable replication
# Log rotation
mongodb_logrotate: yes # Rotate mongodb logs.

View File

@ -1,8 +1,8 @@
# This file was generated by Ansible for {{ ansible_fqdn }}
# Do NOT modify this file by hand!
{{mongodb_logpath}} {
{% for option in mongodb_logrotate_options %}
{{ mongodb_conf.logpath }} {
{% for option in mongodb_logrotate_options %}
{{ option }}
{% endfor %}
{% endfor %}
}

View File

@ -1,94 +1,5 @@
# mongodb.conf
# {{ ansible_managed }}
# This file was generated by Ansible for {{ ansible_fqdn }}
# Do NOT modify this file by hand!
# Where to store the data.
# Note: if you run mongodb as a non-root user (recommended) you may
# need to create and set permissions for this directory manually,
# e.g., if the parent directory isn't mutable by the mongodb user.
dbpath={{mongodb_dbpath}}
#where to log
logpath={{mongodb_logpath}}
logappend=true
port = {{mongodb_port}}
# Disables write-ahead journaling
nojournal = {{'true' if mongodb_nojournal else 'false'}}
# Enables periodic logging of CPU utilization and I/O wait
cpu = {{'true' if mongodb_cpu else 'false'}}
# Verbose logging output.
verbose = {{'true' if mongodb_verbose else 'false'}}
# Enable db quota management
quota = {{'true' if mongodb_quota else 'false'}}
# Turn on/off security. Off is currently the default
{% if mongodb_auth %}
auth = true
{% else %}
noauth = true
{% endif %}
# Inspect all client data for validity on receipt (useful for
# developing drivers)
objcheck = {{'true' if mongodb_objcheck else 'false'}}
# Set oplogging level where n is
# 0=off (default)
# 1=W
# 2=R
# 3=both
# 7=W+some reads
diaglog = {{mongodb_diaglog}}
# Ignore query hints
nohints = {{'true' if mongodb_nohints else 'false'}}
# Disable the HTTP interface (Defaults to localhost:28017).
nohttpinterface = {{'true' if mongodb_nohttpinterface else 'false'}}
# Turns off server-side scripting. This will result in greatly limited
# functionality
noscripting = {{'true' if mongodb_noscripting else 'false'}}
# Turns off table scans. Any query that would do a table scan fails.
notablescan = {{'true' if mongodb_notablescan else 'false'}}
# Disable data file preallocation.
noprealloc = {{'true' if mongodb_noprealloc else 'false'}}
# Specify .ns file size for new databases.
# nssize = <size>
# Accout token for Mongo monitoring server.
#mms-token = <token>
# Server name for Mongo monitoring server.
#mms-name = <server-name>
# Ping interval for Mongo monitoring server.
#mms-interval = <seconds>
# Replication Options
# in master/slave replicated mongo databases, specify here whether
# this is a slave or master
#slave = true
#source = master.example.com
# Slave only: specify a single database to replicate
#only = master.example.com
# or
#master = true
#source = slave.example.com
# in replica set configuration, specify the name of the replica set
{% if mongodb_replSet != "" %}
# replSet = setname
{% endif %}
{% for k, v in mongodb_conf.iteritems() %}
{{ k }} = {{ v }}
{% endfor %}