Added feature to use mongodb versions >= 3.0

This commit is contained in:
Sergei Antipov 2016-03-04 01:20:08 +06:00
parent 390f9263c4
commit 3dfa06c44f
3 changed files with 13 additions and 2 deletions

View File

@ -1,6 +1,7 @@
--- ---
mongodb_package: mongodb-org mongodb_package: mongodb-org
mongodb_version: "2.6"
mongodb_apt_key_url: http://docs.mongodb.org/10gen-gpg-key.asc mongodb_apt_key_url: http://docs.mongodb.org/10gen-gpg-key.asc
mongodb_apt_key_id: 7F0CEB10 mongodb_apt_key_id: 7F0CEB10
mongodb_force_wait_for_port: false mongodb_force_wait_for_port: false

View File

@ -22,8 +22,15 @@
- name: Add APT key - name: Add APT key
apt_key: url="{{mongodb_apt_key_url}}" id="{{mongodb_apt_key_id}}" apt_key: url="{{mongodb_apt_key_url}}" id="{{mongodb_apt_key_id}}"
- name: Fail when used wrong mongodb_version variable
fail:
msg: "mongodb_version variable should be '2.6', '3.0' or '3.2'"
when: mongodb_version is not defined or mongodb_repository[item] is not defined
with_items: "{{ mongodb_version[0:3] }}"
- name: Add APT repository - name: Add APT repository
apt_repository: repo="{{mongodb_repository}}" update_cache=yes apt_repository: repo="{{ mongodb_repository[item] }}" update_cache=yes
with_items: "{{ mongodb_version[0:3] }}"
- name: Install MongoDB package - name: Install MongoDB package
apt: name={{item}} state=present apt: name={{item}} state=present

View File

@ -1,3 +1,6 @@
--- ---
mongodb_repository: deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen mongodb_repository:
"2.6": "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen"
"3.0": "deb http://repo.mongodb.org/apt/ubuntu {{ ansible_distribution_release }}/mongodb-org/3.0 multiverse"
"3.2": "deb http://repo.mongodb.org/apt/ubuntu {{ ansible_distribution_release }}/mongodb-org/3.2 multiverse"