franklinkim.mongodb
is an Ansible role which:
- installs mongodb
- configures mongodb
- configures logrotate
Using ansible-galaxy
:
$ ansible-galaxy install franklinkim.mongodb
Using requirements.yml
:
- src: franklinkim.mongodb
Using git
:
$ git clone https://github.com/weareinteractive/ansible-mongodb.git franklinkim.mongodb
- Ansible >= 1.9
Here is a list of all the default variables for this role, which are also available in defaults/main.yml
.
---
# Mongodb version
mongodb_version: 3.4
# APT key id
mongodb_apt_key_id: 0C49F3730359A14518585931BC711F9BA15703C6
# APT key server
mongodb_apt_key_server: keyserver.ubuntu.com
# APT repository
mongodb_apt_repository: "deb http://repo.mongodb.org/apt/{{ ansible_distribution|lower }} {{ ansible_distribution_release }}/mongodb-org/{{ mongodb_version }} {{ 'main' if ansible_distribution == 'debian' else 'multiverse' }}"
# User
mongodb_user: mongodb
# Package
mongodb_package: mongodb-org
# Run with security
mongodb_conf_auth: no
# Directory for datafiles
mongodb_conf_dbpath: /var/lib/mongodb
# Log file to send write to instead of stdout
mongodb_conf_logpath: /var/log/mongodb/mongod.log
# Specify port number
mongodb_conf_port: 27017
# Comma separated list of ip addresses to listen on
mongodb_conf_bind_ip: 127.0.0.1
# Enable journaling
mongodb_conf_journal: no
# Append to logpath instead of over-writing
mongodb_conf_logappend: yes
# Limits each database to a certain number of files
mongodb_conf_quota: no
# Disable scripting engine
mongodb_conf_noscripting: no
# Do not allow table scans
mongodb_conf_notablescan: no
# Periodically show cpu and iowait utilization
mongodb_conf_cpu: no
# Enable http interface
mongodb_conf_httpinterface: no
# Inspect all client data for validity on receipt
mongodb_conf_objcheck: no
# Disable data file preallocation.
mongodb_conf_noprealloc: no
# start on boot
mongodb_service_enabled: yes
# current state: started, stopped
mongodb_service_state: started
These are the handlers that are defined in handlers/main.yml
.
---
- name: reload mongodb
service: name=mongod state=reloaded
when: mongodb_service_state != 'stopped'
- name: restart mongodb
service: name=mongod state=restarted
when: mongodb_service_state != 'stopped'
This is an example playbook:
---
- hosts: all
become: yes
roles:
- franklinkim.mongodb
vars:
mongodb_conf_bind_ip: 0.0.0.0
$ git clone https://github.com/weareinteractive/ansible-mongodb.git
$ cd ansible-mongodb
$ make test
In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests and examples for any new or changed functionality.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Note: To update the README.md
file please install and run ansible-role
:
$ gem install ansible-role
$ ansible-role docgen
Copyright (c) We Are Interactive under the MIT license.