Refactoring. Support MMS
This commit is contained in:
parent
e854d94231
commit
356a1b5b61
59
README.md
59
README.md
|
@ -6,8 +6,9 @@ Stouts.mongo
|
||||||
|
|
||||||
Ansible role which manage [MongoDB](http://www.mongodb.org/)
|
Ansible role which manage [MongoDB](http://www.mongodb.org/)
|
||||||
|
|
||||||
* Install and configure;
|
* Install and configure the MongoDB;
|
||||||
* Provide hanlers for restart and reload;
|
* Provide hanlers for restart and reload;
|
||||||
|
* Setup MMS authomation agent;
|
||||||
|
|
||||||
#### Variables
|
#### Variables
|
||||||
|
|
||||||
|
@ -15,32 +16,40 @@ Ansible role which manage [MongoDB](http://www.mongodb.org/)
|
||||||
|
|
||||||
mongodb_enabled: yes
|
mongodb_enabled: yes
|
||||||
mongodb_packages:
|
mongodb_packages:
|
||||||
- python-selinux
|
- python-selinux
|
||||||
- python-pymongo
|
- python-pymongo
|
||||||
- mongodb-org
|
- mongodb-org
|
||||||
|
|
||||||
mongodb_conf:
|
mongodb_user: mongodb
|
||||||
auth: "false"
|
|
||||||
bind_ip: 127.0.0.1
|
|
||||||
cpu: "true"
|
|
||||||
dbpath: /var/lib/mongodb/
|
|
||||||
# diaglog: 0 # deprecated
|
|
||||||
logappend: "true"
|
|
||||||
logpath: /var/log/mongodb/mongod.log
|
|
||||||
noauth: "true"
|
|
||||||
nohints: "false"
|
|
||||||
nohttpinterface: "false"
|
|
||||||
nojournal: "true"
|
|
||||||
noprealloc: "false"
|
|
||||||
noscripting: "false"
|
|
||||||
notablescan: "false"
|
|
||||||
objcheck: "false"
|
|
||||||
port: 27017
|
|
||||||
quota: "false"
|
|
||||||
# replSet: "" # Set for enable replication
|
|
||||||
verbose: "true"
|
|
||||||
vvvv: "true"
|
|
||||||
|
|
||||||
|
mongodb_conf_auth: no # Run with security
|
||||||
|
mongodb_conf_bind_ip: 127.0.0.1 # Comma separated list of ip addresses to listen on
|
||||||
|
mongodb_conf_cpu: yes # Periodically show cpu and iowait utilization
|
||||||
|
mongodb_conf_dbpath: /data/db # Directory for datafiles
|
||||||
|
mongodb_conf_fork: no # Fork server process
|
||||||
|
mongodb_conf_httpinterface: no # Enable http interface
|
||||||
|
mongodb_conf_ipv6: no # Enable IPv6 support (disabled by default)
|
||||||
|
mongodb_conf_journal: no # Enable journaling
|
||||||
|
mongodb_conf_logappend: yes # Append to logpath instead of over-writing
|
||||||
|
mongodb_conf_logpath: /var/log/mongodb/mongod.log # Log file to send write to instead of stdout
|
||||||
|
mongodb_conf_maxConns: 1000000 # Max number of simultaneous connections
|
||||||
|
mongodb_conf_noprealloc: no # Disable data file preallocation
|
||||||
|
mongodb_conf_noscripting: no # Disable scripting engine
|
||||||
|
mongodb_conf_notablescan: no # Do not allow table scans
|
||||||
|
mongodb_conf_port: 27017 # Specify port number
|
||||||
|
mongodb_conf_quota: no # Limits each database to a certain number of files
|
||||||
|
mongodb_conf_quotaFiles: 8 # Number of quota files
|
||||||
|
mongodb_conf_syslog: no # Log to system's syslog facility instead of file
|
||||||
|
|
||||||
|
# Replica set options:
|
||||||
|
mongodb_conf_replSet: # Enable replication <setname>[/<optionalseedhostlist>]
|
||||||
|
mongodb_conf_replIndexPrefetch: all # specify index prefetching behavior (if secondary) [none|_id_only|all]
|
||||||
|
|
||||||
|
# MMS Agent
|
||||||
|
mongodb_mms_agent_pkg: https://mms.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager_1.4.2.783-1_amd64.deb
|
||||||
|
mongodb_mms_group_id: ""
|
||||||
|
mongodb_mms_api_key: ""
|
||||||
|
mongodb_mms_base_url: https://mms.mongodb.com
|
||||||
|
|
||||||
# Log rotation
|
# Log rotation
|
||||||
mongodb_logrotate: yes # Rotate mongodb logs.
|
mongodb_logrotate: yes # Rotate mongodb logs.
|
||||||
|
|
|
@ -2,29 +2,40 @@
|
||||||
|
|
||||||
mongodb_enabled: yes
|
mongodb_enabled: yes
|
||||||
mongodb_packages:
|
mongodb_packages:
|
||||||
- python-selinux
|
- python-selinux
|
||||||
- python-pymongo
|
- python-pymongo
|
||||||
- mongodb-org
|
- mongodb-org
|
||||||
|
|
||||||
mongodb_conf_auth: "false"
|
mongodb_user: mongodb
|
||||||
mongodb_conf_bind_ip: 127.0.0.1
|
|
||||||
mongodb_conf_cpu: "true"
|
|
||||||
mongodb_conf_dbpath: /var/lib/mongodb/
|
|
||||||
mongodb_conf_logappend: "true"
|
|
||||||
mongodb_conf_logpath: /var/log/mongodb/mongod.log
|
|
||||||
mongodb_conf_noauth: "true"
|
|
||||||
mongodb_conf_nohints: "false"
|
|
||||||
mongodb_conf_nohttpinterface: "false"
|
|
||||||
mongodb_conf_nojournal: "true"
|
|
||||||
mongodb_conf_noprealloc: "false"
|
|
||||||
mongodb_conf_noscripting: "false"
|
|
||||||
mongodb_conf_notablescan: "false"
|
|
||||||
mongodb_conf_objcheck: "false"
|
|
||||||
mongodb_conf_port: 27017
|
|
||||||
mongodb_conf_quota: "false"
|
|
||||||
mongodb_conf_verbose: "true"
|
|
||||||
mongodb_conf_vvvv: "true"
|
|
||||||
|
|
||||||
|
mongodb_conf_auth: no # Run with security
|
||||||
|
mongodb_conf_bind_ip: 127.0.0.1 # Comma separated list of ip addresses to listen on
|
||||||
|
mongodb_conf_cpu: yes # Periodically show cpu and iowait utilization
|
||||||
|
mongodb_conf_dbpath: /data/db # Directory for datafiles
|
||||||
|
mongodb_conf_fork: no # Fork server process
|
||||||
|
mongodb_conf_httpinterface: no # Enable http interface
|
||||||
|
mongodb_conf_ipv6: no # Enable IPv6 support (disabled by default)
|
||||||
|
mongodb_conf_journal: no # Enable journaling
|
||||||
|
mongodb_conf_logappend: yes # Append to logpath instead of over-writing
|
||||||
|
mongodb_conf_logpath: /var/log/mongodb/mongod.log # Log file to send write to instead of stdout
|
||||||
|
mongodb_conf_maxConns: 1000000 # Max number of simultaneous connections
|
||||||
|
mongodb_conf_noprealloc: no # Disable data file preallocation
|
||||||
|
mongodb_conf_noscripting: no # Disable scripting engine
|
||||||
|
mongodb_conf_notablescan: no # Do not allow table scans
|
||||||
|
mongodb_conf_port: 27017 # Specify port number
|
||||||
|
mongodb_conf_quota: no # Limits each database to a certain number of files
|
||||||
|
mongodb_conf_quotaFiles: 8 # Number of quota files
|
||||||
|
mongodb_conf_syslog: no # Log to system's syslog facility instead of file
|
||||||
|
|
||||||
|
# Replica set options:
|
||||||
|
mongodb_conf_replSet: # Enable replication <setname>[/<optionalseedhostlist>]
|
||||||
|
mongodb_conf_replIndexPrefetch: all # specify index prefetching behavior (if secondary) [none|_id_only|all]
|
||||||
|
|
||||||
|
# MMS Agent
|
||||||
|
mongodb_mms_agent_pkg: https://mms.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager_1.4.2.783-1_amd64.deb
|
||||||
|
mongodb_mms_group_id: ""
|
||||||
|
mongodb_mms_api_key: ""
|
||||||
|
mongodb_mms_base_url: https://mms.mongodb.com
|
||||||
|
|
||||||
# Log rotation
|
# Log rotation
|
||||||
mongodb_logrotate: yes # Rotate mongodb logs.
|
mongodb_logrotate: yes # Rotate mongodb logs.
|
||||||
|
|
|
@ -5,3 +5,6 @@
|
||||||
|
|
||||||
- name: mongodb restart
|
- name: mongodb restart
|
||||||
service: name=mongod state=restarted
|
service: name=mongod state=restarted
|
||||||
|
|
||||||
|
- name: mongodb-mms-automation-agent restart
|
||||||
|
service: name=mongodb-mms-automation-agent state=restarted
|
||||||
|
|
|
@ -5,7 +5,7 @@ dependencies: []
|
||||||
galaxy_info:
|
galaxy_info:
|
||||||
author: klen
|
author: klen
|
||||||
company: Stouts
|
company: Stouts
|
||||||
description: Manage mongodb
|
description: Manage MongoDB (MMS)
|
||||||
license: MIT
|
license: MIT
|
||||||
platforms:
|
platforms:
|
||||||
- name: Ubuntu
|
- name: Ubuntu
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
when: mongodb_logrotate
|
when: mongodb_logrotate
|
||||||
|
|
||||||
- name: Create mongodb user
|
- name: Create mongodb user
|
||||||
user: name=mongodb group=mongodb
|
user: name={{mongodb_user}} group={{mongodb_user}}
|
||||||
|
|
||||||
- name: Configure database directory
|
- name: Configure database directory
|
||||||
file: state=directory path={{ mongodb_conf_dbpath }} owner=mongodb group=mongodb mode=0755
|
file: state=directory path={{ mongodb_conf_dbpath }} owner={{mongodb_user}} group={{mongodb_user}} mode=0755
|
||||||
|
|
||||||
- name: Configure logs
|
- name: Configure logs
|
||||||
file: state=file path={{ mongodb_conf_logpath }} owner=mongodb group=mongodb mode=0644
|
file: state=file path={{ mongodb_conf_logpath }} owner={{mongodb_user}} group={{mongodb_user}} mode=0644
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: Install MMS agent pt. 1
|
||||||
|
get_url: url={{mongodb_mms_agent_pkg}} dest={{mongodb_conf_dbpath}}/mms-agent.deb
|
||||||
|
register: mongodb_mms_agent_loaded
|
||||||
|
|
||||||
|
- name: Install MMS agent pt. 2
|
||||||
|
apt: deb={{mongodb_conf_dbpath}}/mms-agent.deb
|
||||||
|
when: mongodb_mms_agent_loaded.changed
|
||||||
|
|
||||||
|
- name: Configure the MMS agent pt. 1
|
||||||
|
file: state=directory path=/etc/mongodb-mms owner={{mongodb_user}} group={{mongodb_user}} mode=0755
|
||||||
|
|
||||||
|
- name: Configure the MMS agent pt. 2
|
||||||
|
template: src=automation-agent.config.j2 dest=/etc/mongodb-mms/automation-agent.config
|
||||||
|
notify: mongodb-mms-automation-agent restart
|
||||||
|
|
||||||
|
- name: Ensure that the MMS agent is started
|
||||||
|
service: name=mongodb-mms-automation-agent state=started enabled=yes
|
|
@ -8,3 +8,6 @@
|
||||||
- name: Ensure mongodb is started
|
- name: Ensure mongodb is started
|
||||||
service: name=mongod state=started enabled=yes
|
service: name=mongod state=started enabled=yes
|
||||||
changed_when: False
|
changed_when: False
|
||||||
|
|
||||||
|
- include: mms-agent.yml
|
||||||
|
when: mongodb_mms_api_key != ""
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
mmsApiKey={{ mongodb_mms_api_key }}
|
||||||
|
mmsBaseUrl={{ mongodb_mms_base_url }}
|
||||||
|
mmsGroupId={{ mongodb_mms_group_id }}
|
|
@ -1,20 +1,26 @@
|
||||||
# {{ ansible_managed }}
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
auth = {{ mongodb_conf_auth }}
|
auth = {{ mongodb_conf_auth|to_nice_json }}
|
||||||
bind_ip = {{ mongodb_conf_bind_ip }}
|
bind_ip = {{ mongodb_conf_bind_ip }}
|
||||||
cpu = {{ mongodb_conf_cpu }}
|
cpu = {{ mongodb_conf_cpu|to_nice_json }}
|
||||||
dbpath = {{ mongodb_conf_dbpath }}
|
dbpath = {{ mongodb_conf_dbpath }}
|
||||||
logappend = {{ mongodb_conf_logappend }}
|
fork = {{ mongodb_conf_fork|to_nice_json }}
|
||||||
|
httpinterface = {{ mongodb_conf_httpinterface|to_nice_json }}
|
||||||
|
ipv6 = {{ mongodb_conf_ipv6|to_nice_json }}
|
||||||
|
journal = {{ mongodb_conf_journal|to_nice_json }}
|
||||||
|
logappend = {{ mongodb_conf_logappend|to_nice_json }}
|
||||||
logpath = {{ mongodb_conf_logpath }}
|
logpath = {{ mongodb_conf_logpath }}
|
||||||
noauth = {{ mongodb_conf_noauth }}
|
maxConns = {{ mongodb_conf_maxConns }}
|
||||||
nohints = {{ mongodb_conf_nohints }}
|
noprealloc = {{ mongodb_conf_noprealloc|to_nice_json }}
|
||||||
nohttpinterface = {{ mongodb_conf_nohttpinterface }}
|
noscripting = {{ mongodb_conf_noscripting|to_nice_json }}
|
||||||
nojournal = {{ mongodb_conf_nojournal }}
|
notablescan = {{ mongodb_conf_notablescan|to_nice_json }}
|
||||||
noprealloc = {{ mongodb_conf_noprealloc }}
|
|
||||||
noscripting = {{ mongodb_conf_noscripting }}
|
|
||||||
notablescan = {{ mongodb_conf_notablescan }}
|
|
||||||
objcheck = {{ mongodb_conf_objcheck }}
|
|
||||||
port = {{ mongodb_conf_port }}
|
port = {{ mongodb_conf_port }}
|
||||||
quota = {{ mongodb_conf_quota }}
|
quota = {{ mongodb_conf_quota|to_nice_json }}
|
||||||
verbose = {{ mongodb_conf_verbose }}
|
quotaFiles = {{ mongodb_conf_quotaFiles }}
|
||||||
vvvv = {{ mongodb_conf_vvvv }}
|
syslog = {{ mongodb_conf_syslog|to_nice_json }}
|
||||||
|
|
||||||
|
{% if mongodb_conf_replSet %}
|
||||||
|
# Replica set options:
|
||||||
|
replSet = {{ mongodb_conf_replSet }}
|
||||||
|
replIndexPrefetch = {{ mongodb_conf_replIndexPrefetch }}
|
||||||
|
{% endif %}
|
||||||
|
|
Loading…
Reference in New Issue