Skip to content

Commit 02495de

Browse files
committed
Fix for linting warnings
1 parent 3cfe431 commit 02495de

File tree

9 files changed

+89
-82
lines changed

9 files changed

+89
-82
lines changed

defaults/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
mongodb_package: mongodb-org
44
mongodb_package_state: present
5-
mongodb_version: "3.6"
5+
mongodb_package_version: "4.0.9"
6+
mongodb_version: "4.0"
67
mongodb_apt_keyserver: keyserver.ubuntu.com
78
mongodb_apt_key_id:
89
"3.4": "0C49F3730359A14518585931BC711F9BA15703C6"

handlers/main.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
---
22

3+
- name: reload systemd
4+
systemd:
5+
daemon_reload: yes
6+
when: ansible_service_mgr == "systemd" and mongodb_manage_service
7+
38
- name: mongodb reload
49
service: name={{ mongodb_daemon_name }} state=reloaded
510
when: mongodb_manage_service
@@ -12,9 +17,5 @@
1217
service: name=mongodb-mms-monitoring-agent state=restarted
1318
when: mongodb_manage_service
1419

15-
- name: reload systemd
16-
shell: systemctl daemon-reload
17-
when: mongodb_is_systemd and mongodb_manage_service
18-
1920
- name: restart sysfsutils
2021
service: name=sysfsutils state=restarted

tasks/auth_initialization.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@
99
- name: wait MongoDB port is listening
1010
wait_for: host=127.0.0.1 port="{{ mongodb_net_port }}" delay=5 state=started
1111

12-
- name: get pid of mongodb for non daemon mode
13-
shell: "pidof mongod"
14-
register: pidof_mongod
15-
when: mongodb_manage_service == false
16-
ignore_errors: yes
17-
18-
- name: start mongodb daemon
19-
shell: "LC_ALL=C /usr/bin/mongod --config /etc/mongod.conf --fork"
20-
when: mongodb_manage_service == false and pidof_mongod.rc == 1
21-
2212
- name: create administrative user siteUserAdmin
2313
mongodb_user:
2414
database: admin

tasks/configure.yml

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,31 @@
77
owner: "{{ mongodb_user }}"
88
group: "root"
99
mode: 0600
10-
when: mongodb_replication_replset and mongodb_replication_replset != ''
10+
when: mongodb_replication_replset
1111

1212
- name: set mongodb gid
13-
group: name=mongodb gid={{ mongodb_gid }} state=present
13+
group:
14+
name: "{{ mongodb_user }}"
15+
gid: "{{ mongodb_gid }}"
16+
state: present
1417
when: mongodb_gid
1518

1619
- name: set mongodb uid
17-
user: name=mongodb uid={{ mongodb_uid }} group=mongodb state=present
18-
when: mongodb_uid
19-
20-
- name: reset mongodb folder and subfolders with new uid
21-
file: path={{ mongodb_storage_dbpath }} owner=mongodb group=mongodb follow=yes recurse=yes state=directory
20+
user:
21+
name: "{{ mongodb_user }}"
22+
uid: "{{ mongodb_uid }}"
23+
group: "{{ mongodb_user }}"
24+
state: present
2225
when: mongodb_uid
2326

2427
- name: Create log dir if missing
25-
file: state=directory recurse=yes dest={{ mongodb_systemlog_path|dirname }} owner={{ mongodb_user }} group={{mongodb_user}} mode=0755
28+
file:
29+
state: directory
30+
recurse: true
31+
dest: "{{ mongodb_systemlog_path|dirname }}"
32+
owner: "{{ mongodb_user }}"
33+
group: "{{ mongodb_user }}"
34+
mode: 0755
2635
when: mongodb_systemlog_destination == "file"
2736

2837
- name: Check than logfile exists
@@ -31,7 +40,12 @@
3140
when: mongodb_systemlog_destination == "file"
3241

3342
- name: Create log if missing
34-
file: state=touch dest={{ mongodb_systemlog_path }} owner={{ mongodb_user }} group={{mongodb_user}} mode=0755
43+
file:
44+
state: touch
45+
dest: "{{ mongodb_systemlog_path }}"
46+
owner: "{{ mongodb_user }}"
47+
group: "{{ mongodb_user }}"
48+
mode: 0755
3549
when: ( mongodb_systemlog_destination == "file"
3650
and logfile_stat is defined
3751
and not logfile_stat.stat.exists )
@@ -41,11 +55,19 @@
4155
path: "{{ mongodb_storage_dbpath }}"
4256
state: directory
4357
owner: "{{ mongodb_user }}"
58+
group: "{{ mongodb_user }}"
4459
setype: 'mongod_var_lib_t'
45-
recurse: yes
60+
recurse: true
61+
follow: true
4662

4763
- name: Configure mongodb
48-
template: src=mongod.conf.j2 dest=/etc/mongod.conf backup=yes owner=root group=root mode=0644
64+
template:
65+
src: mongod.conf.j2
66+
dest: /etc/mongod.conf
67+
backup: true
68+
owner: root
69+
group: root
70+
mode: 0644
4971
register: config_result
5072

5173
- name: mongodb restart

tasks/install.amazon.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@
1313

1414
- name: Install MongoDB package
1515
yum:
16-
name:
17-
- "{{ mongodb_package }}"
18-
- numactl
19-
state: present
16+
name: "{{ mongodb_package }}"
17+
state: "{{ mongodb_package_version is defined | ternary('present', 'latest') }}"
18+
version: "{{ mongodb_package_version | default(omit) }}"
19+
20+
- name: Install numactl package
21+
yum:
22+
name: numactl
2023

2124
- name: Install PyMongo package
2225
yum:
2326
name: python-pymongo
24-
state: latest
27+
state: present
2528
when: not mongodb_pymongo_from_pip
2629

2730
- name: Install PIP

tasks/install.debian.yml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88

99
- name: Establish some role-related facts
1010
set_fact:
11-
mongodb_is_systemd: "{{ sbin_init.stat.islnk is defined and sbin_init.stat.islnk }}"
1211
mongodb_major_version: "{{ mongodb_version[0:3] }}"
1312

1413
- name: Disable transparent huge pages on systemd systems
1514
include_tasks: disable_transparent_hugepages.yml
1615
when:
1716
- mongodb_disable_transparent_hugepages
18-
- mongodb_is_systemd
17+
- ansible_service_mgr == "systemd"
1918

2019
- name: Add APT key
2120
apt_key:
@@ -53,32 +52,33 @@
5352
when: mongodb_package == 'mongodb-org'
5453

5554
- name: Install MongoDB package
56-
apt:
57-
name:
58-
- "{{mongodb_package}}"
59-
- numactl
60-
state: "{{ mongodb_package_state }}"
61-
update_cache: yes
55+
apt:
56+
name: "{{ mongodb_package }}"
57+
state: "{{ mongodb_package_version is defined | ternary('present', 'latest') }}"
58+
version: "{{ mongodb_package_version | default(omit) }}"
59+
update_cache: true
60+
61+
- name: Install numactl package
62+
apt:
63+
name: numactl
64+
state: present
65+
update_cache: true
6266

6367
- name: Add systemd configuration if present
6468
copy: src=mongodb.service dest=/lib/systemd/system/mongodb.service owner=root group=root mode=0644
65-
when: mongodb_is_systemd
69+
when: ansible_service_mgr == "systemd"
6670

6771
- name: Add symlink for systemd
6872
file: src=/lib/systemd/system/mongodb.service dest=/etc/systemd/system/multi-user.target.wants/mongodb.service state=link
69-
when: mongodb_is_systemd
70-
notify: reload systemd
71-
72-
- name: reload systemd
73-
shell: systemctl daemon-reload
74-
when: mongodb_is_systemd and mongodb_manage_service
73+
when: ansible_service_mgr == "systemd"
7574

7675
- block:
77-
- meta: flush_handlers
78-
when: mongodb_is_systemd
76+
- meta: flush_handlers
77+
when: ansible_service_mgr == "systemd"
7978

8079
- name: Install PyMongo package
81-
apt: pkg=python-pymongo state=latest
80+
apt:
81+
name: python-pymongo
8282
when: not mongodb_pymongo_from_pip
8383

8484
- name: Install PIP

tasks/install.redhat.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,18 @@
1919

2020
- name: Install MongoDB package
2121
yum:
22-
name: "{{ item }}"
23-
state: present
24-
with_items:
25-
- "{{ mongodb_package }}"
26-
- numactl
22+
name: "{{ mongodb_package }}"
23+
state: "{{ mongodb_package_version is defined | ternary('present', 'latest') }}"
24+
version: "{{ mongodb_package_version | default(omit) }}"
25+
26+
- name: Install numactl package
27+
yum:
28+
name: numactl
2729

2830
- name: Install PyMongo package
2931
yum:
3032
name: python-pymongo
31-
state: latest
33+
state: present
3234
when: not mongodb_pymongo_from_pip
3335

3436
- name: Install PIP

tasks/main.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@
2121
- name: Include replication and auth configuration
2222
include: replication_init_auth.yml
2323
when: ( mongodb_replication_replset
24-
and mongodb_replication_replset != ''
2524
and mongodb_security_authorization == 'enabled'
2625
and mongodb_master is defined and mongodb_master )
2726
tags: [mongodb]
2827

2928
- name: Include replication configuration
3029
include: replication.yml
31-
when: mongodb_replication_replset and mongodb_replication_replset != ''
30+
when: mongodb_replication_replset
3231
tags: [mongodb]
3332

3433
- name: Check where admin user already exists
@@ -40,16 +39,14 @@
4039
check_mode: no
4140
ignore_errors: true
4241
when: ( mongodb_security_authorization == 'enabled'
43-
and (not mongodb_replication_replset
44-
or mongodb_replication_replset == '') )
42+
and not mongodb_replication_replset )
4543
no_log: true
4644
tags: [mongodb]
4745

4846
- name: Include authorization configuration
4947
include: auth_initialization.yml
5048
when: ( mongodb_security_authorization == 'enabled'
51-
and (not mongodb_replication_replset
52-
or mongodb_replication_replset == '')
49+
and not mongodb_replication_replset
5350
and mongodb_user_admin_check.rc != 0 )
5451
tags: [mongodb]
5552

@@ -67,7 +64,6 @@
6764
with_items:
6865
- "{{ mongodb_users | default([]) }}"
6966
when: ( mongodb_replication_replset
70-
and mongodb_replication_replset != ''
7167
and mongodb_security_authorization == 'enabled'
7268
and mongodb_master is defined and mongodb_master )
7369
no_log: true
@@ -86,8 +82,7 @@
8682
with_items:
8783
- "{{ mongodb_users | default([]) }}"
8884
when: ( mongodb_security_authorization == 'enabled'
89-
and (not mongodb_replication_replset
90-
or mongodb_replication_replset == '') )
85+
and not mongodb_replication_replset )
9186
no_log: true
9287
tags: [mongodb]
9388

@@ -107,13 +102,12 @@
107102
with_items:
108103
- "{{ mongodb_oplog_users | default([]) }}"
109104
when: ( mongodb_replication_replset
110-
and mongodb_replication_replset != ''
111105
and mongodb_security_authorization == 'enabled'
112106
and mongodb_master is defined and mongodb_master )
113107
no_log: false
114108
tags: [mongodb]
115109

116110
- name: Include MMS Agent configuration
117111
include: mms-agent.yml
118-
when: mongodb_mms_api_key != ""
112+
when: mongodb_mms_api_key
119113
tags: [mongodb]

tasks/mms-agent.yml

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,22 @@
11
---
2-
3-
- name: Download MMS Agent (Debian)
4-
get_url: url={{mongodb_mms_agent_pkg}} dest={{mongodb_storage_dbpath}}/mms-agent.deb
5-
register: mongodb_mms_agent_loaded
6-
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
7-
82
- name: Install MMS agent (Debian)
93
apt:
10-
deb: "{{mongodb_storage_dbpath}}/mms-agent.deb"
11-
when: mongodb_mms_agent_loaded.changed #and (ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu')
12-
13-
- name: Download MMS Agent (RHEL)
14-
get_url: url={{mongodb_mms_agent_pkg}} dest={{mongodb_storage_dbpath}}/mms-agent.rpm
15-
register: mongodb_mms_agent_loaded
16-
when: ansible_distribution == 'CentOS' or ansible_distribution == 'RedHat'
4+
deb: "{{ mongodb_mms_agent_pkg }}"
5+
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
176

187
- name: Install MMS agent (RHEL)
198
yum:
20-
name: "{{mongodb_storage_dbpath}}/mms-agent.rpm"
9+
name: "{{ mongodb_mms_agent_pkg }}"
2110
state: present
22-
when: mongodb_mms_agent_loaded.changed and (ansible_distribution == 'CentOS' or ansible_distribution == 'RedHat')
11+
when: ansible_distribution == 'CentOS' or ansible_distribution == 'RedHat'
2312

2413
- name: Configure the MMS agent pt. 1
25-
file: state=directory path=/etc/mongodb-mms owner={{mongodb_user}} group={{mongodb_user}} mode=0755
14+
file:
15+
state: directory
16+
path: /etc/mongodb-mms
17+
owner: "{{ mongodb_user }}"
18+
group: "{{ mongodb_user }}"
19+
mode: 0755
2620

2721
- name: Configure the MMS agent pt. 2
2822
template: src=monitoring-agent.config.j2 dest=/etc/mongodb-mms/monitoring-agent.config

0 commit comments

Comments
 (0)