Skip to content

Commit 543d5c7

Browse files
fix(macos): launchctl and plist fixes
1 parent 274e50b commit 543d5c7

File tree

11 files changed

+134
-39
lines changed

11 files changed

+134
-39
lines changed

mongodb/clean.sls

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{%- set tplroot = tpldir.split('/')[0] %}
55
{%- from tplroot ~ "/map.jinja" import data as d with context %}
66
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
7-
{%- set sls_config_clean = tplroot ~ '.config.users' %}
7+
{%- set sls_config_clean = tplroot ~ '.config.clean' %}
88
{%- set sls_service_clean = tplroot ~ '.service.clean' %}
99
{%- set formula = d.formula %}
1010
@@ -15,14 +15,16 @@ include:
1515
{{ formula }}-clean-prerequisites:
1616
pip.removed:
1717
- names: {{ d.pkg.pips|json }}
18+
- require:
19+
- sls: {{ sls_service_clean }}
20+
- sls: {{ sls_config_clean }}
21+
- require_in:
22+
- file: {{ formula }}-clean-prerequisites
1823
file.absent:
1924
- names:
2025
- {{ d.dir.tmp }}
2126
- {{ d.dir.var }}
2227
- /tmp/mac_shortcut.sh
23-
- require:
24-
- sls: {{ sls_service_clean }}
25-
- sls: {{ sls_config_clean }}
2628
2729
{%- for comp in d.components %}
2830
{%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %}
@@ -42,6 +44,8 @@ include:
4244
- file: {{ formula }}-clean-prerequisites
4345
file.absent:
4446
- name: {{ software['path'] }}
47+
- require:
48+
- file: {{ formula }}-clean-prerequisites
4549
{%- if d.use_upstream == 'repo' %}
4650
pkgrepo.absent:
4751
- name: {{ d.pkg['repo']['name'] }}
@@ -81,8 +85,8 @@ include:
8185
- {{ d.dir.var }}/{{ name }}
8286
- {{ d.dir.service }}/{{ name }}.service
8387
- /Library/LaunchAgents/{{ name if 'name' not in service else service.name }}.plist
84-
# require:
85-
# file: {{ formula }}-clean-prerequisites
88+
- require:
89+
- file: {{ formula }}-clean-prerequisites
8690
cmd.run:
8791
- name: systemctl daemon-reload >/dev/null 2>&1 || true
8892
- onlyif: {{ grains.kernel|lower == 'linux' }}

mongodb/config/alternatives/clean.sls

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,12 @@
3333
{%- endfor %} {# component #}
3434
{%- endif %} {# wanted #}
3535
{%- endfor %} {# components #}
36+
37+
{%- else %}
38+
39+
{{ formula }}-config-alternatives-clean-notification:
40+
test.show_notification:
41+
- text: |
42+
Note: The linux alternatives state is not applicable for {{ grains.os }}
43+
3644
{%- endif %} {# linux #}

mongodb/config/alternatives/install.sls

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,12 @@ include:
5858
{%- endfor %} {# component #}
5959
{%- endif %} {# wanted #}
6060
{%- endfor %} {# components #}
61+
62+
{%- else %}
63+
64+
{{ formula }}-config-alternatives-install-notification:
65+
test.show_notification:
66+
- text: |
67+
Note: The linux alternatives state is not applicable for {{ grains.os }}
68+
6169
{%- endif %} {# linux #}

mongodb/config/clean.sls

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ include:
2828
- group: {{ formula }}-config-clean-{{ name }}-usergroup
2929
- require:
3030
- sls: {{ sls_service_clean }}
31+
- sls: {{ sls_alternatives_clean }}
3132
group.absent:
3233
- name: {{ d.default.group if 'group' not in software else software['group'] }}
34+
- require:
35+
- user: {{ formula }}-config-clean-{{ name }}-usergroup
3336
{%- endif %} {# users #}
3437
3538
{{ formula }}-config-clean-{{ name }}-files:
@@ -47,6 +50,7 @@ include:
4750
{%- endif %}
4851
- require:
4952
- sls: {{ sls_service_clean }}
53+
- sls: {{ sls_alternatives_clean }}
5054
5155
{%- endif %} {# wanted #}
5256
{%- endfor %} {# component #}

mongodb/config/file.sls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ include:
2121
- makedirs: True
2222
- require:
2323
- sls: {{ sls_software_install }}
24+
- sls: {{ sls_config_users }}
2425
2526
{%- for comp in d.components %}
2627
{%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %}

mongodb/config/users.sls

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
{%- set tplroot = tpldir.split('/')[0] %}
55
{%- from tplroot ~ "/map.jinja" import data as d with context %}
66
{%- set formula = d.formula %}
7+
{%- set sls_software_install = tplroot ~ '.install' %}
8+
9+
include:
10+
- {{ sls_software_install }}
711
812
{%- for comp in d.components %}
913
{%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %}
@@ -19,6 +23,8 @@
1923
- name: {{ d.default.group if 'group' not in software else software['group'] }}
2024
- require_in:
2125
- user: {{ formula }}-config-usergroup-{{ servicename }}-install-usergroup-present
26+
- require_in:
27+
- sls: {{ sls_software_install }}
2228
user.present:
2329
- name: {{ user }}
2430
- shell: /bin/false

mongodb/defaults.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ mongodb:
7171
# http://docs.mongodb.org/manual/reference/configuration-options
7272
storage:
7373
dbPath: /var/lib/mongodb/mongod
74+
systemLog:
75+
quiet: true
76+
traceAllExceptions: false
77+
path: /var/log/mongodb/mongod.log
78+
destination: file
79+
logAppend: true
7480
# replication:
7581
# replSetName: "rs1"
7682
# sharding:
@@ -109,6 +115,10 @@ mongodb:
109115
config:
110116
sharding:
111117
configDB: 'rs1/127.0.0.1:27018'
118+
systemLog:
119+
quiet: true
120+
traceAllExceptions: false
121+
path: /var/log/mongodb/mongos.log
112122
service:
113123
name: mongos
114124
firewall:

mongodb/files/default/macos.plist.jinja

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@
66
<string>org.mongo.mongodb.{{ svc }}</string>
77
<key>ProgramArguments</key>
88
<array>
9-
<string>{{ binpath }}/bin/{{ svc }} </string>
10-
<string>--config </string>
9+
<string>{{ binpath }}/bin/{{ svc }}</string>
10+
<string>{{ '--config' }}</string>
1111
<string>{{ config }}</string>
1212
</array>
1313
<key>RunAtLoad</key>
1414
<true/>
15-
<key>UserName</key>
16-
<string>{{ user }}</string>
1715
<key>StandardErrorPath</key>
18-
<string>/dev/null</string>
16+
<string>/var/log/mongodb/{{ svc }}.log</string>
1917
<key>StandardOutPath</key>
20-
<string>/dev/null</string>
18+
<string>/var/log/mongodb/{{ svc }}.log</string>
2119
</dict>
2220
</plist>

mongodb/install.sls

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@ include:
124124
- group: {{ d.identity.rootgroup }}
125125
- require:
126126
- file: {{ formula }}-{{ comp }}-{{ name }}-{{ package }}-install
127+
- unless:
128+
- test -f {{ software['path'] }}/dummyFILENAME
129+
{%- if 'commands' in software and software['commands'] is iterable %}
130+
{%- for cmd in software['commands'] %}
131+
- test -x {{ software['path'] }}/bin/{{ cmd }}
132+
{%- endfor %}
133+
{%- endif %}
127134
128135
{%- else %}
129136
test.show_notification:

mongodb/service/clean.sls

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,32 @@ include:
2020
{%- set servicename = name if 'service' not in software else software.service.name %}
2121
2222
{{ formula }}-service-dead-{{ comp }}-{{ servicename }}-clean:
23+
{%- if grains.kernel|lower == 'darwin' %} {# service.running is buggy #}
24+
cmd.run:
25+
- names:
26+
- launchctl stop {{ servicename }} || true
27+
- launchctl unload /Library/LaunchAgents/{{ servicename }}.plist || true
28+
{%- else %}
2329
service.dead:
2430
- name: {{ servicename }}
2531
{% if grains.kernel|lower == 'linux' %}
2632
- onlyif: systemctl list-units |grep {{ servicename }} >/dev/null 2>&1
2733
{%- endif %} {# linux #}
2834
- enable: False
35+
{%- endif %}
36+
- require_in:
37+
- sls: {{ sls_config_clean }}
2938
file.absent:
3039
- names:
3140
- {{ d.dir.service }}/{{ servicename }}.service
3241
- /etc/logrotate.d/{{ formula }}_{{ servicename }}
42+
{%- if 'systemLog' in config and 'destination' in config['systemLog'] %}
43+
{%- if config['systemLog']['destination'] == 'file' %}
44+
- {{ config['systemLog']['path'] }}
45+
{%- else %}
46+
- {{ '/var/log/mongodb/' ~ servicename ~ '.log' }}
47+
{%- endif %}
48+
{%- endif %}
3349
- require_in:
3450
- sls: {{ sls_config_clean }}
3551
{% if grains.kernel|lower == 'linux' %}
@@ -43,18 +59,20 @@ include:
4359
file.absent:
4460
- names:
4561
- /tmp/MySiLydUmMyFiLE
46-
{%- if 'processManagement' in config and config['processManagement']['pidFilePath'] %}
62+
{%- if 'processManagement' in config and 'pidFilePath' in config['processManagement'] %}
4763
- {{ config['processManagement']['pidFilePath'] }}
48-
{%- endif %}
49-
{%- if 'storage' in config and 'dbPath' in config['storage'] %}
64+
{%- else %}
65+
- {{ '/var/run/{{ name }}.pid' }}
66+
{%- endif %}
67+
{%- if 'storage' in config and 'dbPath' in config['storage'] %}
5068
- {{ config['storage']['dbPath'] }}
51-
{%- endif %}
52-
{%- if 'schema' in config and 'path' in config['schema'] %}
69+
{%- endif %}
70+
{%- if 'schema' in config and 'path' in config['schema'] %}
5371
- {{ config['schema']['path'] }}
54-
{%- endif %}
55-
{%- if 'systemLog' in config and 'path' in config['systemLog'] %}
72+
{%- endif %}
73+
{%- if 'systemLog' in config and 'path' in config['systemLog'] %}
5674
- {{ config['systemLog']['path'] }}
57-
{%- endif %}
75+
{%- endif %}
5876
- require_in:
5977
- sls: {{ sls_config_clean }}
6078

0 commit comments

Comments
 (0)