diff --git a/mongodb/clean.sls b/mongodb/clean.sls
index cbde49e0..85982f5d 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,22 +15,24 @@ 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.software_component_matrix %}
+ {%- 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.software_package_matrix %}
+ {%- set package = software['use_upstream'] %}
+ {%- if package in d.packagetypes %}
{#- PACKAGE CLEAN #}
{%- if package in software and software[package] is mapping %}
@@ -42,7 +44,9 @@ include:
- file: {{ formula }}-clean-prerequisites
file.absent:
- name: {{ software['path'] }}
- {%- if d.wanted.upstream_repo %}
+ - require:
+ - file: {{ formula }}-clean-prerequisites
+ {%- if package == 'repo' %}
pkgrepo.absent:
- name: {{ d.pkg['repo']['name'] }}
{%- endif %}
@@ -85,6 +89,7 @@ include:
- 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/alternatives/clean.sls b/mongodb/config/alternatives/clean.sls
index 27f76085..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.software_component_matrix %}
+ {%- 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 #}
@@ -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 a7b97480..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.software_component_matrix %}
+ {%- 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 #}
@@ -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 a72b518d..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.software_component_matrix %}
+ {%- 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] %}
@@ -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 %}
@@ -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'] }}
+ - name: {{ software['group'] }}
+ - require:
+ - user: {{ formula }}-config-clean-{{ name }}-usergroup
{%- endif %} {# users #}
{{ formula }}-config-clean-{{ name }}-files:
@@ -37,7 +40,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'] }}
@@ -47,6 +50,7 @@ include:
{%- endif %}
- require:
- sls: {{ sls_service_clean }}
+ - sls: {{ sls_alternatives_clean }}
{%- endif %} {# wanted #}
{%- endfor %} {# component #}
diff --git a/mongodb/config/environ.sls b/mongodb/config/environ.sls
index d3d9f7f0..06d3490a 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.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 ce858b42..56be5666 100644
--- a/mongodb/config/file.sls
+++ b/mongodb/config/file.sls
@@ -21,8 +21,9 @@ include:
- makedirs: True
- require:
- sls: {{ sls_software_install }}
+ - sls: {{ sls_config_users }}
- {%- for comp in d.software_component_matrix %}
+ {%- 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] %}
@@ -33,14 +34,14 @@ 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'
)
}}
- 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 34a98417..26b242fa 100644
--- a/mongodb/config/users.sls
+++ b/mongodb/config/users.sls
@@ -4,29 +4,34 @@
{%- 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' %}
- {%- for comp in d.software_component_matrix %}
+include:
+ - {{ sls_software_install }}
+
+ {%- 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] %}
{%- 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 b2ecfd6b..e1db8a76 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']
+ componentypes: ['database', 'gui', 'connectors']
+ packagetypes: ['archive', 'package', 'repo', 'native']
wanted:
database:
- mongod
@@ -12,10 +12,6 @@ mongodb:
firewall: false
selinux: false
disable_transparent_hugepages: true
- upstream_repo: false
- default:
- user: mongodb
- group: mongodb
pkg:
deps:
- python-pip
@@ -36,7 +32,7 @@ mongodb:
dbtools:
version: 100.0.1
name: mongodb-database-tools
- package_format: archive
+ use_upstream: 'archive'
archive:
skip_verify: true
commands:
@@ -51,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
@@ -72,6 +68,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:
@@ -103,13 +105,17 @@ 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
config:
sharding:
configDB: 'rs1/127.0.0.1:27018'
+ systemLog:
+ quiet: true
+ traceAllExceptions: false
+ path: /var/log/mongodb/mongos.log
service:
name: mongos
firewall:
@@ -120,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
@@ -135,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
@@ -150,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
@@ -158,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
@@ -180,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 33985740..5e940b38 100644
--- a/mongodb/files/default/macos.plist.jinja
+++ b/mongodb/files/default/macos.plist.jinja
@@ -6,15 +6,25 @@
org.mongo.mongodb.{{ svc }}
ProgramArguments
- {{ binpath }}/bin/{{ svc }}
- --config
+ {{ binpath }}/bin/{{ svc }}
+ {{ '--config' }}
{{ config }}
RunAtLoad
+ SoftResourceLimits
+
+ NumberOfFiles
+ {{ limits.soft }}
+
+ HardResourceLimits
+
+ NumberOfFiles
+ {{ limits.hard }}
+
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 d8a750d6..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.software_component_matrix %}
+ {%- 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.software_package_matrix %}
+ {%- 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.wanted.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
@@ -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:
@@ -180,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'] %}
@@ -207,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:
@@ -234,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:
@@ -245,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:
@@ -261,6 +268,8 @@ include:
svc: {{ servicename|replace('org.mongo.mongodb.', '') }}
config: {{ software['config_file'] }}
binpath: {{ software['path'] }}
+ user: {{ software['user'] }}
+ limits: {{ d.limits }}
{%- endif %} {# linux/darwin #}
{%- endif %} {# service #}
diff --git a/mongodb/map.jinja b/mongodb/map.jinja
index efc334cf..950083c8 100644
--- a/mongodb/map.jinja
+++ b/mongodb/map.jinja
@@ -20,11 +20,19 @@
)
)
)
- %}
-
+%}
{%- set d = salt['grains.filter_by']( {'defaults': defaults}, default='defaults', merge=_config) %}
-{%- for comp in d.software_component_matrix %}
+# 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({ 'packagetypes': d.software_package_matrix }) %}
+{%- endif %}
+
+# build dict
+{%- 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] %}
@@ -34,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.software_package_matrix %}
+ {%- 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 e3cf540b..23b18b81 100644
--- a/mongodb/osfamilymap.yaml
+++ b/mongodb/osfamilymap.yaml
@@ -30,8 +30,6 @@ Alpine: {}
Debian:
wanted:
firewall: false
- # package conflict occured when true
- upstream_repo: false
pkg:
deps:
- curl
@@ -52,9 +50,10 @@ 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
@@ -64,7 +63,6 @@ RedHat:
wanted:
firewall: false # turned off for travis ci
selinux: false # turrned off for travs citrue
- upstream_repo: true
default:
user: mongod
group: mongod
@@ -87,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
@@ -152,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 7e29e968..9c7ea478 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.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] %}
@@ -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 5ad347c5..9898e0c5 100644
--- a/mongodb/service/running.sls
+++ b/mongodb/service/running.sls
@@ -11,16 +11,18 @@ 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
+ - unless: test -f /etc/init.d/disable-transparent-hugepages 2>/dev/null
- 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
- onlyif: {{ d.wanted.disable_transparent_hugepages }}
@@ -35,8 +37,9 @@ include:
- onlyif: systemctl list-units | grep firewalld >/dev/null 2>&1
- enable: True
{%- endif %}
+ {%- endif %}
- {%- for comp in d.software_component_matrix %}
+ {%- 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] %}
@@ -48,14 +51,14 @@ 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:
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:
@@ -81,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:
@@ -90,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
@@ -109,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:
@@ -131,15 +135,21 @@ 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'] }}
- - user: {{ d.default.user if 'user' not in software else software['user'] }}
- - group: {{ d.default.group if 'group' not in software else software['group'] }}
+ - name: {{ salt['cmd.run']( 'dirname ' ~ path ) }}
+ - user: {{ software['user'] }}
+ - group: {{ software['group'] }}
- dir_mode: '0775'
- makedirs: True
- require:
@@ -147,15 +157,26 @@ include:
- recurse:
- user
- group
+
+{{ formula }}-service-running-{{ comp }}-{{ servicename }}-install-syslogfile:
+ file.managed:
+ - name: {{ path }}
+ - user: {{ software['user'] }}
+ - group: {{ 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:
@@ -168,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 %}
@@ -198,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 #}
@@ -218,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
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' }