The packages from mongodb.org have different names and the service has a different name. Changed the role to cover both cases.
This commit is contained in:
parent
9910c8580f
commit
c67f747b3f
|
@ -17,16 +17,24 @@ mongodb_upgrade_from_older_version: False
|
|||
mongodb_version: 3.6
|
||||
# Set to 'latest' if you want to get the latest available package
|
||||
mongodb_pkg_state: present
|
||||
mongodb_server_pkgs:
|
||||
mongodb_server_pkgs_external_repo:
|
||||
- mongodb-org
|
||||
- mongodb-org-mongos
|
||||
- mongodb-org-server
|
||||
- mongodb-org-shell
|
||||
- mongodb-org-tools
|
||||
|
||||
mongodb_client_pkgs:
|
||||
mongodb_client_pkgs_external_repo:
|
||||
- mongodb-org-shell
|
||||
|
||||
mongodb_server_pkgs:
|
||||
- mongodb
|
||||
- mongodb-server
|
||||
- mongo-tools
|
||||
|
||||
mongodb_client_pkgs:
|
||||
- mongodb-clients
|
||||
|
||||
mongodb_start_server: 'yes'
|
||||
mongodb_tcp_port: 27017
|
||||
mongo_bind_ip: 0.0.0.0
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
---
|
||||
- name: Restart mongodb
|
||||
- name: Restart mongod
|
||||
service: name=mongod state=restarted
|
||||
when: "'{{ mongodb_start_server }}' == 'yes'"
|
||||
|
||||
- name: Restart mongodb
|
||||
service: name=mongodb state=restarted
|
||||
when: "'{{ mongodb_start_server }}' == 'yes'"
|
||||
|
||||
|
|
|
@ -13,52 +13,78 @@
|
|||
- mongodb_start_server == 'no'
|
||||
- mongodb_install_conf
|
||||
|
||||
when: mongodb_install_server
|
||||
when:
|
||||
- mongodb_install_server
|
||||
- mongodb_install_from_external_repo
|
||||
tags: mongodb
|
||||
|
||||
- block:
|
||||
- name: Install the mongodb apt keys
|
||||
- name: Install the mongodb-org apt keys
|
||||
apt_key: keyserver='hkp://keyserver.ubuntu.com:80' id={{ item }} state=present
|
||||
with_items: '{{ mongodb_repo_keys }}'
|
||||
when: mongodb_install_from_external_repo
|
||||
register: apt_key_update_cache
|
||||
|
||||
- name: Update the apt cache after adding a new key
|
||||
apt: update_cache=yes
|
||||
when: apt_key_update_cache is changed
|
||||
|
||||
- name: Remove the old mongo apt repositories
|
||||
- name: Remove the old mongodb-org apt repositories
|
||||
apt_repository: repo='{{ item }}' state=absent update_cache=yes
|
||||
with_items: '{{ mongodb_old_repositories }}'
|
||||
when: mongodb_upgrade_from_older_version
|
||||
|
||||
- name: Install the mongodb repository
|
||||
- name: Install the mongodb-org repository
|
||||
apt_repository: repo="{{ mongodb_apt_repository }}" update_cache=yes state=present
|
||||
|
||||
when: mongodb_install_from_external_repo
|
||||
tags: [ 'mongodb', 'mongodb_client', 'mongodb_repo' ]
|
||||
|
||||
- block:
|
||||
- name: Install/Update the mongodb configuration
|
||||
- name: Install/Update the mongodb-org configuration
|
||||
template: src=mongod-{{ mongodb_version }}.conf.j2 dest=/etc/mongod.conf owner=root group=root mode=0444 backup=yes
|
||||
when: mongodb_install_conf
|
||||
notify: Restart mongodb
|
||||
tags: [ 'mongodb', 'mongodb_update_conf' ]
|
||||
|
||||
when: mongodb_install_server
|
||||
tags: [ 'mongodb', 'mongodb_update_conf' ]
|
||||
when:
|
||||
- mongodb_install_server
|
||||
- mongodb_install_from_external_repo
|
||||
tags: [ 'mongodb' ]
|
||||
|
||||
- block:
|
||||
- name: We are upgrading, install the latest version of the mongodb-org packages, external repository
|
||||
apt: pkg={{ mongodb_server_pkgs_external_repo }} state=latest update_cache=yes cache_valid_time=1800
|
||||
when: mongodb_upgrade_from_older_version
|
||||
|
||||
- name: Install the mongodb-org packages, external repository
|
||||
apt: pkg={{ mongodb_server_pkgs_external_repo }} state={{ mongodb_pkg_state }} update_cache=yes cache_valid_time=1800
|
||||
|
||||
- name: Install the mongodb-org defaults file
|
||||
template: src=mongod-default.j2 dest=/etc/default/mongod owner=root group=root mode=0444
|
||||
when: mongodb_install_conf
|
||||
notify: Restart mongod
|
||||
tags: [ 'mongodb', 'mongodb_update_conf' ]
|
||||
|
||||
when:
|
||||
- mongodb_install_server
|
||||
- mongodb_install_packages
|
||||
- mongodb_install_from_external_repo
|
||||
tags: mongodb
|
||||
|
||||
- block:
|
||||
- name: We are upgrading, install the latest version of the mongodb packages
|
||||
apt: pkg={{ mongodb_server_pkgs }} state=latest update_cache=yes cache_valid_time=1800
|
||||
when:
|
||||
- mongodb_install_packages
|
||||
- mongodb_upgrade_from_older_version
|
||||
when: mongodb_upgrade_from_older_version
|
||||
|
||||
- name: Install the mongodb packages
|
||||
apt: pkg={{ mongodb_server_pkgs }} state={{ mongodb_pkg_state }} update_cache=yes cache_valid_time=1800
|
||||
when:
|
||||
- mongodb_install_packages
|
||||
|
||||
- name: Install/Update the mongodb configuration
|
||||
template: src=mongod-{{ mongodb_version }}.conf.j2 dest=/etc/mongodb.conf owner=root group=root mode=0444 backup=yes
|
||||
when: mongodb_install_conf
|
||||
notify: Restart mongodb
|
||||
tags: [ 'mongodb', 'mongodb_update_conf' ]
|
||||
|
||||
when:
|
||||
- mongodb_install_server
|
||||
- mongodb_install_packages
|
||||
- not mongodb_install_from_external_repo
|
||||
tags: mongodb
|
||||
|
||||
- block:
|
||||
- name: Create the mongodb log directory
|
||||
file: dest={{ mongodb_logdir }} state=directory owner={{ mongodb_user }} group={{ mongodb_group }} mode=0755
|
||||
when: mongodb_install_conf
|
||||
|
@ -67,25 +93,39 @@
|
|||
file: dest={{ mongodb_dbpath }} state=directory owner={{ mongodb_user }} group={{ mongodb_group }} mode=0755
|
||||
when: mongodb_install_conf
|
||||
|
||||
- name: Install the mongodb defaults file
|
||||
template: src=mongod-default.j2 dest=/etc/default/mongod owner=root group=root mode=0444
|
||||
when: mongodb_install_conf
|
||||
notify: Restart mongodb
|
||||
|
||||
- name: Install the cron job that manages log files rotation
|
||||
template: src=mongo_log_rotate.sh.j2 dest=/etc/cron.daily/mongo_log_rotate owner=root group=root mode=0555
|
||||
when: not mongodb_systemlog_external_logrotate
|
||||
|
||||
- name: Ensure mongodb is started and enabled
|
||||
service: name=mongod state=started enabled=yes
|
||||
when: ( mongodb_start_server is defined ) and ( mongodb_start_server == 'yes' ) and ( mongodb_install_conf )
|
||||
|
||||
when: mongodb_install_server
|
||||
tags: mongodb
|
||||
|
||||
- block:
|
||||
- name: Ensure mongodb is started and enabled
|
||||
service: name=mongodb state=started enabled=yes
|
||||
|
||||
when:
|
||||
- mongodb_install_server
|
||||
- mongodb_start_server == 'yes'
|
||||
- not mongodb_install_from_external_repo
|
||||
tags: mongodb
|
||||
|
||||
- block:
|
||||
- name: Ensure mongodb-org is started and enabled
|
||||
service: name=mongod state=started enabled=yes
|
||||
|
||||
when:
|
||||
- mongodb_install_server
|
||||
- mongodb_start_server == 'yes'
|
||||
- mongodb_install_from_external_repo
|
||||
tags: mongodb
|
||||
|
||||
- block:
|
||||
- name: Install the mongodb client packages
|
||||
apt: pkg={{ mongodb_client_pkgs }} state={{ mongodb_pkg_state }} update_cache=yes cache_valid_time=1800
|
||||
|
||||
- name: Install the mongodb client packages, external repository
|
||||
apt: pkg={{ mongodb_client_pkgs_external_repo }} state={{ mongodb_pkg_state }} update_cache=yes cache_valid_time=1800
|
||||
|
||||
when: not mongodb_install_server
|
||||
tags: [ 'mongodb', 'mongodb_client' ]
|
||||
|
|
Loading…
Reference in New Issue