Skip to content

Commit

Permalink
Merge pull request #88 from noelmcloughlin/macos
Browse files Browse the repository at this point in the history
fix(formula): all fixes for linux and macos
  • Loading branch information
noelmcloughlin authored Aug 9, 2020
2 parents af35635 + b002965 commit 72fcbbd
Show file tree
Hide file tree
Showing 18 changed files with 232 additions and 134 deletions.
21 changes: 13 additions & 8 deletions mongodb/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand All @@ -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 %}
Expand All @@ -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 %}
Expand Down Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions mongodb/config/alternatives/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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 #}
Expand All @@ -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 #}
12 changes: 10 additions & 2 deletions mongodb/config/alternatives/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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 #}
Expand Down Expand Up @@ -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 #}
12 changes: 8 additions & 4 deletions mongodb/config/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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] %}
Expand All @@ -20,24 +20,27 @@ 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 %}
- require_in:
- 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:
file.absent:
- 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'] }}
Expand All @@ -47,6 +50,7 @@ include:
{%- endif %}
- require:
- sls: {{ sls_service_clean }}
- sls: {{ sls_alternatives_clean }}
{%- endif %} {# wanted #}
{%- endfor %} {# component #}
Expand Down
2 changes: 1 addition & 1 deletion mongodb/config/environ.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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] %}
Expand Down
9 changes: 5 additions & 4 deletions mongodb/config/file.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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] %}
Expand All @@ -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:
Expand Down
17 changes: 11 additions & 6 deletions mongodb/config/users.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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 #}
Expand Down
39 changes: 24 additions & 15 deletions mongodb/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -150,15 +156,15 @@ 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
skip_verify: true
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
Expand All @@ -180,6 +186,9 @@ mongodb:
splay: 10
linux:
altpriority: 0
limits:
soft: 2048
hard: 4096

dir:
archive: /usr/local/mongodb
Expand Down
21 changes: 0 additions & 21 deletions mongodb/files/default/limit.maxfiles.plist

This file was deleted.

Loading

0 comments on commit 72fcbbd

Please sign in to comment.