Skip to content

Commit e3b6b75

Browse files
authored
Merge pull request #198 from sportsru/fix_handlers_and_systemd_unit
Fix handlers and systemd unit, speed up tests
2 parents b842529 + 26f5b61 commit e3b6b75

28 files changed

+241
-57
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ tests/*.retry
33
\#*\#
44
.\#*
55
/.python-version
6+
*.pyc

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ dist: trusty
44
sudo: required
55
language: python
66
python:
7-
- "2.7"
7+
- "2.7.15"
88
env:
99
- >
1010
DISTRIBUTION=ubuntu
@@ -46,17 +46,17 @@ env:
4646
DOCKER_PRIVILEGED=true
4747
- >
4848
DISTRIBUTION=ubuntu-upstart
49-
DIST_VERSION=14.04
49+
DIST_VERSION=14_04-builded
5050
MONGODB_VERSION=4.0
5151
DOCKER_PRIVILEGED=true
5252
- >
5353
DISTRIBUTION=ubuntu-upstart
54-
DIST_VERSION=14.04
54+
DIST_VERSION=14_04-builded
5555
MONGODB_VERSION=3.6
5656
DOCKER_PRIVILEGED=true
5757
- >
5858
DISTRIBUTION=ubuntu-upstart
59-
DIST_VERSION=14.04
59+
DIST_VERSION=14_04-builded
6060
MONGODB_VERSION=3.4
6161
DOCKER_PRIVILEGED=true
6262
- >

defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ mongodb_pymongo_pip_version: 3.7.1
1616
mongodb_user_update_password: "on_create" # MongoDB user password update default policy
1717
mongodb_manage_service: true
1818
mongodb_manage_systemd_unit: true
19+
mongodb_systemd_unit_limit_nofile: 64000
20+
mongodb_systemd_unit_limit_nproc: 64000
1921

2022
mongodb_disable_transparent_hugepages: false
2123

handlers/main.yml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,13 @@
33
- name: reload systemd
44
systemd:
55
daemon_reload: yes
6-
when:
7-
- ansible_service_mgr == "systemd"
8-
- mongodb_manage_service | bool
96

107
- name: run disable-transparent-hugepages
118
systemd:
129
name: disable-transparent-hugepages
1310
enabled: true
1411
state: started
1512
daemon_reload: yes
16-
when: ansible_service_mgr == "systemd" and mongodb_disable_transparent_hugepages | bool
17-
18-
- name: mongodb reload
19-
service:
20-
name: "{{ mongodb_daemon_name }}"
21-
state: reloaded
22-
when: mongodb_manage_service | bool
2313

2414
- name: mongodb restart
2515
service:
@@ -38,11 +28,6 @@
3828
name: sysfsutils
3929
state: restarted
4030

41-
- name: service started
42-
service:
43-
name: "{{ mongodb_daemon_name }}"
44-
state: started
45-
4631
- name: wait when mongodb is started
4732
wait_for:
4833
host: "{{ item }}"
@@ -56,3 +41,4 @@
5641
port: "{{ mongodb_net_port }}"
5742
delay: 5
5843
timeout: 120
44+

tasks/configure.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
mode: 0644
8282
notify:
8383
- mongodb restart
84-
- service started
8584
- wait when mongodb is started
8685

8786
- name: Flush all handlers at this point

tasks/disable_transparent_hugepages.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@
1010
- "disable-transparent-hugepages.{{ ansible_distribution | lower }}.service.j2"
1111
- "disable-transparent-hugepages.{{ ansible_os_family | lower }}.service.j2"
1212
notify: "run disable-transparent-hugepages"
13+
when:
14+
- ansible_service_mgr == "systemd"
15+
- mongodb_disable_transparent_hugepages | bool
1316

tasks/install.debian.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
state: present
6060

6161
- name: Add systemd configuration if present
62-
copy:
63-
src: mongodb.service
62+
template:
63+
src: mongodb.service.j2
6464
dest: "/lib/systemd/system/{{mongodb_daemon_name}}.service"
6565
owner: root
6666
group: root

tasks/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@
124124
no_log: false
125125
tags: [mongodb]
126126

127+
- name: service started
128+
service:
129+
name: "{{ mongodb_daemon_name }}"
130+
state: started
131+
enabled: yes
132+
127133
- name: Include MMS Agent configuration
128134
include: mms-agent.yml
129135
when: mongodb_mms_api_key | length > 0

tasks/mms-agent.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@
1919
mode: 0755
2020

2121
- name: Configure the MMS agent pt. 2
22-
template: src=monitoring-agent.config.j2 dest=/etc/mongodb-mms/monitoring-agent.config
22+
template:
23+
src: monitoring-agent.config.j2
24+
dest: /etc/mongodb-mms/monitoring-agent.config
2325
notify: mongodb-mms-monitoring-agent restart
2426

2527
- name: Ensure that the MMS agent is started
26-
service: name=mongodb-mms-monitoring-agent state=started enabled=yes
27-
when: mongodb_manage_service
28+
service:
29+
name: mongodb-mms-monitoring-agent
30+
state: started
31+
enabled: yes
32+

tasks/replication.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
with_items:
2020
- "{{ mongodb_replication_params|default([]) }}"
2121

22-
- name: Replication configuration without auth
22+
- name: Replication configuration without auth on master
2323
mongodb_replication:
2424
build_indexes: "{{ item.build_indexes|default(omit) }}"
2525
login_host: "{{ mongodb_login_host|default('localhost') }}"
@@ -32,6 +32,26 @@
3232
priority: "{{ item.priority|default(1.0) }}"
3333
votes: "{{ item.votes|default(omit) }}"
3434
ssl: "{{ True if mongodb_net_ssl_mode == 'requireSSL' else False }}"
35-
when: mongodb_security_authorization == 'disabled'
35+
when: ( mongodb_security_authorization == 'disabled'
36+
and mongodb_master is defined and mongodb_master )
3637
with_items:
3738
- "{{ mongodb_replication_params|default([]) }}"
39+
40+
- name: Replication configuration without auth on replicas and arbiters
41+
mongodb_replication:
42+
build_indexes: "{{ item.build_indexes|default(omit) }}"
43+
login_host: "{{ mongodb_login_host|default('localhost') }}"
44+
login_port: "{{ mongodb_login_port|default(27017) }}"
45+
replica_set: "{{ mongodb_replication_replset }}"
46+
host_name: "{{ item.host_name }}"
47+
host_port: "{{ item.host_port|default(27017) }}"
48+
host_type: "{{ item.host_type|default('replica') }}"
49+
hidden: "{{ item.hidden|default(false) }}"
50+
priority: "{{ item.priority|default(1.0) }}"
51+
votes: "{{ item.votes|default(omit) }}"
52+
ssl: "{{ True if mongodb_net_ssl_mode == 'requireSSL' else False }}"
53+
when: ( mongodb_security_authorization == 'disabled'
54+
and ( mongodb_master is not defined or not mongodb_master) )
55+
with_items:
56+
- "{{ mongodb_replication_params|default([]) }}"
57+

0 commit comments

Comments
 (0)