diff --git a/.bumpversion.cfg b/.bumpversion.cfg index d1d9d23..935c670 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,6 +1,6 @@ [bumpversion] commit = True -current_version = 1.3.3 +current_version = 1.3.4 tag = True tag_name = {new_version} diff --git a/README.md b/README.md index 8dbd8ae..489d4c6 100644 --- a/README.md +++ b/README.md @@ -64,10 +64,10 @@ Example: - hosts: all roles: - - Stouts.mongodb + - Stouts.mongodb vars: - port: 27400 + mongodb_conf_port: 27400 ``` #### License diff --git a/defaults/main.yml b/defaults/main.yml index 04b46a5..f2b62f4 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -6,27 +6,24 @@ mongodb_packages: - python-pymongo - mongodb-org -mongodb_conf: - 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: "false" +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" # Log rotation diff --git a/tasks/configure.yml b/tasks/configure.yml index ebd00fb..2dd574a 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -2,8 +2,17 @@ - name: Configure mongodb template: src=mongod.conf.j2 dest=/etc/mongod.conf owner=root group=root mode=0644 - notify: mongodb reload + notify: mongodb restart - name: Configure log rotation template: src=logrotate.conf.j2 dest=/etc/logrotate.d/mongodb.conf when: mongodb_logrotate + +- name: Create mongodb user + user: name=mongodb group=mongodb + +- name: Configure database directory + file: state=directory path={{ mongodb_conf_dbpath }} owner=mongodb group=mongodb mode=0755 + +- name: Configure logs + file: state=file path={{ mongodb_conf_logpath }} owner=mongodb group=mongodb mode=0644 diff --git a/templates/logrotate.conf.j2 b/templates/logrotate.conf.j2 index ab25ad2..20483ab 100644 --- a/templates/logrotate.conf.j2 +++ b/templates/logrotate.conf.j2 @@ -1,7 +1,7 @@ # This file was generated by Ansible for {{ ansible_fqdn }} # Do NOT modify this file by hand! -{{ mongodb_conf.logpath }} { +{{ mongodb_conf_logpath }} { {% for option in mongodb_logrotate_options %} {{ option }} {% endfor %} diff --git a/templates/mongod.conf.j2 b/templates/mongod.conf.j2 index 3b354b2..b325792 100644 --- a/templates/mongod.conf.j2 +++ b/templates/mongod.conf.j2 @@ -1,5 +1,20 @@ # {{ ansible_managed }} -{% for k, v in mongodb_conf.iteritems()|sort %} -{{ k }} = {{ v }} -{% endfor %} +auth = {{ mongodb_conf_auth }} +bind_ip = {{ mongodb_conf_bind_ip }} +cpu = {{ mongodb_conf_cpu }} +dbpath = {{ mongodb_conf_dbpath }} +logappend = {{ mongodb_conf_logappend }} +logpath = {{ mongodb_conf_logpath }} +noauth = {{ mongodb_conf_noauth }} +nohints = {{ mongodb_conf_nohints }} +nohttpinterface = {{ mongodb_conf_nohttpinterface }} +nojournal = {{ mongodb_conf_nojournal }} +noprealloc = {{ mongodb_conf_noprealloc }} +noscripting = {{ mongodb_conf_noscripting }} +notablescan = {{ mongodb_conf_notablescan }} +objcheck = {{ mongodb_conf_objcheck }} +port = {{ mongodb_conf_port }} +quota = {{ mongodb_conf_quota }} +verbose = {{ mongodb_conf_verbose }} +vvvv = {{ mongodb_conf_vvvv }}