diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..92e8e1a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,26 @@ +--- +language: python +python: "2.7" +before_install: + - sudo apt-get update -qq + - sudo apt-get install -qq python-apt python-pycurl +install: + - pip install ansible>=1.6.0 +script: + - echo localhost > inventory + + # Check syntax + - ansible-playbook --syntax-check -i inventory test.yml + + # First run + - ansible-playbook -i inventory test.yml --connection=local --sudo + + # Second run Idempotence test + - > + ansible-playbook -i inventory test.yml --connection=local --sudo + | grep -q 'changed=0.*failed=0' + && (echo 'Idempotence test: pass' && exit 0) + || (echo 'Idempotence test: fail' && exit 1) + + # Check fog nginx is running + - ps -ef | grep [m]ongod || exit 1 diff --git a/README.md b/README.md index 2a926e3..2a7461b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,61 @@ Stouts.mongo ============ -Ansible role which manage MongoDB +[![Build Status](https://travis-ci.org/Stouts/Stouts.nginx.png)](https://travis-ci.org/Stouts/Stouts.mongodb) + +Ansible role which manage [MongoDB](http://www.mongodb.org/) + +* Install and configure; +* Provide hanlers for restart and reload; + +#### Variables + +```yaml +mongodb_packages: + - python-selinux + - python-pymongo + - 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 +``` + +#### Usage + +Add `Stouts.mongodb` to your roles and set vars in your playbook file. + +Example: + +```yaml + +- hosts: all + + roles: + - Stouts.mongodb + + vars: + port: 27400 +``` + +#### License + +Licensed under the MIT License. See the LICENSE file for details. + +#### Feedback, bug-reports, requests, ... + +Are [welcome](https://github.com/Stouts/Stouts.mongodb/issues)! diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..483a0c4 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,7 @@ +--- + +- name: mongodb reload + service: name=mongodb state=reloaded + +- name: mongodb restart + service: name=mongodb state=restarted diff --git a/tasks/configure.yml b/tasks/configure.yml index 14af955..ef0646c 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -1,4 +1,5 @@ --- - - name: Configure mongodb - template: src=mongodb.conf.j2 dest=/etc/mongodb.conf owner=root group=root mode=0644 +- name: Configure mongodb + template: src=mongodb.conf.j2 dest=/etc/mongodb.conf owner=root group=root mode=0644 + notify: mongodb reload diff --git a/test.yml b/test.yml new file mode 100644 index 0000000..0ddbdeb --- /dev/null +++ b/test.yml @@ -0,0 +1,7 @@ +- hosts: all + tasks: + - include: tasks/main.yml + handlers: + - include: handlers/main.yml + vars_files: + - defaults/main.yml