diff --git a/README.md b/README.md index e0df8cd..ce76851 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,14 @@ Ansible role which manage [MongoDB](http://www.mongodb.org/) ```yaml mongodb_enabled: yes -mongodb_packages: -- python-selinux -- python-pymongo -- mongodb-org +mongodb_from_mongodb_repo: yes # If yes, install using MongoDB repo, else use system default repo + +mongodb_additional_packages: + - python-selinux + - python-pymongo mongodb_user: mongodb +mongodb_daemon_name: "{{ 'mongod' if (mongodb_from_mongodb_repo | bool) else 'mongodb' }}" mongodb_conf_auth: no # Run with security mongodb_conf_bind_ip: 127.0.0.1 # Comma separated list of ip addresses to listen on @@ -31,7 +33,7 @@ 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_logpath: /var/log/mongodb/{{ mongodb_daemon_name }}.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 @@ -49,7 +51,7 @@ mongodb_shell: {} # Define mongo shell commands # Syntax: mongodb_shell: # dbname: # - db.setProfilingLevel(1, 50) - + # 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 diff --git a/defaults/main.yml b/defaults/main.yml index c8e9090..308a42f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,12 +1,14 @@ --- mongodb_enabled: yes -mongodb_packages: -- python-selinux -- python-pymongo -- mongodb-org +mongodb_from_mongodb_repo: yes # If yes, install using MongoDB repo, else use system default repo + +mongodb_additional_packages: + - python-selinux + - python-pymongo mongodb_user: mongodb +mongodb_daemon_name: "{{ 'mongod' if (mongodb_from_mongodb_repo | bool) else 'mongodb' }}" mongodb_conf_auth: no # Run with security mongodb_conf_bind_ip: 127.0.0.1 # Comma separated list of ip addresses to listen on @@ -17,7 +19,7 @@ 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_logpath: /var/log/mongodb/{{ mongodb_daemon_name }}.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 @@ -35,7 +37,7 @@ mongodb_shell: {} # Define mongo shell commands # Syntax: mongodb_shell: # dbname: # - db.setProfilingLevel(1, 50) - + # 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 diff --git a/handlers/main.yml b/handlers/main.yml index 753a8b8..c6988fb 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,10 +1,10 @@ --- - name: mongodb reload - service: name=mongod state=reloaded + service: name={{ mongodb_daemon_name }} state=reloaded - name: mongodb restart - service: name=mongod state=restarted + service: name={{ mongodb_daemon_name }} state=restarted - name: mongodb-mms-automation-agent restart service: name=mongodb-mms-automation-agent state=restarted diff --git a/tasks/install.deb.yml b/tasks/install.deb.yml index 0e64a6b..f335c37 100644 --- a/tasks/install.deb.yml +++ b/tasks/install.deb.yml @@ -2,15 +2,24 @@ - name: Add APT key apt_key: url=http://docs.mongodb.org/10gen-gpg-key.asc id=7F0CEB10 + when: mongodb_from_mongodb_repo | bool - name: Add APT repository (Ubuntu) apt_repository: repo='deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' update_cache=yes - when: ansible_distribution == 'Ubuntu' + when: ansible_distribution == 'Ubuntu' and (mongodb_from_mongodb_repo | bool) - name: Add APT repository (Debian) apt_repository: repo='deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen' update_cache=yes - when: ansible_distribution == 'Debian' + when: ansible_distribution == 'Debian' and (mongodb_from_mongodb_repo | bool) -- name: Install mongodb-org +- name: Install MongoDB package from MongoDB repo + apt: pkg=mongodb-org state=present + when: mongodb_from_mongodb_repo | bool + +- name: Install MongoDB package from Ubuntu or Debian official repo + apt: pkg=mongodb state=present + when: not (mongodb_from_mongodb_repo | bool) + +- name: Install additional packages apt: pkg={{item}} - with_items: mongodb_packages + with_items: mongodb_additional_packages diff --git a/tasks/mongodb.yml b/tasks/mongodb.yml index b31109a..cca48ed 100644 --- a/tasks/mongodb.yml +++ b/tasks/mongodb.yml @@ -6,7 +6,7 @@ - include: configure.yml - name: Ensure mongodb is started - service: name=mongod state=started enabled=yes + service: name={{ mongodb_daemon_name }} state=started enabled=yes changed_when: False - include: mms-agent.yml