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 >= 2.4
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.6
# APT key id
mongodb_apt_key_id: 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
# 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
# For documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
mongodb_conf_defaults:
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
storage:
dbPath: /var/lib/mongo
journal:
enabled: true
processManagement:
fork: true
pidFilePath: /var/run/mongodb/mongod.pid
timeZoneInfo: /usr/share/zoneinfo
net:
port: 27017
bindIp: 127.0.0.1
mongodb_conf: "{{ mongodb_conf_defaults | combine({}, recursive=True) }}"
# 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
roles:
- franklinkim.mongodb
vars:
mongodb_conf: "{{ mongodb_conf_defaults | combine({'net':{'bindIp':'0.0.0.0'}}, recursive=True) }}"
$ 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.