Skip to content
This repository was archived by the owner on May 12, 2025. It is now read-only.

Commit 8512ea9

Browse files
Add python3 suppot and 4.4 version
1 parent b3dde4d commit 8512ea9

File tree

9 files changed

+71
-21
lines changed

9 files changed

+71
-21
lines changed

library/mongodb_replication.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,13 @@
156156
type: string
157157
sample: "replica"
158158
'''
159-
import ConfigParser
159+
160+
import sys
161+
if sys.version_info >= (3, 0):
162+
import configparser as ConfigParser
163+
else:
164+
import ConfigParser
165+
160166
import ssl as ssl_lib
161167
import time
162168
from datetime import datetime as dtdatetime

meta/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ galaxy_info:
1313
- trusty
1414
- xenial
1515
- bionic
16+
- focal
1617
- name: Debian
1718
versions:
1819
- jessie
@@ -21,6 +22,7 @@ galaxy_info:
2122
versions:
2223
- 6
2324
- 7
25+
- 8
2426
- name: Amazon
2527
versions:
2628
- Candidate

tasks/install.amazon.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
- name: Install MongoDB package
1717
yum:
18-
name: "{{ mongodb_package }}{% if (mongodb_version | length > 3) %}={{ mongodb_version }}{% endif %}"
18+
name: "{{ mongodb_package }}{% if (mongodb_version | length > 3) %}-{{ mongodb_version }}{% endif %}"
1919
state: "{{ mongodb_package_state }}"
2020
lock_timeout: "{{ yum_lock_timeout }}"
2121

@@ -24,7 +24,6 @@
2424
name: numactl
2525
state: present
2626
lock_timeout: "{{ yum_lock_timeout }}"
27-
when: mongodb_use_numa | bool
2827

2928
- name: Install PyMongo package
3029
yum:

tasks/install.debian.yml

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,39 @@
99
- mongodb_disable_transparent_hugepages | bool
1010
- ansible_service_mgr == "systemd"
1111

12+
- name: Install Required Dependency Packages
13+
apt:
14+
pkg:
15+
- software-properties-common
16+
- dirmngr
17+
- apt-transport-https
18+
- lsb-release
19+
- ca-certificates
20+
1221
- name: Add APT key
1322
apt_key:
14-
keyserver: "{{ mongodb_apt_keyserver }}"
15-
id: "{{ mongodb_apt_key_id[mongodb_major_version] }}"
23+
url: "{{ mongodb_repository_gpgkey[mongodb_version] }}"
1624
when: mongodb_package == 'mongodb-org'
1725

1826
- name: Fail when used wrong mongodb_version variable with Debian Stretch
1927
fail:
20-
msg: "mongodb_version variable should be '3.6' or '4.0' or '4.2' for Debian Stretch"
28+
msg: "mongodb_version variable should be '3.6' or '4.0' or '4.2' or '4.4' for Debian Stretch"
2129
when:
2230
- mongodb_package == 'mongodb-org'
23-
- (mongodb_major_version != '3.6' and mongodb_major_version != '4.0' and mongodb_major_version != '4.2')
31+
- (mongodb_major_version != '3.6' and mongodb_major_version != '4.0' and mongodb_major_version != '4.2' and mongodb_major_version != '4.4')
2432
- ansible_distribution_release == 'stretch'
2533

2634
- name: Fail when used wrong mongodb_version variable with Ubuntu 18.04
2735
fail:
28-
msg: "mongodb_version variable should be '4.0' or '4.2', or else mongodb_package should be 'mongodb' for Ubuntu 18.04"
36+
msg: "mongodb_version variable should be '4.0' or '4.2' or '4.4', or else mongodb_package should be 'mongodb' for Ubuntu 18.04"
2937
when:
3038
- mongodb_package == 'mongodb-org'
31-
- (mongodb_major_version != '4.0' and mongodb_major_version != '4.2')
39+
- (mongodb_major_version != '4.0' and mongodb_major_version != '4.2' and mongodb_major_version != '4.4')
3240
- ansible_distribution_release == "bionic"
3341

3442
- name: Fail when used wrong mongodb_version variable
3543
fail:
36-
msg: "mongodb_version variable should be '3.4', '3.6' or '4.0' or '4.2'"
44+
msg: "mongodb_version variable should be '3.4', '3.6' or '4.0' or '4.2' or '4.4'"
3745
when: (mongodb_package == 'mongodb-org' and
3846
(mongodb_version is not defined
3947
or mongodb_repository[mongodb_major_version] is not defined))
@@ -57,12 +65,11 @@
5765
apt:
5866
name: numactl
5967
state: present
60-
when: mongodb_use_numa | bool
6168

6269
- name: Add systemd configuration if present
6370
template:
6471
src: mongodb.service.j2
65-
dest: "/lib/systemd/system/{{mongodb_daemon_name}}.service"
72+
dest: "/lib/systemd/system/{{ mongodb_daemon_name }}.service"
6673
owner: root
6774
group: root
6875
mode: '0644'
@@ -74,8 +81,8 @@
7481

7582
- name: Add symlink for systemd
7683
file:
77-
src: "/lib/systemd/system/{{mongodb_daemon_name}}.service"
78-
dest: "/etc/systemd/system/multi-user.target.wants/{{mongodb_daemon_name}}.service"
84+
src: "/lib/systemd/system/{{ mongodb_daemon_name }}.service"
85+
dest: "/etc/systemd/system/multi-user.target.wants/{{ mongodb_daemon_name }}.service"
7986
state: link
8087
when:
8188
- ansible_service_mgr == "systemd"
@@ -88,22 +95,30 @@
8895
name: python-pymongo
8996
when: not mongodb_pymongo_from_pip
9097

91-
- name: Install PIP
98+
- name: Install Python2 PIP
9299
apt:
93100
pkg:
94101
- python-dev
95102
- python-pip
96-
when: mongodb_pymongo_from_pip | bool
103+
when: mongodb_pymongo_from_pip | bool and ansible_distribution_release != 'focal'
104+
105+
- name: Install Python3 PIP
106+
apt:
107+
pkg:
108+
- python3-dev
109+
- python3-pip
110+
when: mongodb_pymongo_from_pip | bool and ansible_distribution_release == 'focal'
97111

98112
- name: Install setuptools (required for ansible 2.7+)
99113
apt:
100114
pkg:
101-
- python-setuptools
115+
- "{{ 'python3-setuptools' if (ansible_distribution_release == 'focal') else 'python-setuptools' }}" # different setuptools for python3
102116
when: mongodb_pymongo_from_pip | bool
103117

104118
- name: Install PyMongo from PIP
105119
pip:
106120
name: pymongo
121+
executable: "{{ 'pip3' if (ansible_distribution_release == 'focal') else 'pip' }}" # different pip for python3
107122
state: "{{ mongodb_pymongo_pip_version is defined | ternary('present', 'latest') }}"
108123
version: "{{ mongodb_pymongo_pip_version | default(omit) }}"
109124
when: mongodb_pymongo_from_pip | bool

tasks/install.redhat.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
- name: Install MongoDB package
2323
yum:
24-
name: "{{ mongodb_package }}{% if (mongodb_version | length > 3) %}={{ mongodb_version }}{% endif %}"
24+
name: "{{ mongodb_package }}{% if (mongodb_version | length > 3) %}-{{ mongodb_version }}{% endif %}"
2525
state: "{{ mongodb_package_state }}"
2626
lock_timeout: "{{ yum_lock_timeout }}"
2727

@@ -30,7 +30,6 @@
3030
name: numactl
3131
state: present
3232
lock_timeout: "{{ yum_lock_timeout }}"
33-
when: mongodb_use_numa | bool
3433

3534
- name: Install PyMongo package
3635
yum:
@@ -39,17 +38,26 @@
3938
lock_timeout: "{{ yum_lock_timeout }}"
4039
when: not mongodb_pymongo_from_pip
4140

42-
- name: Install PIP
41+
- name: Install Python2 PIP
4342
yum:
4443
name:
4544
- python-devel
4645
- python-pip
4746
lock_timeout: "{{ yum_lock_timeout }}"
48-
when: mongodb_pymongo_from_pip | bool
47+
when: mongodb_pymongo_from_pip | bool and ansible_distribution != 'CentOS' and ansible_distribution_version < '8'
48+
49+
- name: Install Python3 PIP
50+
yum:
51+
name:
52+
- python3-devel
53+
- python3-pip
54+
lock_timeout: "{{ yum_lock_timeout }}"
55+
when: mongodb_pymongo_from_pip | bool and ansible_distribution == 'CentOS' and ansible_distribution_version >= '8'
4956

5057
- name: Install PyMongo from PIP
5158
pip:
5259
name: pymongo
60+
executable: "{{ 'pip3' if (ansible_distribution == 'CentOS' and ansible_distribution_version >= '8') else 'pip' }}" # different pip for python3
5361
state: "{{ mongodb_pymongo_pip_version is defined | ternary('present', 'latest') }}"
5462
version: "{{ mongodb_pymongo_pip_version | default(omit) }}"
5563
when: mongodb_pymongo_from_pip | bool

vars/Amazon.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
---
22
mongodb_repository:
3+
"4.4": "https://repo.mongodb.org/yum/amazon/2/mongodb-org/4.4/x86_64/"
34
"4.2": "https://repo.mongodb.org/yum/amazon/2/mongodb-org/4.2/x86_64/"
45
"4.0": "https://repo.mongodb.org/yum/amazon/2/mongodb-org/4.0/x86_64/"
56
"3.6": "https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/3.6/x86_64/"
67
"3.4": "https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/3.4/x86_64/"
78

89
mongodb_repository_gpgkey:
10+
"4.4": "https://www.mongodb.org/static/pgp/server-4.4.asc"
911
"4.2": "https://www.mongodb.org/static/pgp/server-4.2.asc"
1012
"4.0": "https://www.mongodb.org/static/pgp/server-4.0.asc"
1113
"3.6": "https://www.mongodb.org/static/pgp/server-3.6.asc"

vars/Debian.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,11 @@ mongodb_repository:
44
"3.6": "deb http://repo.mongodb.org/apt/debian {{ ansible_distribution_release }}/mongodb-org/3.6 main"
55
"4.0": "deb http://repo.mongodb.org/apt/debian {{ ansible_distribution_release }}/mongodb-org/4.0 main"
66
"4.2": "deb http://repo.mongodb.org/apt/debian {{ ansible_distribution_release }}/mongodb-org/4.2 main"
7+
"4.4": "deb http://repo.mongodb.org/apt/debian {{ ansible_distribution_release }}/mongodb-org/4.4 main"
8+
9+
mongodb_repository_gpgkey:
10+
"3.4": "https://www.mongodb.org/static/pgp/server-3.4.asc"
11+
"3.6": "https://www.mongodb.org/static/pgp/server-3.6.asc"
12+
"4.0": "https://www.mongodb.org/static/pgp/server-4.0.asc"
13+
"4.2": "https://www.mongodb.org/static/pgp/server-4.2.asc"
14+
"4.4": "https://www.mongodb.org/static/pgp/server-4.4.asc"

vars/RedHat.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ mongodb_repository:
44
"3.6": "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/$basearch/"
55
"4.0": "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/$basearch/"
66
"4.2": "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/$basearch/"
7+
"4.4": "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/$basearch/"
78

89
mongodb_repository_gpgkey:
910
"3.4": "https://www.mongodb.org/static/pgp/server-3.4.asc"
1011
"3.6": "https://www.mongodb.org/static/pgp/server-3.6.asc"
1112
"4.0": "https://www.mongodb.org/static/pgp/server-4.0.asc"
1213
"4.2": "https://www.mongodb.org/static/pgp/server-4.2.asc"
14+
"4.4": "https://www.mongodb.org/static/pgp/server-4.4.asc"
1315

1416
mongodb_pidfile_path: "{{ '/var/run/mongodb/mongod.pid' if ('mongodb-org' in mongodb_package) else '' }}"
1517

vars/Ubuntu.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,11 @@ mongodb_repository:
44
"3.6": "deb http://repo.mongodb.org/apt/ubuntu {{ ansible_distribution_release }}/mongodb-org/3.6 multiverse"
55
"4.0": "deb http://repo.mongodb.org/apt/ubuntu {{ ansible_distribution_release }}/mongodb-org/4.0 multiverse"
66
"4.2": "deb http://repo.mongodb.org/apt/ubuntu {{ ansible_distribution_release }}/mongodb-org/4.2 multiverse"
7+
"4.4": "deb http://repo.mongodb.org/apt/ubuntu {{ ansible_distribution_release }}/mongodb-org/4.4 multiverse"
8+
9+
mongodb_repository_gpgkey:
10+
"3.4": "https://www.mongodb.org/static/pgp/server-3.4.asc"
11+
"3.6": "https://www.mongodb.org/static/pgp/server-3.6.asc"
12+
"4.0": "https://www.mongodb.org/static/pgp/server-4.0.asc"
13+
"4.2": "https://www.mongodb.org/static/pgp/server-4.2.asc"
14+
"4.4": "https://www.mongodb.org/static/pgp/server-4.4.asc"

0 commit comments

Comments
 (0)