From 25a6883d36540a78baea2d478ed3a22180d04c28 Mon Sep 17 00:00:00 2001 From: N Date: Tue, 21 Jul 2020 17:39:16 +0100 Subject: [PATCH 1/7] fix(macos): hugepages in linux kernel only --- mongodb/service/running.sls | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mongodb/service/running.sls b/mongodb/service/running.sls index 5ad347c5..a430d1d5 100644 --- a/mongodb/service/running.sls +++ b/mongodb/service/running.sls @@ -15,15 +15,16 @@ include: file.managed: - name: /etc/init.d/disable-transparent-hugepages - source: salt://{{ formula }}/files/disable-transparent-hugepages.init - - unless: test -f /etc/init.d/disable-transparent-hugepages - - onlyif: {{ d.wanted.disable_transparent_hugepages }} + - unless: test -f /etc/init.d/disable-transparent-hugepages 2>/dev/null + - onlyif: {{ grains.kernel|lower == 'linux' and d.wanted.disable_transparent_hugepages }} - mode: '0755' - makedirs: True - require: - sls: {{ sls_software_install }} cmd.run: - name: echo never >/sys/kernel/mm/transparent_hugepage/enabled - - onlyif: {{ d.wanted.disable_transparent_hugepages }} + - unless: test -f /etc/init.d/disable-transparent-hugepages 2>/dev/null + - onlyif: {{ grains.kernel|lower == 'linux' and d.wanted.disable_transparent_hugepages }} - require: - file: {{ formula }}-service-running-prerequisites {%- if d.wanted.firewall %} From 2f076757cf31b216d11699d7604f5dc36614e454 Mon Sep 17 00:00:00 2001 From: N Date: Wed, 22 Jul 2020 14:43:35 +0100 Subject: [PATCH 2/7] refactor(jinja): depreciate/replacer two variable names --- mongodb/clean.sls | 6 +++--- mongodb/config/alternatives/clean.sls | 2 +- mongodb/config/alternatives/install.sls | 2 +- mongodb/config/clean.sls | 2 +- mongodb/config/environ.sls | 2 +- mongodb/config/file.sls | 2 +- mongodb/config/users.sls | 2 +- mongodb/defaults.yaml | 5 ++--- mongodb/install.sls | 6 +++--- mongodb/map.jinja | 13 +++++++++++-- mongodb/osfamilymap.yaml | 5 ++--- mongodb/service/clean.sls | 2 +- mongodb/service/running.sls | 2 +- 13 files changed, 29 insertions(+), 22 deletions(-) diff --git a/mongodb/clean.sls b/mongodb/clean.sls index cbde49e0..597e9bb4 100644 --- a/mongodb/clean.sls +++ b/mongodb/clean.sls @@ -24,13 +24,13 @@ include: - sls: {{ sls_service_clean }} - sls: {{ sls_config_clean }} - {%- for comp in d.software_component_matrix %} + {%- for comp in d.components %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} {%- set software = d.pkg[comp][name] %} {%- set package = software.package_format %} - {%- if package in d.software_package_matrix %} + {%- if package in d.use_upstream %} {#- PACKAGE CLEAN #} {%- if package in software and software[package] is mapping %} @@ -42,7 +42,7 @@ include: - file: {{ formula }}-clean-prerequisites file.absent: - name: {{ software['path'] }} - {%- if d.wanted.upstream_repo %} + {%- if d.use_upstream == 'repo' %} pkgrepo.absent: - name: {{ d.pkg['repo']['name'] }} {%- endif %} diff --git a/mongodb/config/alternatives/clean.sls b/mongodb/config/alternatives/clean.sls index 27f76085..fe2a2a39 100644 --- a/mongodb/config/alternatives/clean.sls +++ b/mongodb/config/alternatives/clean.sls @@ -6,7 +6,7 @@ {%- set formula = d.formula %} {%- if grains.kernel|lower == 'linux' and d.linux.altpriority|int > 0 and grains.os_family != 'Arch' %} - {%- for comp in d.software_component_matrix %} + {%- for comp in d.components %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} diff --git a/mongodb/config/alternatives/install.sls b/mongodb/config/alternatives/install.sls index a7b97480..a287ad26 100644 --- a/mongodb/config/alternatives/install.sls +++ b/mongodb/config/alternatives/install.sls @@ -10,7 +10,7 @@ include: - {{ sls_software_install }} {%- if grains.kernel|lower == 'linux' and d.linux.altpriority|int > 0 and grains.os_family != 'Arch' %} - {%- for comp in d.software_component_matrix %} + {%- for comp in d.components %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} diff --git a/mongodb/config/clean.sls b/mongodb/config/clean.sls index a72b518d..c0416cce 100644 --- a/mongodb/config/clean.sls +++ b/mongodb/config/clean.sls @@ -11,7 +11,7 @@ include: - {{ sls_service_clean }} - {{ sls_alternatives_clean }} - {%- for comp in d.software_component_matrix %} + {%- for comp in d.components %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} diff --git a/mongodb/config/environ.sls b/mongodb/config/environ.sls index d3d9f7f0..c5504036 100644 --- a/mongodb/config/environ.sls +++ b/mongodb/config/environ.sls @@ -10,7 +10,7 @@ include: - {{ sls_software_install }} - {%- for comp in d.software_component_matrix %} + {%- for comp in d.components %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} diff --git a/mongodb/config/file.sls b/mongodb/config/file.sls index ce858b42..81267b80 100644 --- a/mongodb/config/file.sls +++ b/mongodb/config/file.sls @@ -22,7 +22,7 @@ include: - require: - sls: {{ sls_software_install }} - {%- for comp in d.software_component_matrix %} + {%- for comp in d.components %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} diff --git a/mongodb/config/users.sls b/mongodb/config/users.sls index 34a98417..950cbfa8 100644 --- a/mongodb/config/users.sls +++ b/mongodb/config/users.sls @@ -5,7 +5,7 @@ {%- from tplroot ~ "/map.jinja" import data as d with context %} {%- set formula = d.formula %} - {%- for comp in d.software_component_matrix %} + {%- for comp in d.components %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} diff --git a/mongodb/defaults.yaml b/mongodb/defaults.yaml index b2ecfd6b..60f2bd78 100644 --- a/mongodb/defaults.yaml +++ b/mongodb/defaults.yaml @@ -2,8 +2,8 @@ # vim: ft=yaml --- mongodb: - software_component_matrix: ['database', 'gui', 'connectors'] - software_package_matrix: ['archive', 'macapp', 'native'] + components: ['database', 'gui', 'connectors'] # depreciate software_component_matrix + use_upstream: ['archive', 'macapp', 'repo'] # depreciate software_package_matrix wanted: database: - mongod @@ -12,7 +12,6 @@ mongodb: firewall: false selinux: false disable_transparent_hugepages: true - upstream_repo: false default: user: mongodb group: mongodb diff --git a/mongodb/install.sls b/mongodb/install.sls index d8a750d6..9fefeaaa 100644 --- a/mongodb/install.sls +++ b/mongodb/install.sls @@ -31,13 +31,13 @@ include: - pkg: {{ formula }}-install-prerequisites - pip: {{ formula }}-install-prerequisites - {%- for comp in d.software_component_matrix %} + {%- for comp in d.components %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} {%- set software = d.pkg[comp][name] %} {%- set package = software.package_format %} - {%- if package in d.software_package_matrix %} + {%- if package in d.use_upstream %} {# DOWNLOAD NATIVE PACKAGE #} @@ -76,7 +76,7 @@ include: {#- NATIVE PACKAGE INSTALL #} {%- if package == 'native' %} - {%- if d.wanted.upstream_repo and 'repo' in d.pkg and d.pkg.repo %} + {%- if d.use_upstream = 'repo' and 'repo' in d.pkg and d.pkg.repo %} pkgrepo.managed: {{- format_kwargs(d.pkg['repo']) }} {%- endif %} diff --git a/mongodb/map.jinja b/mongodb/map.jinja index efc334cf..534a93dc 100644 --- a/mongodb/map.jinja +++ b/mongodb/map.jinja @@ -22,9 +22,18 @@ ) %} +# depreciate two params +{%- if 'software_component_matrix' in d %} + {%- do d.update({ 'components': d.software_component_matrix %} +{%- endif %} +{%- if 'software_package_matrix' in d %} + {%- do d.update({ 'use_upstream': d.software_package_matrix %} +{%- endif %} + +# build dict {%- set d = salt['grains.filter_by']( {'defaults': defaults}, default='defaults', merge=_config) %} -{%- for comp in d.software_component_matrix %} +{%- for comp in d.components %} {%- if comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- set software = d.pkg[comp][name] %} @@ -34,7 +43,7 @@ {%- set release = v.version.split('.')[0] ~ '.' ~ v.version.split('.')[1] %} {%- set dir = '%s-%s'|format(name, v.version) %} {%- set path = d.dir.archive ~ '/' ~ dir %} - {%- for package in d.software_package_matrix %} + {%- for package in d.use_upstream %} {%- if package in v and v[package] %} {%- set path = d.dir[package] if package == 'macapp' else path %} {%- do software[package].update({'name': path}) %} diff --git a/mongodb/osfamilymap.yaml b/mongodb/osfamilymap.yaml index e3cf540b..7037ea27 100644 --- a/mongodb/osfamilymap.yaml +++ b/mongodb/osfamilymap.yaml @@ -28,10 +28,9 @@ Arch: Alpine: {} Debian: + use_upstream: 'archive' # using 'repo' caused a conflict wanted: firewall: false - # package conflict occured when true - upstream_repo: false pkg: deps: - curl @@ -61,10 +60,10 @@ Debian: skip_verify: false RedHat: + use_upstream: 'repo' wanted: firewall: false # turned off for travis ci selinux: false # turrned off for travs citrue - upstream_repo: true default: user: mongod group: mongod diff --git a/mongodb/service/clean.sls b/mongodb/service/clean.sls index 7e29e968..5b9a845c 100644 --- a/mongodb/service/clean.sls +++ b/mongodb/service/clean.sls @@ -9,7 +9,7 @@ include: - {{ sls_config_clean }} - {%- for comp in d.software_component_matrix %} + {%- for comp in d.components %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} diff --git a/mongodb/service/running.sls b/mongodb/service/running.sls index a430d1d5..20f0556c 100644 --- a/mongodb/service/running.sls +++ b/mongodb/service/running.sls @@ -37,7 +37,7 @@ include: - enable: True {%- endif %} - {%- for comp in d.software_component_matrix %} + {%- for comp in d.components %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} From 309f0963570baa9dbbe242ed9af20da3d63e0c41 Mon Sep 17 00:00:00 2001 From: N Date: Wed, 22 Jul 2020 14:50:06 +0100 Subject: [PATCH 3/7] chore(conditional): check if linux --- mongodb/service/running.sls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongodb/service/running.sls b/mongodb/service/running.sls index 20f0556c..499fca4d 100644 --- a/mongodb/service/running.sls +++ b/mongodb/service/running.sls @@ -27,7 +27,7 @@ include: - onlyif: {{ grains.kernel|lower == 'linux' and d.wanted.disable_transparent_hugepages }} - require: - file: {{ formula }}-service-running-prerequisites - {%- if d.wanted.firewall %} + {%- if d.wanted.firewall and grains.kernel|lower == 'linux' %} pkg.installed: - name: firewalld - reload_modules: true From 274e50ba35b73d2d9fea1991ac246a48cd21b65e Mon Sep 17 00:00:00 2001 From: N Date: Wed, 22 Jul 2020 14:57:02 +0100 Subject: [PATCH 4/7] fix(config): rename config file to .conf --- mongodb/clean.sls | 5 +++-- mongodb/config/clean.sls | 2 +- mongodb/config/file.sls | 2 +- mongodb/files/default/macos.plist.jinja | 2 ++ mongodb/install.sls | 3 ++- mongodb/map.jinja | 9 ++++----- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/mongodb/clean.sls b/mongodb/clean.sls index 597e9bb4..63ddbcd5 100644 --- a/mongodb/clean.sls +++ b/mongodb/clean.sls @@ -81,10 +81,11 @@ include: - {{ d.dir.var }}/{{ name }} - {{ d.dir.service }}/{{ name }}.service - /Library/LaunchAgents/{{ name if 'name' not in service else service.name }}.plist - - require: - - file: {{ formula }}-clean-prerequisites + # require: + # file: {{ formula }}-clean-prerequisites cmd.run: - name: systemctl daemon-reload >/dev/null 2>&1 || true + - onlyif: {{ grains.kernel|lower == 'linux' }} - onchange: - file: {{ formula }}-{{ comp }}-{{ package }}-{{ name }}-clean-service diff --git a/mongodb/config/clean.sls b/mongodb/config/clean.sls index c0416cce..8b6564e1 100644 --- a/mongodb/config/clean.sls +++ b/mongodb/config/clean.sls @@ -37,7 +37,7 @@ include: - names: {%- if 'service' in software and software['service'] is mapping %} {%- set servicename = name if 'service' not in software else software.service.name %} - - {{ d.dir.etc }}/{{ servicename|replace('org.mongo.mongodb.', '') }}.yml + - {{ d.dir.etc }}/{{ servicename|replace('org.mongo.mongodb.', '') }}.conf {%- endif %} {%- if 'config_file' in software and 'config' in software and software['config'] is mapping %} - {{ software['config_file'] }} diff --git a/mongodb/config/file.sls b/mongodb/config/file.sls index 81267b80..6019a616 100644 --- a/mongodb/config/file.sls +++ b/mongodb/config/file.sls @@ -33,7 +33,7 @@ include: {{ formula }}-config-file-{{ servicename }}-file-managed: file.managed: - - name: {{ d.dir.etc }}/{{ servicename|replace('org.mongo.mongodb.', '') }}.yml + - name: {{ d.dir.etc }}/{{ servicename|replace('org.mongo.mongodb.', '') }}.conf - source: {{ files_switch(['config.yml.jinja'], lookup=formula ~ '-config-file-' ~ servicename ~ '-file-managed' ) diff --git a/mongodb/files/default/macos.plist.jinja b/mongodb/files/default/macos.plist.jinja index 33985740..a1707fe0 100644 --- a/mongodb/files/default/macos.plist.jinja +++ b/mongodb/files/default/macos.plist.jinja @@ -12,6 +12,8 @@ RunAtLoad + UserName + {{ user }} StandardErrorPath /dev/null StandardOutPath diff --git a/mongodb/install.sls b/mongodb/install.sls index 9fefeaaa..1aabc18b 100644 --- a/mongodb/install.sls +++ b/mongodb/install.sls @@ -76,7 +76,7 @@ include: {#- NATIVE PACKAGE INSTALL #} {%- if package == 'native' %} - {%- if d.use_upstream = 'repo' and 'repo' in d.pkg and d.pkg.repo %} + {%- if d.use_upstream == 'repo' and 'repo' in d.pkg and d.pkg.repo %} pkgrepo.managed: {{- format_kwargs(d.pkg['repo']) }} {%- endif %} @@ -261,6 +261,7 @@ include: svc: {{ servicename|replace('org.mongo.mongodb.', '') }} config: {{ software['config_file'] }} binpath: {{ software['path'] }} + user: {{ d.default.user if 'user' not in software else software['user'] }} {%- endif %} {# linux/darwin #} {%- endif %} {# service #} diff --git a/mongodb/map.jinja b/mongodb/map.jinja index 534a93dc..08bbb507 100644 --- a/mongodb/map.jinja +++ b/mongodb/map.jinja @@ -20,19 +20,18 @@ ) ) ) - %} +%} +{%- set d = salt['grains.filter_by']( {'defaults': defaults}, default='defaults', merge=_config) %} # depreciate two params {%- if 'software_component_matrix' in d %} - {%- do d.update({ 'components': d.software_component_matrix %} + {%- do d.update({ 'components': d.software_component_matrix }) %} {%- endif %} {%- if 'software_package_matrix' in d %} - {%- do d.update({ 'use_upstream': d.software_package_matrix %} + {%- do d.update({ 'use_upstream': d.software_package_matrix }) %} {%- endif %} # build dict -{%- set d = salt['grains.filter_by']( {'defaults': defaults}, default='defaults', merge=_config) %} - {%- for comp in d.components %} {%- if comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} From 543d5c7e6c0ff8a9de0b2cf3e086dee090a8fabd Mon Sep 17 00:00:00 2001 From: N Date: Wed, 22 Jul 2020 17:13:53 +0100 Subject: [PATCH 5/7] fix(macos): launchctl and plist fixes --- mongodb/clean.sls | 16 +++--- mongodb/config/alternatives/clean.sls | 8 +++ mongodb/config/alternatives/install.sls | 8 +++ mongodb/config/clean.sls | 4 ++ mongodb/config/file.sls | 1 + mongodb/config/users.sls | 6 +++ mongodb/defaults.yaml | 10 ++++ mongodb/files/default/macos.plist.jinja | 10 ++-- mongodb/install.sls | 7 +++ mongodb/service/clean.sls | 34 +++++++++--- mongodb/service/running.sls | 69 ++++++++++++++++++------- 11 files changed, 134 insertions(+), 39 deletions(-) diff --git a/mongodb/clean.sls b/mongodb/clean.sls index 63ddbcd5..0fc4e137 100644 --- a/mongodb/clean.sls +++ b/mongodb/clean.sls @@ -4,7 +4,7 @@ {%- set tplroot = tpldir.split('/')[0] %} {%- from tplroot ~ "/map.jinja" import data as d with context %} {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} -{%- set sls_config_clean = tplroot ~ '.config.users' %} +{%- set sls_config_clean = tplroot ~ '.config.clean' %} {%- set sls_service_clean = tplroot ~ '.service.clean' %} {%- set formula = d.formula %} @@ -15,14 +15,16 @@ include: {{ formula }}-clean-prerequisites: pip.removed: - names: {{ d.pkg.pips|json }} + - require: + - sls: {{ sls_service_clean }} + - sls: {{ sls_config_clean }} + - require_in: + - file: {{ formula }}-clean-prerequisites file.absent: - names: - {{ d.dir.tmp }} - {{ d.dir.var }} - /tmp/mac_shortcut.sh - - require: - - sls: {{ sls_service_clean }} - - sls: {{ sls_config_clean }} {%- for comp in d.components %} {%- 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: - file: {{ formula }}-clean-prerequisites file.absent: - name: {{ software['path'] }} + - require: + - file: {{ formula }}-clean-prerequisites {%- if d.use_upstream == 'repo' %} pkgrepo.absent: - name: {{ d.pkg['repo']['name'] }} @@ -81,8 +85,8 @@ include: - {{ d.dir.var }}/{{ name }} - {{ d.dir.service }}/{{ name }}.service - /Library/LaunchAgents/{{ name if 'name' not in service else service.name }}.plist - # require: - # file: {{ formula }}-clean-prerequisites + - require: + - file: {{ formula }}-clean-prerequisites cmd.run: - name: systemctl daemon-reload >/dev/null 2>&1 || true - onlyif: {{ grains.kernel|lower == 'linux' }} diff --git a/mongodb/config/alternatives/clean.sls b/mongodb/config/alternatives/clean.sls index fe2a2a39..38e21ed3 100644 --- a/mongodb/config/alternatives/clean.sls +++ b/mongodb/config/alternatives/clean.sls @@ -33,4 +33,12 @@ {%- endfor %} {# component #} {%- endif %} {# wanted #} {%- endfor %} {# components #} + +{%- else %} + +{{ formula }}-config-alternatives-clean-notification: + test.show_notification: + - text: | + Note: The linux alternatives state is not applicable for {{ grains.os }} + {%- endif %} {# linux #} diff --git a/mongodb/config/alternatives/install.sls b/mongodb/config/alternatives/install.sls index a287ad26..6eb87505 100644 --- a/mongodb/config/alternatives/install.sls +++ b/mongodb/config/alternatives/install.sls @@ -58,4 +58,12 @@ include: {%- endfor %} {# component #} {%- endif %} {# wanted #} {%- endfor %} {# components #} + +{%- else %} + +{{ formula }}-config-alternatives-install-notification: + test.show_notification: + - text: | + Note: The linux alternatives state is not applicable for {{ grains.os }} + {%- endif %} {# linux #} diff --git a/mongodb/config/clean.sls b/mongodb/config/clean.sls index 8b6564e1..5ba0a731 100644 --- a/mongodb/config/clean.sls +++ b/mongodb/config/clean.sls @@ -28,8 +28,11 @@ include: - group: {{ formula }}-config-clean-{{ name }}-usergroup - require: - sls: {{ sls_service_clean }} + - sls: {{ sls_alternatives_clean }} group.absent: - name: {{ d.default.group if 'group' not in software else software['group'] }} + - require: + - user: {{ formula }}-config-clean-{{ name }}-usergroup {%- endif %} {# users #} {{ formula }}-config-clean-{{ name }}-files: @@ -47,6 +50,7 @@ include: {%- endif %} - require: - sls: {{ sls_service_clean }} + - sls: {{ sls_alternatives_clean }} {%- endif %} {# wanted #} {%- endfor %} {# component #} diff --git a/mongodb/config/file.sls b/mongodb/config/file.sls index 6019a616..bdfd7cc5 100644 --- a/mongodb/config/file.sls +++ b/mongodb/config/file.sls @@ -21,6 +21,7 @@ include: - makedirs: True - require: - sls: {{ sls_software_install }} + - sls: {{ sls_config_users }} {%- for comp in d.components %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} diff --git a/mongodb/config/users.sls b/mongodb/config/users.sls index 950cbfa8..f0f01776 100644 --- a/mongodb/config/users.sls +++ b/mongodb/config/users.sls @@ -4,6 +4,10 @@ {%- set tplroot = tpldir.split('/')[0] %} {%- from tplroot ~ "/map.jinja" import data as d with context %} {%- set formula = d.formula %} +{%- set sls_software_install = tplroot ~ '.install' %} + +include: + - {{ sls_software_install }} {%- for comp in d.components %} {%- 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 @@ - name: {{ d.default.group if 'group' not in software else software['group'] }} - require_in: - user: {{ formula }}-config-usergroup-{{ servicename }}-install-usergroup-present + - require_in: + - sls: {{ sls_software_install }} user.present: - name: {{ user }} - shell: /bin/false diff --git a/mongodb/defaults.yaml b/mongodb/defaults.yaml index 60f2bd78..0d98c295 100644 --- a/mongodb/defaults.yaml +++ b/mongodb/defaults.yaml @@ -71,6 +71,12 @@ mongodb: # http://docs.mongodb.org/manual/reference/configuration-options storage: dbPath: /var/lib/mongodb/mongod + systemLog: + quiet: true + traceAllExceptions: false + path: /var/log/mongodb/mongod.log + destination: file + logAppend: true # replication: # replSetName: "rs1" # sharding: @@ -109,6 +115,10 @@ mongodb: config: sharding: configDB: 'rs1/127.0.0.1:27018' + systemLog: + quiet: true + traceAllExceptions: false + path: /var/log/mongodb/mongos.log service: name: mongos firewall: diff --git a/mongodb/files/default/macos.plist.jinja b/mongodb/files/default/macos.plist.jinja index a1707fe0..3cc752f5 100644 --- a/mongodb/files/default/macos.plist.jinja +++ b/mongodb/files/default/macos.plist.jinja @@ -6,17 +6,15 @@ org.mongo.mongodb.{{ svc }} ProgramArguments - {{ binpath }}/bin/{{ svc }} - --config + {{ binpath }}/bin/{{ svc }} + {{ '--config' }} {{ config }} RunAtLoad - UserName - {{ user }} StandardErrorPath - /dev/null + /var/log/mongodb/{{ svc }}.log StandardOutPath - /dev/null + /var/log/mongodb/{{ svc }}.log diff --git a/mongodb/install.sls b/mongodb/install.sls index 1aabc18b..4cd48a1e 100644 --- a/mongodb/install.sls +++ b/mongodb/install.sls @@ -124,6 +124,13 @@ include: - group: {{ d.identity.rootgroup }} - require: - file: {{ formula }}-{{ comp }}-{{ name }}-{{ package }}-install + - unless: + - test -f {{ software['path'] }}/dummyFILENAME + {%- if 'commands' in software and software['commands'] is iterable %} + {%- for cmd in software['commands'] %} + - test -x {{ software['path'] }}/bin/{{ cmd }} + {%- endfor %} + {%- endif %} {%- else %} test.show_notification: diff --git a/mongodb/service/clean.sls b/mongodb/service/clean.sls index 5b9a845c..6746b5f9 100644 --- a/mongodb/service/clean.sls +++ b/mongodb/service/clean.sls @@ -20,16 +20,32 @@ include: {%- set servicename = name if 'service' not in software else software.service.name %} {{ formula }}-service-dead-{{ comp }}-{{ servicename }}-clean: + {%- if grains.kernel|lower == 'darwin' %} {# service.running is buggy #} + cmd.run: + - names: + - launchctl stop {{ servicename }} || true + - launchctl unload /Library/LaunchAgents/{{ servicename }}.plist || true + {%- else %} service.dead: - name: {{ servicename }} {% if grains.kernel|lower == 'linux' %} - onlyif: systemctl list-units |grep {{ servicename }} >/dev/null 2>&1 {%- endif %} {# linux #} - enable: False + {%- endif %} + - require_in: + - sls: {{ sls_config_clean }} file.absent: - names: - {{ d.dir.service }}/{{ servicename }}.service - /etc/logrotate.d/{{ formula }}_{{ servicename }} + {%- if 'systemLog' in config and 'destination' in config['systemLog'] %} + {%- if config['systemLog']['destination'] == 'file' %} + - {{ config['systemLog']['path'] }} + {%- else %} + - {{ '/var/log/mongodb/' ~ servicename ~ '.log' }} + {%- endif %} + {%- endif %} - require_in: - sls: {{ sls_config_clean }} {% if grains.kernel|lower == 'linux' %} @@ -43,18 +59,20 @@ include: file.absent: - names: - /tmp/MySiLydUmMyFiLE - {%- if 'processManagement' in config and config['processManagement']['pidFilePath'] %} + {%- if 'processManagement' in config and 'pidFilePath' in config['processManagement'] %} - {{ config['processManagement']['pidFilePath'] }} - {%- endif %} - {%- if 'storage' in config and 'dbPath' in config['storage'] %} + {%- else %} + - {{ '/var/run/{{ name }}.pid' }} + {%- endif %} + {%- if 'storage' in config and 'dbPath' in config['storage'] %} - {{ config['storage']['dbPath'] }} - {%- endif %} - {%- if 'schema' in config and 'path' in config['schema'] %} + {%- endif %} + {%- if 'schema' in config and 'path' in config['schema'] %} - {{ config['schema']['path'] }} - {%- endif %} - {%- if 'systemLog' in config and 'path' in config['systemLog'] %} + {%- endif %} + {%- if 'systemLog' in config and 'path' in config['systemLog'] %} - {{ config['systemLog']['path'] }} - {%- endif %} + {%- endif %} - require_in: - sls: {{ sls_config_clean }} diff --git a/mongodb/service/running.sls b/mongodb/service/running.sls index 499fca4d..100778b2 100644 --- a/mongodb/service/running.sls +++ b/mongodb/service/running.sls @@ -11,23 +11,24 @@ include: - {{ sls_config_users }} - {{ sls_software_install }} + {%- if grains.kernel|lower == 'linux' %} {{ formula }}-service-running-prerequisites: file.managed: - name: /etc/init.d/disable-transparent-hugepages - source: salt://{{ formula }}/files/disable-transparent-hugepages.init - unless: test -f /etc/init.d/disable-transparent-hugepages 2>/dev/null - - onlyif: {{ grains.kernel|lower == 'linux' and d.wanted.disable_transparent_hugepages }} + - onlyif: {{ d.wanted.disable_transparent_hugepages }} - mode: '0755' - makedirs: True - require: - sls: {{ sls_software_install }} + - sls: {{ sls_config_users }} cmd.run: - name: echo never >/sys/kernel/mm/transparent_hugepage/enabled - - unless: test -f /etc/init.d/disable-transparent-hugepages 2>/dev/null - - onlyif: {{ grains.kernel|lower == 'linux' and d.wanted.disable_transparent_hugepages }} + - onlyif: {{ d.wanted.disable_transparent_hugepages }} - require: - file: {{ formula }}-service-running-prerequisites - {%- if d.wanted.firewall and grains.kernel|lower == 'linux' %} + {%- if d.wanted.firewall %} pkg.installed: - name: firewalld - reload_modules: true @@ -36,6 +37,7 @@ include: - onlyif: systemctl list-units | grep firewalld >/dev/null 2>&1 - enable: True {%- endif %} + {%- endif %} {%- for comp in d.components %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} @@ -49,7 +51,7 @@ include: {%- set config = software['config'] %} {%- set service_files = [] %} - {%- if 'processManagement' in config and config['processManagement']['pidFilePath'] %} + {%- if 'processManagement' in config and 'pidFilePath' in config['processManagement'] %} {%- do service_files.append(config['processManagement']['pidFilePath']) %} {{ formula }}-service-running-{{ comp }}-{{ servicename }}-install-pidpath: @@ -91,13 +93,14 @@ include: - group - require: - sls: {{ sls_config_users }} + - unless: test -d {{ config['storage']['dbPath'] }} - require_in: - service: {{ formula }}-service-running-{{ comp }}-{{ servicename }} {%- if 'selinux' in d.wanted and d.wanted.selinux %} selinux.fcontext_policy_present: - name: '{{ config['storage']['dbPath'] }}(/.*)?' - sel_type: {{ name }}_var_lib_t - - require: + - onchanges: - file: {{ formula }}-service-running-{{ comp }}-{{ servicename }}-install-datapath - require_in: - selinux: {{ formula }}-service-running-{{ comp }}-{{ servicename }}-selinux-applied @@ -132,13 +135,19 @@ include: {%- endif %} {%- endif %} - {%- if 'systemLog' in config and 'path' in config['systemLog'] %} - {%- do service_files.append(config['systemLog']['path']) %} - {%- do service_files.append('/etc/logrotate.d/{{ formula }}_' ~ name ) %} + {%- set path = '/var/log/mongodb/' ~ servicename ~ '.log' %} + {%- if 'systemLog' in config and 'destination' in config['systemLog'] %} + {%- if config['systemLog']['destination'] == 'file' %} + {%- if 'path' in config['systemLog'] %} + {%- set path = config['systemLog']['path'] %} + {%- endif %} + {%- endif %} + {%- endif %} + {%- do service_files.append(path) %} {{ formula }}-service-running-{{ comp }}-{{ servicename }}-install-syslogpath: file.directory: - - name: {{ config['systemLog']['path'] }} + - name: {{ salt['cmd.run']( 'dirname ' ~ path ) }} - user: {{ d.default.user if 'user' not in software else software['user'] }} - group: {{ d.default.group if 'group' not in software else software['group'] }} - dir_mode: '0775' @@ -148,15 +157,26 @@ include: - recurse: - user - group + +{{ formula }}-service-running-{{ comp }}-{{ servicename }}-install-syslogfile: + file.managed: + - name: {{ path }} + - user: {{ d.default.user if 'user' not in software else software['user'] }} + - group: {{ d.default.group if 'group' not in software else software['group'] }} + - mode: '0775' + - create: true + - replace: false + - require: + - file: {{ formula }}-service-running-{{ comp }}-{{ servicename }}-install-syslogpath - require_in: - service: {{ formula }}-service-running-{{ comp }}-{{ servicename }} - {%- if 'selinux' in d.wanted and d.wanted.selinux %} + {%- if 'selinux' in d.wanted and d.wanted.selinux %} selinux.fcontext_policy_present: - - name: '{{ logpath }}(/.*)?' + - name: {{ salt['cmd.run']( 'dirname ' ~ path ) }}'(/.*)?' - sel_type: {{ name }}_var_log_t - require_in: - selinux: {{ formula }}-service-running-{{ comp }}-{{ servicename }}-selinux-applied - {%- endif %} + {%- endif %} {{ formula }}-service-running-{{ comp }}-{{ servicename }}-install-logrotate: file.managed: @@ -169,19 +189,22 @@ include: - source: salt://{{ formula }}/files/default/logrotate.jinja - context: svc: {{ name }} - pattern: {{ config['systemLog']['path'] }} + pattern: {{ salt['cmd.run']( 'dirname ' ~ path ) }} + {%- if 'processManagement' in config and 'pidFilePath' in config['processManagement'] %} pidpath: {{ config['processManagement']['pidFilePath'] }} + {%- else %} + pidpath: {{ '/var/run/{{ name }}.pid' }} + {%- endif %} days: 7 - require_in: - service: {{ formula }}-service-running-{{ comp }}-{{ servicename }} - {%- if 'selinux' in d.wanted and d.wanted.selinux %} + {%- if 'selinux' in d.wanted and d.wanted.selinux %} selinux.fcontext_policy_present: - name: '/etc/logrotate.d/{{ formula }}_{{ svc }}(/.*)?' - sel_type: etc_t - require_in: - selinux: {{ formula }}-service-running-{{ comp }}-{{ servicename }}-selinux-applied - recursive: True - {%- endif %} {%- endif %} {%- if 'selinux' in d.wanted and d.wanted.selinux %} @@ -199,9 +222,11 @@ include: firewalld.present: - name: public - ports: {{ software['firewall']['ports']|json }} + {%- if grains.kernel|lower == 'linux' %} - require: - pkg: {{ formula }}-service-running-prerequisites - service: {{ formula }}-service-running-prerequisites + {%- endif %} - require_in: - service: {{ formula }}-service-running-{{ comp }}-{{ servicename }} {%- endif %} {# firewall #} @@ -219,14 +244,20 @@ include: - service: {{ formula }}-service-running-{{ comp }}-{{ servicename }} {{ formula }}-service-running-{{ comp }}-{{ servicename }}: + {%- if grains.kernel|lower == 'darwin' %} {# service.running is buggy #} + cmd.run: + - names: + - launchctl load /Library/LaunchAgents/{{ servicename }}.plist || true + - launchctl start {{ servicename }} + {%- else %} service.running: - name: {{ servicename }} - enable: True + - onlyif: systemctl list-units | grep {{ servicename }} >/dev/null 2>&1 + {%- endif %} - require: - sls: {{ sls_software_install }} - {%- if grains.kernel|lower == 'linux' %} - - onlyif: systemctl list-units | grep {{ servicename }} >/dev/null 2>&1 - {%- endif %} {# linux #} + - sls: {{ sls_config_users }} {%- if 'config' in software and software['config'] is mapping %} - watch: - file: {{ formula }}-config-file-{{ servicename }}-file-managed From 4888c2b114a04863df5bd1c1fe3d35638aa9a022 Mon Sep 17 00:00:00 2001 From: N Date: Wed, 22 Jul 2020 23:35:13 +0100 Subject: [PATCH 6/7] chore(limits): increase default limits on macos --- mongodb/config/clean.sls | 4 ++-- mongodb/config/file.sls | 4 ++-- mongodb/config/users.sls | 9 ++++----- mongodb/defaults.yaml | 6 +++--- mongodb/files/default/limit.maxfiles.plist | 21 --------------------- mongodb/files/default/macos.plist.jinja | 10 ++++++++++ mongodb/install.sls | 13 +++++++------ mongodb/service/running.sls | 20 ++++++++++---------- 8 files changed, 38 insertions(+), 49 deletions(-) delete mode 100644 mongodb/files/default/limit.maxfiles.plist diff --git a/mongodb/config/clean.sls b/mongodb/config/clean.sls index 5ba0a731..599a6d08 100644 --- a/mongodb/config/clean.sls +++ b/mongodb/config/clean.sls @@ -20,7 +20,7 @@ include: {{ formula }}-config-clean-{{ name }}-usergroup: user.absent: - - name: {{ d.default.user if 'user' not in software else software['user'] }} + - name: {{ software['user'] }} {%- if grains.os_family == 'MacOS' %} - onlyif: /usr/bin/dscl . list /Users | grep {{ name }} >/dev/null 2>&1 {%- endif %} @@ -30,7 +30,7 @@ include: - sls: {{ sls_service_clean }} - sls: {{ sls_alternatives_clean }} group.absent: - - name: {{ d.default.group if 'group' not in software else software['group'] }} + - name: {{ software['group'] }} - require: - user: {{ formula }}-config-clean-{{ name }}-usergroup {%- endif %} {# users #} diff --git a/mongodb/config/file.sls b/mongodb/config/file.sls index bdfd7cc5..8a887ded 100644 --- a/mongodb/config/file.sls +++ b/mongodb/config/file.sls @@ -40,8 +40,8 @@ include: ) }} - mode: 644 - - user: {{ d.default.user if 'user' not in software else software['user'] }} - - group: {{ d.default.group if 'group' not in software else software['group'] }} + - user: {{ software['user'] }} + - group: {{ software['group'] }} - makedirs: True - template: jinja - context: diff --git a/mongodb/config/users.sls b/mongodb/config/users.sls index f0f01776..1bc31107 100644 --- a/mongodb/config/users.sls +++ b/mongodb/config/users.sls @@ -16,23 +16,22 @@ include: {%- set software = d.pkg[comp][name] %} {%- if 'user' in software and 'service' in software and software['service'] is mapping %} {%- set servicename = name if 'service' not in software else software.service.name %} - {%- set user = d.default.user if 'user' not in software else software['user'] %} {{ formula }}-config-usergroup-{{ servicename }}-install-usergroup-present: group.present: - - name: {{ d.default.group if 'group' not in software else software['group'] }} + - name: {{ software['group'] }} - require_in: - user: {{ formula }}-config-usergroup-{{ servicename }}-install-usergroup-present - require_in: - sls: {{ sls_software_install }} user.present: - - name: {{ user }} + - name: {{ software['user'] }} - shell: /bin/false - createhome: false - groups: - - {{ d.default.group if 'group' not in software else software['group'] }} + - {{ software['group'] }} {%- if grains.os_family == 'MacOS' %} - - unless: /usr/bin/dscl . list /Users | grep {{ user }} >/dev/null 2>&1 + - unless: /usr/bin/dscl . list /Users | grep {{ software['user'] }} >/dev/null 2>&1 {%- endif %} {# darwin #} {%- endif %} {# service-users #} diff --git a/mongodb/defaults.yaml b/mongodb/defaults.yaml index 0d98c295..3559a600 100644 --- a/mongodb/defaults.yaml +++ b/mongodb/defaults.yaml @@ -12,9 +12,6 @@ mongodb: firewall: false selinux: false disable_transparent_hugepages: true - default: - user: mongodb - group: mongodb pkg: deps: - python-pip @@ -189,6 +186,9 @@ mongodb: splay: 10 linux: altpriority: 0 + limits: + soft: 2048 + hard: 4096 dir: archive: /usr/local/mongodb diff --git a/mongodb/files/default/limit.maxfiles.plist b/mongodb/files/default/limit.maxfiles.plist deleted file mode 100644 index 1b16b1b8..00000000 --- a/mongodb/files/default/limit.maxfiles.plist +++ /dev/null @@ -1,21 +0,0 @@ - - - - - Label - limit.maxfiles - ProgramArguments - - /bin/launchctl - limit - maxfiles - {{ soft_limit }} - {{ hard_limit }} - - RunAtLoad - - ServiceIPC - - - diff --git a/mongodb/files/default/macos.plist.jinja b/mongodb/files/default/macos.plist.jinja index 3cc752f5..743e1a70 100644 --- a/mongodb/files/default/macos.plist.jinja +++ b/mongodb/files/default/macos.plist.jinja @@ -12,6 +12,16 @@ RunAtLoad + SoftResourceLimits + + NumberOfFiles + {{ limits.soft }} + + HardResourceLimits + + NumberOfFiles + {{ limits.hard }} + StandardErrorPath /var/log/mongodb/{{ svc }}.log StandardOutPath diff --git a/mongodb/install.sls b/mongodb/install.sls index 4cd48a1e..67605975 100644 --- a/mongodb/install.sls +++ b/mongodb/install.sls @@ -214,8 +214,8 @@ include: {{ formula }}-{{ comp }}-{{ service.name }}-install-service-directory: file.directory: - name: {{ d.dir.var }}/{{ name }} - - user: {{ d.default.user if 'user' not in software else software['user'] }} - - group: {{ d.default.group if 'group' not in software else software['group'] }} + - user: {{ software['user'] }} + - group: {{ software['group'] }} - mode: '0755' - makedirs: True - require: @@ -241,8 +241,8 @@ include: desc: {{ formula }} {{ name }} service name: {{ name }} workdir: {{ d.dir.var }}/{{ name }} - user: {{ d.default.user if 'user' not in software else software['user'] }} - group: {{ d.default.group if 'group' not in software else software['group'] }} + user: {{ software['user'] }} + group: {{ software['group'] }} stop: '' start: {{ software['path'] }}/bin/{{ name }} - watch_in: @@ -252,7 +252,7 @@ include: {%- elif grains.kernel == 'Darwin' %} {%- set servicename = name if 'name' not in service else service.name %} - + - require_in: - file: {{ formula }}-{{ comp }}-{{ servicename }}-install-service-launched {{ formula }}-{{ comp }}-{{ servicename }}-install-service-launched: @@ -268,7 +268,8 @@ include: svc: {{ servicename|replace('org.mongo.mongodb.', '') }} config: {{ software['config_file'] }} binpath: {{ software['path'] }} - user: {{ d.default.user if 'user' not in software else software['user'] }} + user: {{ software['user'] }} + limits: {{ d.limits }} {%- endif %} {# linux/darwin #} {%- endif %} {# service #} diff --git a/mongodb/service/running.sls b/mongodb/service/running.sls index 100778b2..a511b0f6 100644 --- a/mongodb/service/running.sls +++ b/mongodb/service/running.sls @@ -57,8 +57,8 @@ include: {{ formula }}-service-running-{{ comp }}-{{ servicename }}-install-pidpath: file.directory: - name: {{ config['processManagement']['pidFilePath'] }} - - user: {{ d.default.user if 'user' not in software else software['user'] }} - - group: {{ d.default.group if 'group' not in software else software['group'] }} + - user: {{ software['user'] }} + - group: {{ software['group'] }} - dir_mode: '0775' - makedirs: True - require: @@ -84,8 +84,8 @@ include: {{ formula }}-service-running-{{ comp }}-{{ servicename }}-install-datapath: file.directory: - name: {{ config['storage']['dbPath'] }} - - user: {{ d.default.user if 'user' not in software else software['user'] }} - - group: {{ d.default.group if 'group' not in software else software['group'] }} + - user: {{ software['user'] }} + - group: {{ software['group'] }} - dir_mode: '0775' - makedirs: True - recurse: @@ -113,8 +113,8 @@ include: {{ formula }}-service-running-{{ comp }}-{{ servicename }}-install-schemapath: file.directory: - name: {{ config['schema']['path'] }} - - user: {{ d.default.user if 'user' not in software else software['user'] }} - - group: {{ d.default.group if 'group' not in software else software['group'] }} + - user: {{ software['user'] }} + - group: {{ software['group'] }} - dir_mode: '0775' - makedirs: True - recurse: @@ -148,8 +148,8 @@ include: {{ formula }}-service-running-{{ comp }}-{{ servicename }}-install-syslogpath: file.directory: - name: {{ salt['cmd.run']( 'dirname ' ~ path ) }} - - user: {{ d.default.user if 'user' not in software else software['user'] }} - - group: {{ d.default.group if 'group' not in software else software['group'] }} + - user: {{ software['user'] }} + - group: {{ software['group'] }} - dir_mode: '0775' - makedirs: True - require: @@ -161,8 +161,8 @@ include: {{ formula }}-service-running-{{ comp }}-{{ servicename }}-install-syslogfile: file.managed: - name: {{ path }} - - user: {{ d.default.user if 'user' not in software else software['user'] }} - - group: {{ d.default.group if 'group' not in software else software['group'] }} + - user: {{ software['user'] }} + - group: {{ software['group'] }} - mode: '0775' - create: true - replace: false From b00296553f36fb02ad6fae3961f1c9bad1fc415e Mon Sep 17 00:00:00 2001 From: N Date: Thu, 23 Jul 2020 00:31:12 +0100 Subject: [PATCH 7/7] fix(linux): fixup linux ci/cd --- mongodb/clean.sls | 8 +++---- mongodb/config/alternatives/clean.sls | 4 ++-- mongodb/config/alternatives/install.sls | 4 ++-- mongodb/config/clean.sls | 2 +- mongodb/config/environ.sls | 2 +- mongodb/config/file.sls | 2 +- mongodb/config/users.sls | 2 +- mongodb/defaults.yaml | 22 +++++++++---------- mongodb/files/default/macos.plist.jinja | 4 ++-- mongodb/install.sls | 16 +++++++------- mongodb/map.jinja | 6 ++--- mongodb/osfamilymap.yaml | 20 ++++++++++------- mongodb/osfingermap.yaml | 8 +++---- mongodb/service/clean.sls | 6 ++--- mongodb/service/running.sls | 4 ++-- pillar.example | 1 - .../default/controls/archive_spec.rb | 4 ++-- 17 files changed, 59 insertions(+), 56 deletions(-) diff --git a/mongodb/clean.sls b/mongodb/clean.sls index 0fc4e137..85982f5d 100644 --- a/mongodb/clean.sls +++ b/mongodb/clean.sls @@ -26,13 +26,13 @@ include: - {{ d.dir.var }} - /tmp/mac_shortcut.sh - {%- for comp in d.components %} + {%- for comp in d.componentypes %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} {%- set software = d.pkg[comp][name] %} - {%- set package = software.package_format %} - {%- if package in d.use_upstream %} + {%- set package = software['use_upstream'] %} + {%- if package in d.packagetypes %} {#- PACKAGE CLEAN #} {%- if package in software and software[package] is mapping %} @@ -46,7 +46,7 @@ include: - name: {{ software['path'] }} - require: - file: {{ formula }}-clean-prerequisites - {%- if d.use_upstream == 'repo' %} + {%- if package == 'repo' %} pkgrepo.absent: - name: {{ d.pkg['repo']['name'] }} {%- endif %} diff --git a/mongodb/config/alternatives/clean.sls b/mongodb/config/alternatives/clean.sls index 38e21ed3..1755b54d 100644 --- a/mongodb/config/alternatives/clean.sls +++ b/mongodb/config/alternatives/clean.sls @@ -6,12 +6,12 @@ {%- set formula = d.formula %} {%- if grains.kernel|lower == 'linux' and d.linux.altpriority|int > 0 and grains.os_family != 'Arch' %} - {%- for comp in d.components %} + {%- for comp in d.componentypes %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} {%- set software = d.pkg[comp][name] %} - {%- set package = software.package_format %} + {%- set package = software['use_upstream'] %} {%- if package == 'archive' and package in software and software[package] is mapping %} {# LINUX ALTERNATIVES #} diff --git a/mongodb/config/alternatives/install.sls b/mongodb/config/alternatives/install.sls index 6eb87505..d6a949a5 100644 --- a/mongodb/config/alternatives/install.sls +++ b/mongodb/config/alternatives/install.sls @@ -10,13 +10,13 @@ include: - {{ sls_software_install }} {%- if grains.kernel|lower == 'linux' and d.linux.altpriority|int > 0 and grains.os_family != 'Arch' %} - {%- for comp in d.components %} + {%- for comp in d.componentypes %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} {%- set software = d.pkg[comp][name] %} {%- set path = software['path'] %} - {%- set package = software.package_format %} + {%- set package = software['use_upstream'] %} {%- if package == 'archive' and package in software and software[package] is mapping %} {# LINUX ALTERNATIVES #} diff --git a/mongodb/config/clean.sls b/mongodb/config/clean.sls index 599a6d08..9e0c22b3 100644 --- a/mongodb/config/clean.sls +++ b/mongodb/config/clean.sls @@ -11,7 +11,7 @@ include: - {{ sls_service_clean }} - {{ sls_alternatives_clean }} - {%- for comp in d.components %} + {%- for comp in d.componentypes %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} diff --git a/mongodb/config/environ.sls b/mongodb/config/environ.sls index c5504036..06d3490a 100644 --- a/mongodb/config/environ.sls +++ b/mongodb/config/environ.sls @@ -10,7 +10,7 @@ include: - {{ sls_software_install }} - {%- for comp in d.components %} + {%- for comp in d.componentypes %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} diff --git a/mongodb/config/file.sls b/mongodb/config/file.sls index 8a887ded..56be5666 100644 --- a/mongodb/config/file.sls +++ b/mongodb/config/file.sls @@ -23,7 +23,7 @@ include: - sls: {{ sls_software_install }} - sls: {{ sls_config_users }} - {%- for comp in d.components %} + {%- for comp in d.componentypes %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} diff --git a/mongodb/config/users.sls b/mongodb/config/users.sls index 1bc31107..26b242fa 100644 --- a/mongodb/config/users.sls +++ b/mongodb/config/users.sls @@ -9,7 +9,7 @@ include: - {{ sls_software_install }} - {%- for comp in d.components %} + {%- for comp in d.componentypes %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} diff --git a/mongodb/defaults.yaml b/mongodb/defaults.yaml index 3559a600..e1db8a76 100644 --- a/mongodb/defaults.yaml +++ b/mongodb/defaults.yaml @@ -2,8 +2,8 @@ # vim: ft=yaml --- mongodb: - components: ['database', 'gui', 'connectors'] # depreciate software_component_matrix - use_upstream: ['archive', 'macapp', 'repo'] # depreciate software_package_matrix + componentypes: ['database', 'gui', 'connectors'] + packagetypes: ['archive', 'package', 'repo', 'native'] wanted: database: - mongod @@ -32,7 +32,7 @@ mongodb: dbtools: version: 100.0.1 name: mongodb-database-tools - package_format: archive + use_upstream: 'archive' archive: skip_verify: true commands: @@ -47,14 +47,14 @@ mongodb: shell: version: 4.2.6 name: mongodb-org-shell - package_format: archive + use_upstream: 'archive' config_file: /etc/mongodb/mongorc.js commands: - mongo mongod: version: 4.2.6 name: mongodb-org-server - package_format: archive + use_upstream: 'archive' user: mongodb group: mongodb config_file: /etc/mongodb/mongod.conf @@ -105,7 +105,7 @@ mongodb: mongos: version: 4.2.6 name: mongodb-org-mongos - package_format: null # installed with mongod + use_upstream: null # installed with mongod user: mongos group: mongos config_file: /etc/mongodb/mongos.conf @@ -126,10 +126,10 @@ mongodb: compass: version: 1.21.2 name: mongo-compass - package_format: native + use_upstream: native robo3t: version: 1.3.1 - package_format: archive + use_upstream: archive archive: # yamllint disable-line rule:line-length source: https://download-test.robomongo.org/linux/robo3t-VER-linux-ARCH-7419c406.tar.gz @@ -141,7 +141,7 @@ mongodb: bi: name: mongodb-bi version: 2.13.4 - package_format: archive + use_upstream: archive archive: # for linux, see osfingermap; bi is unavailable for macos skip_verify: true @@ -156,7 +156,7 @@ mongodb: kafka: version: 1.1.0 name: mongo-kafka - package_format: archive + use_upstream: archive archive: # yamllint disable-line rule:line-length source: https://github.com/mongodb/mongo-kafka/releases/download/rVER/mongodb-kafka-connect-mongodb-VER.zip @@ -164,7 +164,7 @@ mongodb: spark: version: 2.4.1 name: mongo-spark - package_format: archive + use_upstream: archive archive: source: https://github.com/mongodb/mongo-spark/archive/rVER.tar.gz skip_verify: true diff --git a/mongodb/files/default/macos.plist.jinja b/mongodb/files/default/macos.plist.jinja index 743e1a70..5e940b38 100644 --- a/mongodb/files/default/macos.plist.jinja +++ b/mongodb/files/default/macos.plist.jinja @@ -15,12 +15,12 @@ SoftResourceLimits NumberOfFiles - {{ limits.soft }} + {{ limits.soft }} HardResourceLimits NumberOfFiles - {{ limits.hard }} + {{ limits.hard }} StandardErrorPath /var/log/mongodb/{{ svc }}.log diff --git a/mongodb/install.sls b/mongodb/install.sls index 67605975..cbed47b1 100644 --- a/mongodb/install.sls +++ b/mongodb/install.sls @@ -31,13 +31,13 @@ include: - pkg: {{ formula }}-install-prerequisites - pip: {{ formula }}-install-prerequisites - {%- for comp in d.components %} + {%- for comp in d.componentypes %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} {%- set software = d.pkg[comp][name] %} - {%- set package = software.package_format %} - {%- if package in d.use_upstream %} + {%- set package = software['use_upstream'] %} + {%- if package in d.packagetypes %} {# DOWNLOAD NATIVE PACKAGE #} @@ -73,10 +73,10 @@ include: {{ formula }}-{{ comp }}-{{ name }}-{{ package }}-install: - {#- NATIVE PACKAGE INSTALL #} + {#- NATIVE PACKAGE INSTALL #} - {%- if package == 'native' %} - {%- if d.use_upstream == 'repo' and 'repo' in d.pkg and d.pkg.repo %} + {%- if package in ('native', 'repo') %} + {%- if package == 'repo' and 'repo' in d.pkg and d.pkg.repo %} pkgrepo.managed: {{- format_kwargs(d.pkg['repo']) }} {%- endif %} @@ -89,7 +89,7 @@ include: - require: - module: {{ formula }}-{{ comp }}-{{ name }}-{{ package }}-download {%- endif %} - {%- else %} + {%- else %} {# package #} - name: {{ software.get('name', name) }} {%- endif %} - reload_modules: true @@ -187,7 +187,7 @@ include: {#- SYMLINK INSTALL #} {%- if grains.kernel|lower in ('linux', 'darwin') %} - {%- if package in ('archve', 'macapp') %} + {%- if package in ('archive', 'macapp') %} {%- if d.linux.altpriority|int <= 0 or grains.os_family in ('MacOS', 'Arch') %} {%- if 'commands' in software and software['commands'] is iterable %} {%- for cmd in software['commands'] %} diff --git a/mongodb/map.jinja b/mongodb/map.jinja index 08bbb507..950083c8 100644 --- a/mongodb/map.jinja +++ b/mongodb/map.jinja @@ -28,11 +28,11 @@ {%- do d.update({ 'components': d.software_component_matrix }) %} {%- endif %} {%- if 'software_package_matrix' in d %} - {%- do d.update({ 'use_upstream': d.software_package_matrix }) %} + {%- do d.update({ 'packagetypes': d.software_package_matrix }) %} {%- endif %} # build dict -{%- for comp in d.components %} +{%- for comp in d.componentypes %} {%- if comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- set software = d.pkg[comp][name] %} @@ -42,7 +42,7 @@ {%- set release = v.version.split('.')[0] ~ '.' ~ v.version.split('.')[1] %} {%- set dir = '%s-%s'|format(name, v.version) %} {%- set path = d.dir.archive ~ '/' ~ dir %} - {%- for package in d.use_upstream %} + {%- for package in d.packagetypes %} {%- if package in v and v[package] %} {%- set path = d.dir[package] if package == 'macapp' else path %} {%- do software[package].update({'name': path}) %} diff --git a/mongodb/osfamilymap.yaml b/mongodb/osfamilymap.yaml index 7037ea27..23b18b81 100644 --- a/mongodb/osfamilymap.yaml +++ b/mongodb/osfamilymap.yaml @@ -28,7 +28,6 @@ Arch: Alpine: {} Debian: - use_upstream: 'archive' # using 'repo' caused a conflict wanted: firewall: false pkg: @@ -51,16 +50,16 @@ Debian: database: mongod: name: mongodb-org + use_upstream: 'archive' # using 'repo' caused a conflict gui: compass: - package_format: native + use_upstream: native native: source: https://downloads.mongodb.com/compass/mongodb-compass-community_VER_amd64.deb source_hash: 8101ae6c2294072090751c7226dd0ee0467f65217bf68886a9b8b6b1f3441bc8 skip_verify: false RedHat: - use_upstream: 'repo' wanted: firewall: false # turned off for travis ci selinux: false # turrned off for travs citrue @@ -86,11 +85,16 @@ RedHat: from_repo_value: '' database: mongod: + {%- if 'osfinger' in grains and 'amazon' in grains.osfinger|lower %} + use_upstream: 'archive' + {%- else %} + use_upstream: 'repo' + {%- endif %} user: mongod group: mongod gui: compass: - package_format: native + use_upstream: native native: source: https://downloads.mongodb.com/compass/mongodb-compass-community-VER.ARCH.rpm source_hash: ee4ab84302710686e8bec0309c68de5ab49d85a77b60e244a63be3e0e93562ca @@ -151,25 +155,25 @@ MacOS: service: name: org.mongo.mongodb.mongos dbtools: - package_format: archive + use_upstream: archive archive: source: https://fastdl.mongodb.org/tools/db/mongodb-database-tools-macos-ARCH-VER.tgz shell: - package_format: archive + use_upstream: archive archive: source: https://fastdl.mongodb.org/osx/mongodb-macos-ARCH-VER.tgz skip_verify: true gui: compass: name: MongoDB Compass Community - package_format: macapp + use_upstream: macapp macapp: source: https://downloads.mongodb.com/compass/mongodb-compass-community-VER-darwin-x64.dmg source_hash: af2840d0a71a15d01160b547766cd291acc2f15955f1dee1ac79cc9db60153ba skip_verify: true robo3t: name: Robo 3T - package_format: macapp + use_upstream: macapp macapp: source: https://download-test.robomongo.org/mac/robo3t-VER-darwin-ARCH-7419c40.dmg skip_verify: true diff --git a/mongodb/osfingermap.yaml b/mongodb/osfingermap.yaml index 4c0941e1..96019969 100644 --- a/mongodb/osfingermap.yaml +++ b/mongodb/osfingermap.yaml @@ -6,7 +6,7 @@ pkg: database: mongod: - package_format: archive + use_upstream: archive archive: source: https://fastdl.mongodb.org/linux/mongodb-linux-ARCH-{{ oscode }}-VER.tgz source_hash: https://fastdl.mongodb.org/linux/mongodb-linux-ARCH-{{ oscode }}-VER.tgz.sha256 @@ -14,18 +14,18 @@ source: https://repo.mongodb.org/{{ uri|replace('COMP', 'mongodb-org-server') }} skip_verify: true dbtools: - package_format: archive + use_upstream: archive archive: source: https://fastdl.mongodb.org/tools/db/mongodb-database-tools-{{ oscode }}-ARCH-VER.tgz # noqa 204 skip_verify: true shell: - # package_format: native # Debian 10 error: 'LookupError There is no member named control' + # use_upstream: native # Debian 10 error: 'LookupError There is no member named control' native: source: https://repo.mongodb.org/{{ uri|replace('COMP', 'mongodb-org-shell') }} skip_verify: true connectors: bi: - package_format: archive + use_upstream: archive archive: source: https://info-mongodb-com.s3.amazonaws.com/mongodb-bi/v2/mongodb-bi-linux-ARCH-{{ oscode }}-vVER.tgz # noqa 204 source_hash: https://info-mongodb-com.s3.amazonaws.com/mongodb-bi/v2/mongodb-bi-linux-ARCH-{{ oscode }}-vVER.tgz.sha256 # noqa 204 diff --git a/mongodb/service/clean.sls b/mongodb/service/clean.sls index 6746b5f9..9c7ea478 100644 --- a/mongodb/service/clean.sls +++ b/mongodb/service/clean.sls @@ -9,7 +9,7 @@ include: - {{ sls_config_clean }} - {%- for comp in d.components %} + {%- for comp in d.componentypes %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} @@ -44,8 +44,8 @@ include: - {{ config['systemLog']['path'] }} {%- else %} - {{ '/var/log/mongodb/' ~ servicename ~ '.log' }} - {%- endif %} - {%- endif %} + {%- endif %} + {%- endif %} - require_in: - sls: {{ sls_config_clean }} {% if grains.kernel|lower == 'linux' %} diff --git a/mongodb/service/running.sls b/mongodb/service/running.sls index a511b0f6..9898e0c5 100644 --- a/mongodb/service/running.sls +++ b/mongodb/service/running.sls @@ -39,7 +39,7 @@ include: {%- endif %} {%- endif %} - {%- for comp in d.components %} + {%- for comp in d.componentypes %} {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} {%- for name,v in d.pkg[comp].items() %} {%- if name in d.wanted[comp] %} @@ -135,7 +135,7 @@ include: {%- endif %} {%- endif %} - {%- set path = '/var/log/mongodb/' ~ servicename ~ '.log' %} + {%- set path = '/var/log/mongodb/' ~ servicename ~ '.log' %} {%- if 'systemLog' in config and 'destination' in config['systemLog'] %} {%- if config['systemLog']['destination'] == 'file' %} {%- if 'path' in config['systemLog'] %} diff --git a/pillar.example b/pillar.example index 9bd4a952..c810c93a 100644 --- a/pillar.example +++ b/pillar.example @@ -17,7 +17,6 @@ mongodb: connectors: # bi # enterprise subscription only - kafka - upstream_repo: false pkg: deps: diff --git a/test/integration/default/controls/archive_spec.rb b/test/integration/default/controls/archive_spec.rb index cb738bb8..432ad9a9 100644 --- a/test/integration/default/controls/archive_spec.rb +++ b/test/integration/default/controls/archive_spec.rb @@ -90,13 +90,13 @@ its('owner') { should eq 'root' } its('group') { should eq 'root' } end - describe file('/etc/mongodb/mongod.yml') do + describe file('/etc/mongodb/mongod.conf') do it { should exist } its('mode') { should cmp '0644' } # its('owner') { should eq 'mongodb' } # its('group') { should eq 'mongodb' } end - describe file('/etc/mongodb/mongos.yml') do + describe file('/etc/mongodb/mongos.conf') do it { should exist } its('mode') { should cmp '0644' } its('owner') { should eq 'mongos' }