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
|
mongodb_version: 3.6
|
||||||
# Set to 'latest' if you want to get the latest available package
|
# Set to 'latest' if you want to get the latest available package
|
||||||
mongodb_pkg_state: present
|
mongodb_pkg_state: present
|
||||||
mongodb_server_pkgs:
|
mongodb_server_pkgs_external_repo:
|
||||||
- mongodb-org
|
- mongodb-org
|
||||||
- mongodb-org-mongos
|
- mongodb-org-mongos
|
||||||
- mongodb-org-server
|
- mongodb-org-server
|
||||||
- mongodb-org-shell
|
- mongodb-org-shell
|
||||||
- mongodb-org-tools
|
- mongodb-org-tools
|
||||||
|
|
||||||
mongodb_client_pkgs:
|
mongodb_client_pkgs_external_repo:
|
||||||
- mongodb-org-shell
|
- mongodb-org-shell
|
||||||
|
|
||||||
|
mongodb_server_pkgs:
|
||||||
|
- mongodb
|
||||||
|
- mongodb-server
|
||||||
|
- mongo-tools
|
||||||
|
|
||||||
|
mongodb_client_pkgs:
|
||||||
|
- mongodb-clients
|
||||||
|
|
||||||
mongodb_start_server: 'yes'
|
mongodb_start_server: 'yes'
|
||||||
mongodb_tcp_port: 27017
|
mongodb_tcp_port: 27017
|
||||||
mongo_bind_ip: 0.0.0.0
|
mongo_bind_ip: 0.0.0.0
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
---
|
---
|
||||||
- name: Restart mongodb
|
- name: Restart mongod
|
||||||
service: name=mongod state=restarted
|
service: name=mongod state=restarted
|
||||||
when: "'{{ mongodb_start_server }}' == 'yes'"
|
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_start_server == 'no'
|
||||||
- mongodb_install_conf
|
- mongodb_install_conf
|
||||||
|
|
||||||
when: mongodb_install_server
|
when:
|
||||||
|
- mongodb_install_server
|
||||||
|
- mongodb_install_from_external_repo
|
||||||
tags: mongodb
|
tags: mongodb
|
||||||
|
|
||||||
- block:
|
- 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
|
apt_key: keyserver='hkp://keyserver.ubuntu.com:80' id={{ item }} state=present
|
||||||
with_items: '{{ mongodb_repo_keys }}'
|
with_items: '{{ mongodb_repo_keys }}'
|
||||||
when: mongodb_install_from_external_repo
|
when: mongodb_install_from_external_repo
|
||||||
register: apt_key_update_cache
|
register: apt_key_update_cache
|
||||||
|
|
||||||
- name: Update the apt cache after adding a new key
|
- name: Remove the old mongodb-org apt repositories
|
||||||
apt: update_cache=yes
|
|
||||||
when: apt_key_update_cache is changed
|
|
||||||
|
|
||||||
- name: Remove the old mongo apt repositories
|
|
||||||
apt_repository: repo='{{ item }}' state=absent update_cache=yes
|
apt_repository: repo='{{ item }}' state=absent update_cache=yes
|
||||||
with_items: '{{ mongodb_old_repositories }}'
|
with_items: '{{ mongodb_old_repositories }}'
|
||||||
when: mongodb_upgrade_from_older_version
|
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
|
apt_repository: repo="{{ mongodb_apt_repository }}" update_cache=yes state=present
|
||||||
|
|
||||||
when: mongodb_install_from_external_repo
|
- name: Install/Update the mongodb-org configuration
|
||||||
tags: [ 'mongodb', 'mongodb_client', 'mongodb_repo' ]
|
|
||||||
|
|
||||||
- block:
|
|
||||||
- name: Install/Update the mongodb configuration
|
|
||||||
template: src=mongod-{{ mongodb_version }}.conf.j2 dest=/etc/mongod.conf owner=root group=root mode=0444 backup=yes
|
template: src=mongod-{{ mongodb_version }}.conf.j2 dest=/etc/mongod.conf owner=root group=root mode=0444 backup=yes
|
||||||
when: mongodb_install_conf
|
when: mongodb_install_conf
|
||||||
notify: Restart mongodb
|
notify: Restart mongodb
|
||||||
|
tags: [ 'mongodb', 'mongodb_update_conf' ]
|
||||||
|
|
||||||
when: mongodb_install_server
|
when:
|
||||||
tags: [ 'mongodb', 'mongodb_update_conf' ]
|
- 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:
|
- block:
|
||||||
- name: We are upgrading, install the latest version of the mongodb packages
|
- 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
|
apt: pkg={{ mongodb_server_pkgs }} state=latest update_cache=yes cache_valid_time=1800
|
||||||
when:
|
when: mongodb_upgrade_from_older_version
|
||||||
- mongodb_install_packages
|
|
||||||
- mongodb_upgrade_from_older_version
|
|
||||||
|
|
||||||
- name: Install the mongodb packages
|
- name: Install the mongodb packages
|
||||||
apt: pkg={{ mongodb_server_pkgs }} state={{ mongodb_pkg_state }} update_cache=yes cache_valid_time=1800
|
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
|
- name: Create the mongodb log directory
|
||||||
file: dest={{ mongodb_logdir }} state=directory owner={{ mongodb_user }} group={{ mongodb_group }} mode=0755
|
file: dest={{ mongodb_logdir }} state=directory owner={{ mongodb_user }} group={{ mongodb_group }} mode=0755
|
||||||
when: mongodb_install_conf
|
when: mongodb_install_conf
|
||||||
|
@ -67,25 +93,39 @@
|
||||||
file: dest={{ mongodb_dbpath }} state=directory owner={{ mongodb_user }} group={{ mongodb_group }} mode=0755
|
file: dest={{ mongodb_dbpath }} state=directory owner={{ mongodb_user }} group={{ mongodb_group }} mode=0755
|
||||||
when: mongodb_install_conf
|
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
|
- 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
|
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
|
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
|
when: mongodb_install_server
|
||||||
tags: mongodb
|
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:
|
- block:
|
||||||
- name: Install the mongodb client packages
|
- name: Install the mongodb client packages
|
||||||
apt: pkg={{ mongodb_client_pkgs }} state={{ mongodb_pkg_state }} update_cache=yes cache_valid_time=1800
|
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
|
when: not mongodb_install_server
|
||||||
tags: [ 'mongodb', 'mongodb_client' ]
|
tags: [ 'mongodb', 'mongodb_client' ]
|
||||||
|
|
Loading…
Reference in New Issue