├── .github └── workflows │ └── commitlint.yml ├── .gitignore ├── .gitlab-ci.yml ├── .pre-commit-config.yaml ├── .rstcheck.cfg ├── .rubocop.yml ├── .salt-lint ├── .travis.yml ├── .yamllint ├── AUTHORS.md ├── CHANGELOG.md ├── CODEOWNERS ├── FORMULA ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── bin ├── install-hooks └── kitchen ├── commitlint.config.js ├── docs ├── AUTHORS.rst ├── CHANGELOG.rst ├── README.rst ├── TOFS_pattern.rst ├── _static │ └── css │ │ └── custom.css └── conf.py ├── kitchen.yml ├── mongodb ├── _mapdata │ ├── _mapdata.jinja │ └── init.sls ├── clean.sls ├── config │ ├── alternatives │ │ ├── clean.sls │ │ ├── init.sls │ │ └── install.sls │ ├── clean.sls │ ├── environ.sls │ ├── file.sls │ ├── init.sls │ └── users.sls ├── defaults.yaml ├── files │ ├── default │ │ ├── config.yml.jinja │ │ ├── environ.sh.jinja │ │ ├── logrotate.jinja │ │ ├── mac_shortcut.sh.jinja │ │ ├── macos.plist.jinja │ │ ├── mongorc.js.jinja │ │ └── systemd.ini.jinja │ ├── disable-transparent-hugepages.init │ └── macros.jinja ├── init.sls ├── install.sls ├── libtofs.jinja ├── map.jinja ├── osarchmap.yaml ├── osfamilymap.yaml ├── osfingermap.yaml └── service │ ├── clean.sls │ ├── init.sls │ └── running.sls ├── pillar.example ├── pre-commit_semantic-release.sh ├── release-rules.js ├── release.config.js └── test ├── integration ├── default │ ├── README.md │ ├── controls │ │ └── archive_spec.rb │ └── inspec.yml └── share │ ├── README.md │ ├── inspec.yml │ └── libraries │ └── system.rb └── salt └── pillar └── default.sls /.github/workflows/commitlint.yml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | name: Commitlint 5 | 'on': [pull_request] 6 | 7 | jobs: 8 | lint: 9 | runs-on: ubuntu-latest 10 | env: 11 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 12 | steps: 13 | - uses: actions/checkout@v2 14 | with: 15 | fetch-depth: 0 16 | - uses: wagoid/commitlint-github-action@v1 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a packager 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .kitchen 49 | .kitchen.local.yml 50 | kitchen.local.yml 51 | junit-*.xml 52 | 53 | # Translations 54 | *.mo 55 | *.pot 56 | 57 | # Django stuff: 58 | *.log 59 | local_settings.py 60 | 61 | # Flask stuff: 62 | instance/ 63 | .webassets-cache 64 | 65 | # Scrapy stuff: 66 | .scrapy 67 | 68 | # Sphinx documentation 69 | docs/_build/ 70 | 71 | # PyBuilder 72 | target/ 73 | 74 | # Jupyter Notebook 75 | .ipynb_checkpoints 76 | 77 | # pyenv 78 | .python-version 79 | 80 | # celery beat schedule file 81 | celerybeat-schedule 82 | 83 | # SageMath parsed files 84 | *.sage.py 85 | 86 | # dotenv 87 | .env 88 | 89 | # virtualenv 90 | .venv 91 | venv/ 92 | ENV/ 93 | 94 | # visual studio 95 | .vs/ 96 | 97 | # Spyder project settings 98 | .spyderproject 99 | .spyproject 100 | 101 | # Rope project settings 102 | .ropeproject 103 | 104 | # mkdocs documentation 105 | /site 106 | 107 | # mypy 108 | .mypy_cache/ 109 | 110 | # Bundler 111 | .bundle/ 112 | 113 | # copied `.md` files used for conversion to `.rst` using `m2r` 114 | docs/*.md 115 | 116 | # Vim 117 | *.sw? 118 | 119 | ## Collected when centralising formulas (check and sort) 120 | # `collectd-formula` 121 | .pytest_cache/ 122 | /.idea/ 123 | Dockerfile.*_* 124 | ignore/ 125 | tmp/ 126 | 127 | # `salt-formula` -- Vagrant Specific files 128 | .vagrant 129 | top.sls 130 | !test/salt/pillar/top.sls 131 | 132 | # `suricata-formula` -- Platform binaries 133 | *.rpm 134 | *.deb 135 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | ############################################################################### 5 | # Define all YAML node anchors 6 | ############################################################################### 7 | .node_anchors: 8 | # `only` (also used for `except` where applicable) 9 | only_branch_master_parent_repo: &only_branch_master_parent_repo 10 | - 'master@saltstack-formulas/mongodb-formula' 11 | # `stage` 12 | stage_lint: &stage_lint 'lint' 13 | stage_release: &stage_release 'release' 14 | stage_test: &stage_test 'test' 15 | # `image` 16 | image_commitlint: &image_commitlint 'myii/ssf-commitlint:11' 17 | image_dindruby: &image_dindruby 'myii/ssf-dind-ruby:2.7.1-r3' 18 | image_precommit: &image_precommit 19 | name: 'myii/ssf-pre-commit:2.9.2' 20 | entrypoint: ['/bin/bash', '-c'] 21 | image_rubocop: &image_rubocop 'pipelinecomponents/rubocop:latest' 22 | image_semantic-release: &image_semanticrelease 'myii/ssf-semantic-release:15.14' 23 | # `services` 24 | services_docker_dind: &services_docker_dind 25 | - 'docker:dind' 26 | # `variables` 27 | # https://forum.gitlab.com/t/gitlab-com-ci-caching-rubygems/5627/3 28 | # https://bundler.io/v1.16/bundle_config.html 29 | variables_bundler: &variables_bundler 30 | BUNDLE_CACHE_PATH: '${CI_PROJECT_DIR}/.cache/bundler' 31 | BUNDLE_WITHOUT: 'production' 32 | # `cache` 33 | cache_bundler: &cache_bundler 34 | key: '${CI_JOB_STAGE}' 35 | paths: 36 | - '${BUNDLE_CACHE_PATH}' 37 | 38 | ############################################################################### 39 | # Define stages and global variables 40 | ############################################################################### 41 | stages: 42 | - *stage_lint 43 | - *stage_test 44 | - *stage_release 45 | variables: 46 | DOCKER_DRIVER: 'overlay2' 47 | 48 | ############################################################################### 49 | # `lint` stage: `commitlint`, `pre-commit` & `rubocop` (latest, failure allowed) 50 | ############################################################################### 51 | commitlint: 52 | stage: *stage_lint 53 | image: *image_commitlint 54 | script: 55 | # Add `upstream` remote to get access to `upstream/master` 56 | - 'git remote add upstream 57 | https://gitlab.com/saltstack-formulas/mongodb-formula.git' 58 | - 'git fetch --all' 59 | # Set default commit hashes for `--from` and `--to` 60 | - 'export COMMITLINT_FROM="$(git merge-base upstream/master HEAD)"' 61 | - 'export COMMITLINT_TO="${CI_COMMIT_SHA}"' 62 | # `coqbot` adds a merge commit to test PRs on top of the latest commit in 63 | # the repo; amend this merge commit message to avoid failure 64 | - | 65 | if [ "${GITLAB_USER_LOGIN}" = "coqbot" ] \ 66 | && [ "${CI_COMMIT_BRANCH}" != "master" ]; then 67 | git commit --amend -m \ 68 | 'chore: reword coqbot merge commit message for commitlint' 69 | export COMMITLINT_TO=HEAD 70 | fi 71 | # Run `commitlint` 72 | - 'commitlint --from "${COMMITLINT_FROM}" 73 | --to "${COMMITLINT_TO}" 74 | --verbose' 75 | 76 | pre-commit: 77 | stage: *stage_lint 78 | image: *image_precommit 79 | # https://pre-commit.com/#gitlab-ci-example 80 | variables: 81 | PRE_COMMIT_HOME: '${CI_PROJECT_DIR}/.cache/pre-commit' 82 | cache: 83 | key: '${CI_JOB_NAME}' 84 | paths: 85 | - '${PRE_COMMIT_HOME}' 86 | script: 87 | - 'pre-commit run --all-files --color always --verbose' 88 | 89 | # Use a separate job for `rubocop` other than the one potentially run by `pre-commit` 90 | # - The `pre-commit` check will only be available for formulas that pass the default 91 | # `rubocop` check -- and must continue to do so 92 | # - This job is allowed to fail, so can be used for all formulas 93 | # - Furthermore, this job uses all of the latest `rubocop` features & cops, 94 | # which will help when upgrading the `rubocop` linter used in `pre-commit` 95 | rubocop: 96 | allow_failure: true 97 | stage: *stage_lint 98 | image: *image_rubocop 99 | script: 100 | - 'rubocop -d -P -S --enable-pending-cops' 101 | 102 | ############################################################################### 103 | # Define `test` template 104 | ############################################################################### 105 | .test_instance: &test_instance 106 | stage: *stage_test 107 | image: *image_dindruby 108 | services: *services_docker_dind 109 | variables: *variables_bundler 110 | cache: *cache_bundler 111 | before_script: 112 | # TODO: This should work from the env vars above automatically 113 | - 'bundle config set path "${BUNDLE_CACHE_PATH}"' 114 | - 'bundle config set without "${BUNDLE_WITHOUT}"' 115 | - 'bundle install' 116 | script: 117 | # Alternative value to consider: `${CI_JOB_NAME}` 118 | - 'bin/kitchen verify "${DOCKER_ENV_CI_JOB_NAME}"' 119 | 120 | ############################################################################### 121 | # Define `test` template (`allow_failure: true`) 122 | ############################################################################### 123 | .test_instance_failure_permitted: 124 | <<: *test_instance 125 | allow_failure: true 126 | 127 | ############################################################################### 128 | # `test` stage: each instance below uses the `test` template above 129 | ############################################################################### 130 | ## Define the rest of the matrix based on Kitchen testing 131 | # Make sure the instances listed below match up with 132 | # the `platforms` defined in `kitchen.yml` 133 | # yamllint disable rule:line-length 134 | # default-debian-11-tiamat-py3: {extends: '.test_instance'} 135 | # default-debian-10-tiamat-py3: {extends: '.test_instance'} 136 | # default-debian-9-tiamat-py3: {extends: '.test_instance'} 137 | # default-ubuntu-2204-tiamat-py3: {extends: '.test_instance_failure_permitted'} 138 | # default-ubuntu-2004-tiamat-py3: {extends: '.test_instance'} 139 | # default-ubuntu-1804-tiamat-py3: {extends: '.test_instance'} 140 | # default-centos-stream8-tiamat-py3: {extends: '.test_instance_failure_permitted'} 141 | # default-centos-7-tiamat-py3: {extends: '.test_instance'} 142 | # default-amazonlinux-2-tiamat-py3: {extends: '.test_instance'} 143 | # default-oraclelinux-8-tiamat-py3: {extends: '.test_instance'} 144 | # default-oraclelinux-7-tiamat-py3: {extends: '.test_instance'} 145 | # default-almalinux-8-tiamat-py3: {extends: '.test_instance'} 146 | # default-rockylinux-8-tiamat-py3: {extends: '.test_instance'} 147 | default-debian-11-master-py3: {extends: '.test_instance'} 148 | default-debian-10-master-py3: {extends: '.test_instance'} 149 | default-debian-9-master-py3: {extends: '.test_instance'} 150 | # default-ubuntu-2204-master-py3: {extends: '.test_instance_failure_permitted'} 151 | # default-ubuntu-2004-master-py3: {extends: '.test_instance'} 152 | default-ubuntu-1804-master-py3: {extends: '.test_instance'} 153 | # default-centos-stream8-master-py3: {extends: '.test_instance_failure_permitted'} 154 | default-centos-7-master-py3: {extends: '.test_instance'} 155 | # default-fedora-36-master-py3: {extends: '.test_instance_failure_permitted'} 156 | # default-fedora-35-master-py3: {extends: '.test_instance'} 157 | # default-opensuse-leap-153-master-py3: {extends: '.test_instance'} 158 | # default-opensuse-tmbl-latest-master-py3: {extends: '.test_instance_failure_permitted'} 159 | default-amazonlinux-2-master-py3: {extends: '.test_instance'} 160 | # default-oraclelinux-8-master-py3: {extends: '.test_instance'} 161 | # default-oraclelinux-7-master-py3: {extends: '.test_instance'} 162 | default-arch-base-latest-master-py3: {extends: '.test_instance'} 163 | # default-gentoo-stage3-latest-master-py3: {extends: '.test_instance'} 164 | # default-gentoo-stage3-systemd-master-py3: {extends: '.test_instance'} 165 | # default-almalinux-8-master-py3: {extends: '.test_instance'} 166 | # default-rockylinux-8-master-py3: {extends: '.test_instance'} 167 | # default-debian-11-3004-1-py3: {extends: '.test_instance'} 168 | # default-debian-10-3004-1-py3: {extends: '.test_instance'} 169 | # default-debian-9-3004-1-py3: {extends: '.test_instance'} 170 | # default-ubuntu-2204-3004-1-py3: {extends: '.test_instance_failure_permitted'} 171 | # default-ubuntu-2004-3004-1-py3: {extends: '.test_instance'} 172 | # default-ubuntu-1804-3004-1-py3: {extends: '.test_instance'} 173 | # default-centos-stream8-3004-1-py3: {extends: '.test_instance_failure_permitted'} 174 | # default-centos-7-3004-1-py3: {extends: '.test_instance'} 175 | # default-fedora-36-3004-1-py3: {extends: '.test_instance_failure_permitted'} 176 | # default-fedora-35-3004-1-py3: {extends: '.test_instance'} 177 | # default-amazonlinux-2-3004-1-py3: {extends: '.test_instance'} 178 | # default-oraclelinux-8-3004-1-py3: {extends: '.test_instance'} 179 | # default-oraclelinux-7-3004-1-py3: {extends: '.test_instance'} 180 | # default-arch-base-latest-3004-1-py3: {extends: '.test_instance'} 181 | # default-gentoo-stage3-latest-3004-1-py3: {extends: '.test_instance'} 182 | # default-gentoo-stage3-systemd-3004-1-py3: {extends: '.test_instance'} 183 | # default-almalinux-8-3004-1-py3: {extends: '.test_instance'} 184 | # default-rockylinux-8-3004-1-py3: {extends: '.test_instance'} 185 | # default-opensuse-leap-153-3004-0-py3: {extends: '.test_instance'} 186 | # default-opensuse-tmbl-latest-3004-0-py3: {extends: '.test_instance_failure_permitted'} 187 | # default-debian-10-3003-4-py3: {extends: '.test_instance'} 188 | # default-debian-9-3003-4-py3: {extends: '.test_instance'} 189 | # default-ubuntu-2004-3003-4-py3: {extends: '.test_instance'} 190 | # default-ubuntu-1804-3003-4-py3: {extends: '.test_instance'} 191 | # default-centos-stream8-3003-4-py3: {extends: '.test_instance_failure_permitted'} 192 | # default-centos-7-3003-4-py3: {extends: '.test_instance'} 193 | # default-amazonlinux-2-3003-4-py3: {extends: '.test_instance'} 194 | # default-oraclelinux-8-3003-4-py3: {extends: '.test_instance'} 195 | # default-oraclelinux-7-3003-4-py3: {extends: '.test_instance'} 196 | # default-almalinux-8-3003-4-py3: {extends: '.test_instance'} 197 | # yamllint enable rule:line-length 198 | 199 | ############################################################################### 200 | # `release` stage: `semantic-release` 201 | ############################################################################### 202 | semantic-release: 203 | only: *only_branch_master_parent_repo 204 | stage: *stage_release 205 | image: *image_semanticrelease 206 | variables: 207 | MAINTAINER_TOKEN: '${GH_TOKEN}' 208 | script: 209 | # Update `AUTHORS.md` 210 | - '${HOME}/go/bin/maintainer contributor' 211 | # Run `semantic-release` 212 | - 'semantic-release' 213 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | # See https://pre-commit.com for more information 5 | # See https://pre-commit.com/hooks.html for more hooks 6 | ci: 7 | autofix_commit_msg: | 8 | ci(pre-commit.ci): apply auto fixes from pre-commit.com hooks 9 | 10 | For more information, see https://pre-commit.ci 11 | autofix_prs: true 12 | autoupdate_branch: '' 13 | autoupdate_commit_msg: | 14 | ci(pre-commit.ci): perform `pre-commit` autoupdate 15 | autoupdate_schedule: quarterly 16 | skip: [] 17 | submodules: false 18 | default_stages: [commit] 19 | repos: 20 | - repo: https://github.com/dafyddj/commitlint-pre-commit-hook 21 | rev: v2.3.0 22 | hooks: 23 | - id: commitlint 24 | name: Check commit message using commitlint 25 | description: Lint commit message against @commitlint/config-conventional rules 26 | stages: [commit-msg] 27 | additional_dependencies: ['@commitlint/config-conventional@8.3.4'] 28 | - id: commitlint-travis 29 | stages: [manual] 30 | additional_dependencies: ['@commitlint/config-conventional@8.3.4'] 31 | always_run: true 32 | - repo: https://github.com/rubocop-hq/rubocop 33 | rev: v1.30.1 34 | hooks: 35 | - id: rubocop 36 | name: Check Ruby files with rubocop 37 | args: [--debug] 38 | always_run: true 39 | pass_filenames: false 40 | - repo: https://github.com/shellcheck-py/shellcheck-py 41 | rev: v0.8.0.4 42 | hooks: 43 | - id: shellcheck 44 | name: Check shell scripts with shellcheck 45 | files: ^.*\.(sh|bash|ksh)$ 46 | types: [] 47 | - repo: https://github.com/adrienverge/yamllint 48 | rev: v1.26.3 49 | hooks: 50 | - id: yamllint 51 | name: Check YAML syntax with yamllint 52 | args: [--strict, '.'] 53 | always_run: true 54 | pass_filenames: false 55 | - repo: https://github.com/warpnet/salt-lint 56 | rev: v0.8.0 57 | hooks: 58 | - id: salt-lint 59 | name: Check Salt files using salt-lint 60 | files: ^.*\.(sls|jinja|j2|tmpl|tst)$ 61 | - repo: https://github.com/myint/rstcheck 62 | rev: 3f929574 63 | hooks: 64 | - id: rstcheck 65 | name: Check reST files using rstcheck 66 | exclude: 'docs/CHANGELOG.rst' 67 | - repo: https://github.com/saltstack-formulas/mirrors-rst-lint 68 | rev: v1.3.2 69 | hooks: 70 | - id: rst-lint 71 | name: Check reST files using rst-lint 72 | exclude: | 73 | (?x)^( 74 | docs/CHANGELOG.rst| 75 | docs/TOFS_pattern.rst| 76 | )$ 77 | additional_dependencies: [pygments==2.9.0] 78 | -------------------------------------------------------------------------------- /.rstcheck.cfg: -------------------------------------------------------------------------------- 1 | [rstcheck] 2 | report=info 3 | ignore_language=rst 4 | ignore_messages=(Duplicate (ex|im)plicit target.*|Hyperlink target ".*" is not referenced\.$) 5 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | # General overrides used across formulas in the org 5 | Layout/LineLength: 6 | # Increase from default of `80` 7 | # Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`) 8 | Max: 88 9 | Metrics/BlockLength: 10 | IgnoredMethods: 11 | - control 12 | - describe 13 | # Increase from default of `25` 14 | Max: 30 15 | Security/YAMLLoad: 16 | Exclude: 17 | - test/integration/**/_mapdata.rb 18 | 19 | # General settings across all cops in this formula 20 | AllCops: 21 | NewCops: enable 22 | 23 | # Any offenses that should be fixed, e.g. collected via. `rubocop --auto-gen-config` 24 | -------------------------------------------------------------------------------- /.salt-lint: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | exclude_paths: [] 5 | rules: {} 6 | skip_list: 7 | # Using `salt-lint` for linting other files as well, such as Jinja macros/templates 8 | - 205 # Use ".sls" as a Salt State file extension 9 | # Skipping `207` and `208` because `210` is sufficient, at least for the time-being 10 | # I.e. Allows 3-digit unquoted codes to still be used, such as `644` and `755` 11 | - 207 # File modes should always be encapsulated in quotation marks 12 | - 208 # File modes should always contain a leading zero 13 | tags: [] 14 | verbosity: 1 15 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | ################################################################################ 5 | # NOTE: This file is UNMAINTAINED; it is provided for references purposes only. 6 | # No guarantees are tendered that this structure will work after 2020. 7 | ################################################################################ 8 | # * https://en.wikipedia.org/wiki/Travis_CI: 9 | # - "... free open-source plans were removed in [sic] the end of 2020" 10 | # - https://blog.travis-ci.com/2020-11-02-travis-ci-new-billing 11 | # - https://ropensci.org/technotes/2020/11/19/moving-away-travis/ 12 | ################################################################################ 13 | ## Machine config 14 | os: 'linux' 15 | arch: 'amd64' 16 | dist: 'bionic' 17 | version: '~> 1.0' 18 | 19 | ## Language and cache config 20 | language: 'ruby' 21 | cache: 'bundler' 22 | 23 | ## Services config 24 | services: 25 | - docker 26 | 27 | ## Script to run for the test stage 28 | script: 29 | - bin/kitchen verify "${INSTANCE}" 30 | 31 | ## Stages and jobs matrix 32 | stages: 33 | - test 34 | # # As part of the switch away from Travis CI, ensure that the `release` stage 35 | # # is not run inadvertently 36 | # - name: 'release' 37 | # if: 'branch = master AND type != pull_request' 38 | jobs: 39 | include: 40 | ## Define the test stage that runs the linters (and testing matrix, if applicable) 41 | 42 | # Run all of the linters in a single job 43 | - language: 'node_js' 44 | node_js: 'lts/*' 45 | env: 'Lint' 46 | name: 'Lint: salt-lint, yamllint, rubocop, shellcheck & commitlint' 47 | before_install: 'skip' 48 | script: 49 | # Install and run `salt-lint` 50 | - pip install --user salt-lint 51 | - git ls-files -- '*.sls' '*.jinja' '*.j2' '*.tmpl' '*.tst' 52 | | xargs salt-lint 53 | # Install and run `yamllint` 54 | # Need at least `v1.17.0` for the `yaml-files` setting 55 | - pip install --user yamllint>=1.17.0 56 | - yamllint -s . 57 | # Install and run `rubocop` 58 | - gem install rubocop 59 | - rubocop -d 60 | # Run `shellcheck` (already pre-installed in Travis) 61 | - shellcheck --version 62 | - git ls-files -- '*.sh' '*.bash' '*.ksh' 63 | | xargs shellcheck 64 | # Install and run `commitlint` 65 | - npm i -D @commitlint/config-conventional 66 | @commitlint/travis-cli 67 | - commitlint-travis 68 | 69 | # Run `pre-commit` linters in a single job 70 | - language: 'python' 71 | env: 'Lint_pre-commit' 72 | name: 'Lint: pre-commit' 73 | before_install: 'skip' 74 | cache: 75 | directories: 76 | - $HOME/.cache/pre-commit 77 | script: 78 | # Install and run `pre-commit` 79 | - pip install pre-commit==2.7.1 80 | - pre-commit run --all-files --color always --verbose 81 | - pre-commit run --color always --hook-stage manual --verbose commitlint-travis 82 | 83 | ## Define the rest of the matrix based on Kitchen testing 84 | # Make sure the instances listed below match up with 85 | # the `platforms` defined in `kitchen.yml` 86 | # - env: INSTANCE=default-debian-11-tiamat-py3 87 | # - env: INSTANCE=default-debian-10-tiamat-py3 88 | # - env: INSTANCE=default-debian-9-tiamat-py3 89 | # - env: INSTANCE=default-ubuntu-2204-tiamat-py3 90 | # - env: INSTANCE=default-ubuntu-2004-tiamat-py3 91 | # - env: INSTANCE=default-ubuntu-1804-tiamat-py3 92 | # - env: INSTANCE=default-centos-stream8-tiamat-py3 93 | # - env: INSTANCE=default-centos-7-tiamat-py3 94 | # - env: INSTANCE=default-amazonlinux-2-tiamat-py3 95 | # - env: INSTANCE=default-oraclelinux-8-tiamat-py3 96 | # - env: INSTANCE=default-oraclelinux-7-tiamat-py3 97 | # - env: INSTANCE=default-almalinux-8-tiamat-py3 98 | # - env: INSTANCE=default-rockylinux-8-tiamat-py3 99 | - env: INSTANCE=default-debian-11-master-py3 100 | - env: INSTANCE=default-debian-10-master-py3 101 | - env: INSTANCE=default-debian-9-master-py3 102 | # - env: INSTANCE=default-ubuntu-2204-master-py3 103 | # - env: INSTANCE=default-ubuntu-2004-master-py3 104 | - env: INSTANCE=default-ubuntu-1804-master-py3 105 | # - env: INSTANCE=default-centos-stream8-master-py3 106 | - env: INSTANCE=default-centos-7-master-py3 107 | # - env: INSTANCE=default-fedora-36-master-py3 108 | # - env: INSTANCE=default-fedora-35-master-py3 109 | # - env: INSTANCE=default-opensuse-leap-153-master-py3 110 | # - env: INSTANCE=default-opensuse-tmbl-latest-master-py3 111 | - env: INSTANCE=default-amazonlinux-2-master-py3 112 | # - env: INSTANCE=default-oraclelinux-8-master-py3 113 | # - env: INSTANCE=default-oraclelinux-7-master-py3 114 | - env: INSTANCE=default-arch-base-latest-master-py3 115 | # - env: INSTANCE=default-gentoo-stage3-latest-master-py3 116 | # - env: INSTANCE=default-gentoo-stage3-systemd-master-py3 117 | # - env: INSTANCE=default-almalinux-8-master-py3 118 | # - env: INSTANCE=default-rockylinux-8-master-py3 119 | # - env: INSTANCE=default-debian-11-3004-1-py3 120 | # - env: INSTANCE=default-debian-10-3004-1-py3 121 | # - env: INSTANCE=default-debian-9-3004-1-py3 122 | # - env: INSTANCE=default-ubuntu-2204-3004-1-py3 123 | # - env: INSTANCE=default-ubuntu-2004-3004-1-py3 124 | # - env: INSTANCE=default-ubuntu-1804-3004-1-py3 125 | # - env: INSTANCE=default-centos-stream8-3004-1-py3 126 | # - env: INSTANCE=default-centos-7-3004-1-py3 127 | # - env: INSTANCE=default-fedora-36-3004-1-py3 128 | # - env: INSTANCE=default-fedora-35-3004-1-py3 129 | # - env: INSTANCE=default-amazonlinux-2-3004-1-py3 130 | # - env: INSTANCE=default-oraclelinux-8-3004-1-py3 131 | # - env: INSTANCE=default-oraclelinux-7-3004-1-py3 132 | # - env: INSTANCE=default-arch-base-latest-3004-1-py3 133 | # - env: INSTANCE=default-gentoo-stage3-latest-3004-1-py3 134 | # - env: INSTANCE=default-gentoo-stage3-systemd-3004-1-py3 135 | # - env: INSTANCE=default-almalinux-8-3004-1-py3 136 | # - env: INSTANCE=default-rockylinux-8-3004-1-py3 137 | # - env: INSTANCE=default-opensuse-leap-153-3004-0-py3 138 | # - env: INSTANCE=default-opensuse-tmbl-latest-3004-0-py3 139 | # - env: INSTANCE=default-debian-10-3003-4-py3 140 | # - env: INSTANCE=default-debian-9-3003-4-py3 141 | # - env: INSTANCE=default-ubuntu-2004-3003-4-py3 142 | # - env: INSTANCE=default-ubuntu-1804-3003-4-py3 143 | # - env: INSTANCE=default-centos-stream8-3003-4-py3 144 | # - env: INSTANCE=default-centos-7-3003-4-py3 145 | # - env: INSTANCE=default-amazonlinux-2-3003-4-py3 146 | # - env: INSTANCE=default-oraclelinux-8-3003-4-py3 147 | # - env: INSTANCE=default-oraclelinux-7-3003-4-py3 148 | # - env: INSTANCE=default-almalinux-8-3003-4-py3 149 | 150 | ## Define the release stage that runs `semantic-release` 151 | - stage: 'release' 152 | language: 'node_js' 153 | node_js: 'lts/*' 154 | env: 'Release' 155 | name: 'Run semantic-release inc. file updates to AUTHORS, CHANGELOG & FORMULA' 156 | before_install: 'skip' 157 | script: 158 | # Update `AUTHORS.md` 159 | - export MAINTAINER_TOKEN=${GH_TOKEN} 160 | - go get github.com/myii/maintainer 161 | - maintainer contributor 162 | 163 | # Install all dependencies required for `semantic-release` 164 | - npm i -D @semantic-release/changelog@3 165 | @semantic-release/exec@3 166 | @semantic-release/git@7 167 | deploy: 168 | provider: 'script' 169 | # Opt-in to `dpl v2` to complete the Travis build config validation (beta) 170 | # * https://docs.travis-ci.com/user/build-config-validation 171 | # Deprecated `skip_cleanup` can now be avoided, `cleanup: false` is by default 172 | edge: true 173 | # Run `semantic-release` 174 | script: 'npx semantic-release@15.14' 175 | 176 | # Notification options: `always`, `never` or `change` 177 | notifications: 178 | webhooks: 179 | if: 'repo = saltstack-formulas/mongodb-formula' 180 | urls: 181 | - https://saltstack-formulas.zulipchat.com/api/v1/external/travis?api_key=HsIq3o5QmLxdnVCKF9is0FUIpkpAY79P&stream=CI&topic=saltstack-formulas%2Fmongodb-formula&ignore_pull_requests=true 182 | on_success: always # default: always 183 | on_failure: always # default: always 184 | on_start: always # default: never 185 | on_cancel: always # default: always 186 | on_error: always # default: always 187 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | # Extend the `default` configuration provided by `yamllint` 5 | extends: 'default' 6 | 7 | # Files to ignore completely 8 | # 1. All YAML files under directory `.bundle/`, introduced if gems are installed locally 9 | # 2. All YAML files under directory `.cache/`, introduced during the CI run 10 | # 3. All YAML files under directory `.git/` 11 | # 4. All YAML files under directory `node_modules/`, introduced during the CI run 12 | # 5. Any SLS files under directory `test/`, which are actually state files 13 | # 6. Any YAML files under directory `.kitchen/`, introduced during local testing 14 | # 7. `kitchen.vagrant.yml`, which contains Embedded Ruby (ERB) template syntax 15 | ignore: | 16 | .bundle/ 17 | .cache/ 18 | .git/ 19 | node_modules/ 20 | test/**/states/**/*.sls 21 | .kitchen/ 22 | kitchen.vagrant.yml 23 | pillar.example 24 | mongodb/osfamilymap.yaml 25 | mongodb/osfingermap.yaml 26 | 27 | yaml-files: 28 | # Default settings 29 | - '*.yaml' 30 | - '*.yml' 31 | - .salt-lint 32 | - .yamllint 33 | # SaltStack Formulas additional settings 34 | - '*.example' 35 | - test/**/*.sls 36 | 37 | rules: 38 | empty-values: 39 | forbid-in-block-mappings: true 40 | forbid-in-flow-mappings: true 41 | line-length: 42 | # Increase from default of `80` 43 | # Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`) 44 | max: 88 45 | octal-values: 46 | forbid-implicit-octal: true 47 | forbid-explicit-octal: true 48 | -------------------------------------------------------------------------------- /AUTHORS.md: -------------------------------------------------------------------------------- 1 | # Authors 2 | 3 | This list is sorted by the number of commits per contributor in _descending_ order. 4 | 5 | Avatar|Contributor|Contributions 6 | :-:|---|:-: 7 | @myii|[@myii](https://github.com/myii)|97 8 | @noelmcloughlin|[@noelmcloughlin](https://github.com/noelmcloughlin)|47 9 | @gravyboat|[@gravyboat](https://github.com/gravyboat)|18 10 | @kevinschoon|[@kevinschoon](https://github.com/kevinschoon)|9 11 | @stp-ip|[@stp-ip](https://github.com/stp-ip)|5 12 | @aboe76|[@aboe76](https://github.com/aboe76)|5 13 | @genuss|[@genuss](https://github.com/genuss)|5 14 | @nmadhok|[@nmadhok](https://github.com/nmadhok)|4 15 | @wdalmut|[@wdalmut](https://github.com/wdalmut)|4 16 | @puneetk|[@puneetk](https://github.com/puneetk)|4 17 | @sbreidba|[@sbreidba](https://github.com/sbreidba)|4 18 | @dafyddj|[@dafyddj](https://github.com/dafyddj)|3 19 | @vutny|[@vutny](https://github.com/vutny)|2 20 | @whiteinge|[@whiteinge](https://github.com/whiteinge)|2 21 | @blarghmatey|[@blarghmatey](https://github.com/blarghmatey)|2 22 | @viktortnk|[@viktortnk](https://github.com/viktortnk)|2 23 | @babilen|[@babilen](https://github.com/babilen)|2 24 | @amr|[@amr](https://github.com/amr)|1 25 | @andrew-vant|[@andrew-vant](https://github.com/andrew-vant)|1 26 | @auser|[@auser](https://github.com/auser)|1 27 | @iggy|[@iggy](https://github.com/iggy)|1 28 | @baby-gnu|[@baby-gnu](https://github.com/baby-gnu)|1 29 | @UtahDave|[@UtahDave](https://github.com/UtahDave)|1 30 | @HeinrichFilter|[@HeinrichFilter](https://github.com/HeinrichFilter)|1 31 | @techhat|[@techhat](https://github.com/techhat)|1 32 | @maratsh|[@maratsh](https://github.com/maratsh)|1 33 | @holms|[@holms](https://github.com/holms)|1 34 | @thatch45|[@thatch45](https://github.com/thatch45)|1 35 | @abednarik|[@abednarik](https://github.com/abednarik)|1 36 | @eglute|[@eglute](https://github.com/eglute)|1 37 | @littleski|[@littleski](https://github.com/littleski)|1 38 | 39 | --- 40 | 41 | Auto-generated by a [forked version](https://github.com/myii/maintainer) of [gaocegege/maintainer](https://github.com/gaocegege/maintainer) on 2022-01-24. 42 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [1.1.1](https://github.com/saltstack-formulas/mongodb-formula/compare/v1.1.0...v1.1.1) (2022-01-24) 4 | 5 | 6 | ### Bug Fixes 7 | 8 | * **repo:** do not override service from package ([789bb9a](https://github.com/saltstack-formulas/mongodb-formula/commit/789bb9a7c205a80163bea96652e3e1e758387609)) 9 | * **users:** mongodb as system user/group ([0054e6e](https://github.com/saltstack-formulas/mongodb-formula/commit/0054e6ebf1f58411e8a7041d7f930e9cce93490e)) 10 | 11 | 12 | ### Continuous Integration 13 | 14 | * **kitchen+ci:** update with `3004` pre-salted images/boxes [skip ci] ([1ed6fd5](https://github.com/saltstack-formulas/mongodb-formula/commit/1ed6fd507b0ac58bb095b4860a40c01246e88fe2)) 15 | * **kitchen+ci:** update with latest `3003.2` pre-salted images [skip ci] ([c66a656](https://github.com/saltstack-formulas/mongodb-formula/commit/c66a6566142d5d30a429771601ed8562875b468a)) 16 | * **kitchen+ci:** update with latest CVE pre-salted images [skip ci] ([67228eb](https://github.com/saltstack-formulas/mongodb-formula/commit/67228eb31c1a646996efbdc5e534d056c075c3ce)) 17 | 18 | # [1.1.0](https://github.com/saltstack-formulas/mongodb-formula/compare/v1.0.3...v1.1.0) (2021-08-09) 19 | 20 | 21 | ### Continuous Integration 22 | 23 | * **gemfile+lock:** use `ssf` customised `inspec` repo [skip ci] ([0baed21](https://github.com/saltstack-formulas/mongodb-formula/commit/0baed214054aff08236184d096d9add7c7442e35)) 24 | * add Debian 11 Bullseye & update `yamllint` configuration [skip ci] ([6266aa9](https://github.com/saltstack-formulas/mongodb-formula/commit/6266aa95d08e411f0a0d7ef456381ed0d5635f4f)) 25 | * **3003.1:** update inc. AlmaLinux, Rocky & `rst-lint` [skip ci] ([b34922b](https://github.com/saltstack-formulas/mongodb-formula/commit/b34922bd9448b22940f549ce2f498d39efeaf9ba)) 26 | * **kitchen:** move `provisioner` block & update `run_command` [skip ci] ([a1af7a5](https://github.com/saltstack-formulas/mongodb-formula/commit/a1af7a575a942a48bf1d3af026c78d790ce1e04f)) 27 | 28 | 29 | ### Features 30 | 31 | * **repository:** only take keys with values ([d71b5d1](https://github.com/saltstack-formulas/mongodb-formula/commit/d71b5d144818dd668af51bd7c158a5e797b05fa6)) 32 | 33 | ## [1.0.3](https://github.com/saltstack-formulas/mongodb-formula/compare/v1.0.2...v1.0.3) (2021-06-24) 34 | 35 | 36 | ### Bug Fixes 37 | 38 | * remove firewalld from dependencies ([7bf363c](https://github.com/saltstack-formulas/mongodb-formula/commit/7bf363c9830b86939d6442d615f4d03c435435c2)) 39 | 40 | 41 | ### Continuous Integration 42 | 43 | * **kitchen+gitlab:** remove Ubuntu 16.04 & Fedora 32 (EOL) [skip ci] ([f709345](https://github.com/saltstack-formulas/mongodb-formula/commit/f70934596c541cdfc4ab6f6276e5513101e8b6b0)) 44 | * add `arch-master` to matrix and update `.travis.yml` [skip ci] ([706b49f](https://github.com/saltstack-formulas/mongodb-formula/commit/706b49fe244a581c5621e3faabf04300d4a51687)) 45 | * **commitlint:** ensure `upstream/master` uses main repo URL [skip ci] ([8c82e2b](https://github.com/saltstack-formulas/mongodb-formula/commit/8c82e2b7bb4e49825cbe766a35bfc2a54c127d7b)) 46 | * **gemfile+lock:** use `ssf` customised `kitchen-docker` repo [skip ci] ([b24c101](https://github.com/saltstack-formulas/mongodb-formula/commit/b24c101f24c33c0f5f4b07cb13fbc2daffd34f0d)) 47 | * **gitlab-ci:** add `rubocop` linter (with `allow_failure`) [skip ci] ([586292c](https://github.com/saltstack-formulas/mongodb-formula/commit/586292c2e2d02202cc1474f524dce3401ac630d1)) 48 | * **gitlab-ci:** use GitLab CI as Travis CI replacement ([b743808](https://github.com/saltstack-formulas/mongodb-formula/commit/b7438088004ed6147338c4bead19e3dbb2ccee03)) 49 | * **kitchen+ci:** use latest pre-salted images (after CVE) [skip ci] ([74ce488](https://github.com/saltstack-formulas/mongodb-formula/commit/74ce4886c79f8192c207c1268313343bfa6ca946)) 50 | * **kitchen+gitlab:** adjust matrix to add `3003` [skip ci] ([d3e5feb](https://github.com/saltstack-formulas/mongodb-formula/commit/d3e5feb2ed06739ffb228ed06d51b6e9f0a754f8)) 51 | * **kitchen+gitlab-ci:** use latest pre-salted images [skip ci] ([7db78ba](https://github.com/saltstack-formulas/mongodb-formula/commit/7db78ba0919a42c271c48e26a40f9ba3ac142212)) 52 | * **pre-commit:** add to formula [skip ci] ([6849f80](https://github.com/saltstack-formulas/mongodb-formula/commit/6849f80287e608fdf7230ebe8dbdf9c4634f132e)) 53 | * **pre-commit:** enable/disable `rstcheck` as relevant [skip ci] ([ffe3388](https://github.com/saltstack-formulas/mongodb-formula/commit/ffe33882c7815cc8b3ba60c282bcfac770974947)) 54 | * **pre-commit:** finalise `rstcheck` configuration [skip ci] ([b9e0df0](https://github.com/saltstack-formulas/mongodb-formula/commit/b9e0df09fab10aa7cd14c32ec9b41aeab53d9f93)) 55 | * **pre-commit:** update hook for `rubocop` [skip ci] ([dccb17c](https://github.com/saltstack-formulas/mongodb-formula/commit/dccb17cbab62f4f1aa9ee438155f2e2ab5965d93)) 56 | 57 | 58 | ### Documentation 59 | 60 | * remove files which aren't formula-specific [skip ci] ([b8bfdd3](https://github.com/saltstack-formulas/mongodb-formula/commit/b8bfdd3a0e35d03095c1543f49f169972bb9f366)) 61 | * **readme:** fix headings and contributing link [skip ci] ([8e6d59b](https://github.com/saltstack-formulas/mongodb-formula/commit/8e6d59b4b3a30745e48f9ee24d6df4b5a80e883b)) 62 | 63 | 64 | ### Tests 65 | 66 | * standardise use of `share` suite & `_mapdata` state [skip ci] ([82a3b26](https://github.com/saltstack-formulas/mongodb-formula/commit/82a3b2611858189baa186fa098c3f5281fb6ad2f)) 67 | 68 | ## [1.0.2](https://github.com/saltstack-formulas/mongodb-formula/compare/v1.0.1...v1.0.2) (2020-08-09) 69 | 70 | 71 | ### Bug Fixes 72 | 73 | * **issues:** file various minor issues ([cf8b457](https://github.com/saltstack-formulas/mongodb-formula/commit/cf8b457bb75fcfde90cfa77d9ad113922bb1fc74)) 74 | 75 | ## [1.0.1](https://github.com/saltstack-formulas/mongodb-formula/compare/v1.0.0...v1.0.1) (2020-08-09) 76 | 77 | 78 | ### Bug Fixes 79 | 80 | * **config:** rename config file to .conf ([274e50b](https://github.com/saltstack-formulas/mongodb-formula/commit/274e50ba35b73d2d9fea1991ac246a48cd21b65e)) 81 | * **linux:** fixup linux ci/cd ([b002965](https://github.com/saltstack-formulas/mongodb-formula/commit/b00296553f36fb02ad6fae3961f1c9bad1fc415e)) 82 | * **macos:** hugepages in linux kernel only ([25a6883](https://github.com/saltstack-formulas/mongodb-formula/commit/25a6883d36540a78baea2d478ed3a22180d04c28)) 83 | * **macos:** launchctl and plist fixes ([543d5c7](https://github.com/saltstack-formulas/mongodb-formula/commit/543d5c7e6c0ff8a9de0b2cf3e086dee090a8fabd)) 84 | 85 | 86 | ### Code Refactoring 87 | 88 | * **jinja:** depreciate/replacer two variable names ([2f07675](https://github.com/saltstack-formulas/mongodb-formula/commit/2f076757cf31b216d11699d7604f5dc36614e454)) 89 | 90 | 91 | ### Continuous Integration 92 | 93 | * **kitchen:** use `saltimages` Docker Hub where available [skip ci] ([2f143f9](https://github.com/saltstack-formulas/mongodb-formula/commit/2f143f9dccfad53a52e0b7135a962daa60da9b9d)) 94 | * **kitchen+travis:** add new platforms [skip ci] ([c16bb41](https://github.com/saltstack-formulas/mongodb-formula/commit/c16bb4167af505633d7b0fd79f404d3adb5e02e5)) 95 | 96 | 97 | ### Styles 98 | 99 | * **libtofs.jinja:** use Black-inspired Jinja formatting [skip ci] ([af35635](https://github.com/saltstack-formulas/mongodb-formula/commit/af35635af74ce477d720d078b11bda654f140a44)) 100 | 101 | # [1.0.0](https://github.com/saltstack-formulas/mongodb-formula/compare/v0.19.1...v1.0.0) (2020-05-26) 102 | 103 | 104 | ### Bug Fixes 105 | 106 | * **script:** fix some travis tests ([63cfb1e](https://github.com/saltstack-formulas/mongodb-formula/commit/63cfb1e388b46f82b5e555f27839f618d49734f4)) 107 | 108 | 109 | ### Code Refactoring 110 | 111 | * **all:** align to template; fix bugs and ci ([fc1ff28](https://github.com/saltstack-formulas/mongodb-formula/commit/fc1ff28b9dc944bf9460c804e8a70d2be6cd4fb8)) 112 | 113 | 114 | ### Continuous Integration 115 | 116 | * **gemfile.lock:** add to repo with updated `Gemfile` [skip ci] ([e76b40c](https://github.com/saltstack-formulas/mongodb-formula/commit/e76b40ce14405173c1d4f88584dba8ef28c1eb07)) 117 | * **kitchen:** avoid using bootstrap for `master` instances [skip ci] ([498b79f](https://github.com/saltstack-formulas/mongodb-formula/commit/498b79f6ffaeef4560c02d805536d20c6f7d1ba7)) 118 | * **kitchen+travis:** adjust matrix to add `3000.3` [skip ci] ([f98319a](https://github.com/saltstack-formulas/mongodb-formula/commit/f98319a348c222462a0ef9bad7662e927b9f4e37)) 119 | * **kitchen+travis:** remove `master-py2-arch-base-latest` [skip ci] ([2220bd9](https://github.com/saltstack-formulas/mongodb-formula/commit/2220bd95bad711817b1deebf70184555fa3d66fc)) 120 | * **travis:** add notifications => zulip [skip ci] ([81d3677](https://github.com/saltstack-formulas/mongodb-formula/commit/81d3677a277b92b2de0998f2d98224607a32f4ac)) 121 | * **workflows/commitlint:** add to repo [skip ci] ([3e8848d](https://github.com/saltstack-formulas/mongodb-formula/commit/3e8848db7b08dd3368b969039031d61916d6a2fb)) 122 | 123 | 124 | ### Documentation 125 | 126 | * **readme:** add depth one ([5680c6b](https://github.com/saltstack-formulas/mongodb-formula/commit/5680c6b151c1db2d43fb81d7d3b02c3bea0eedc6)) 127 | 128 | 129 | ### Features 130 | 131 | * **semantic-release:** standardise for this formula ([f56ba6a](https://github.com/saltstack-formulas/mongodb-formula/commit/f56ba6ac75998b97842f897266b4c6b13d9e37c7)) 132 | 133 | 134 | ### BREAKING CHANGES 135 | 136 | * **all:** The data dictionary is simplified and redesigned. 137 | This formula is aligned to template-formula with multiple fixes. 138 | Retest your states and update pillar data accordingly. 139 | For developer convenience, connectors and gui states are introduced. 140 | See pillar.example, defaults.yaml, and docs/README. 141 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners 2 | 3 | # SECTION: Owner(s) for everything in the repo, unless a later match takes precedence 4 | # FILE PATTERN OWNER(S) 5 | * @noelmcloughlin 6 | 7 | # SECTION: Owner(s) for specific directories 8 | # FILE PATTERN OWNER(S) 9 | 10 | # SECTION: Owner(s) for files/directories related to `semantic-release` 11 | # FILE PATTERN OWNER(S) 12 | /.github/workflows/ @saltstack-formulas/ssf 13 | /bin/install-hooks @saltstack-formulas/ssf 14 | /bin/kitchen @saltstack-formulas/ssf 15 | /docs/AUTHORS.rst @saltstack-formulas/ssf 16 | /docs/CHANGELOG.rst @saltstack-formulas/ssf 17 | /docs/TOFS_pattern.rst @saltstack-formulas/ssf 18 | /*/_mapdata/ @saltstack-formulas/ssf 19 | /*/libsaltcli.jinja @saltstack-formulas/ssf 20 | /*/libtofs.jinja @saltstack-formulas/ssf 21 | /test/integration/**/_mapdata.rb @saltstack-formulas/ssf 22 | /test/integration/**/libraries/system.rb @saltstack-formulas/ssf 23 | /test/integration/**/inspec.yml @saltstack-formulas/ssf 24 | /test/integration/**/README.md @saltstack-formulas/ssf 25 | /test/salt/pillar/top.sls @saltstack-formulas/ssf 26 | /.gitignore @saltstack-formulas/ssf 27 | /.cirrus.yml @saltstack-formulas/ssf 28 | /.gitlab-ci.yml @saltstack-formulas/ssf 29 | /.pre-commit-config.yaml @saltstack-formulas/ssf 30 | /.rstcheck.cfg @saltstack-formulas/ssf 31 | /.rubocop.yml @saltstack-formulas/ssf 32 | /.salt-lint @saltstack-formulas/ssf 33 | /.travis.yml @saltstack-formulas/ssf 34 | /.yamllint @saltstack-formulas/ssf 35 | /AUTHORS.md @saltstack-formulas/ssf 36 | /CHANGELOG.md @saltstack-formulas/ssf 37 | /CODEOWNERS @saltstack-formulas/ssf 38 | /commitlint.config.js @saltstack-formulas/ssf 39 | /FORMULA @saltstack-formulas/ssf 40 | /Gemfile @saltstack-formulas/ssf 41 | /Gemfile.lock @saltstack-formulas/ssf 42 | /kitchen.yml @saltstack-formulas/ssf 43 | /kitchen.vagrant.yml @saltstack-formulas/ssf 44 | /kitchen.windows.yml @saltstack-formulas/ssf 45 | /pre-commit_semantic-release.sh @saltstack-formulas/ssf 46 | /release-rules.js @saltstack-formulas/ssf 47 | /release.config.js @saltstack-formulas/ssf 48 | 49 | # SECTION: Owner(s) for specific files 50 | # FILE PATTERN OWNER(S) 51 | -------------------------------------------------------------------------------- /FORMULA: -------------------------------------------------------------------------------- 1 | name: mongodb 2 | os: Debian, Ubuntu, Raspbian, RedHat, Fedora, CentOS, Amazon, Suse, openSUSE, Gentoo, Funtoo, Arch, Manjaro, Alpine, FreeBSD, OpenBSD, Solaris, SmartOS, Windows, MacOS 3 | os_family: Debian, RedHat, Suse, Gentoo, Arch, Alpine, FreeBSD, OpenBSD, Solaris, Windows, MacOS 4 | version: 1.1.1 5 | release: 1 6 | minimum_version: 2019.2 7 | summary: mongodb formula 8 | description: Formula to install mongodb and configure it 9 | top_level_dir: mongodb 10 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source ENV.fetch('PROXY_RUBYGEMSORG', 'https://rubygems.org') 4 | 5 | # Install the `inspec` gem using `git` because versions after `4.22.22` 6 | # suppress diff output; this version fixes this for our uses. 7 | # rubocop:disable Layout/LineLength 8 | gem 'inspec', git: 'https://gitlab.com/saltstack-formulas/infrastructure/inspec', branch: 'ssf' 9 | # rubocop:enable Layout/LineLength 10 | 11 | # Install the `kitchen-docker` gem using `git` in order to gain a performance 12 | # improvement: avoid package installations which are already covered by the 13 | # `salt-image-builder` (i.e. the pre-salted images that we're using) 14 | # rubocop:disable Layout/LineLength 15 | gem 'kitchen-docker', git: 'https://gitlab.com/saltstack-formulas/infrastructure/kitchen-docker', branch: 'ssf' 16 | # rubocop:enable Layout/LineLength 17 | 18 | gem 'kitchen-inspec', '>= 2.5.0' 19 | gem 'kitchen-salt', '>= 0.7.2' 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019 Salt Stack Formulas 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /bin/install-hooks: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | set -o nounset # Treat unset variables as an error and immediately exit 3 | set -o errexit # If a command fails exit the whole script 4 | 5 | if [ "${DEBUG:-false}" = "true" ]; then 6 | set -x # Run the entire script in debug mode 7 | fi 8 | 9 | if ! command -v pre-commit >/dev/null 2>&1; then 10 | echo "pre-commit not found: please install or check your PATH" >&2 11 | echo "See https://pre-commit.com/#installation" >&2 12 | exit 1 13 | fi 14 | 15 | pre-commit install --install-hooks 16 | pre-commit install --hook-type commit-msg --install-hooks 17 | -------------------------------------------------------------------------------- /bin/kitchen: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'kitchen' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | require 'pathname' 12 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', 13 | Pathname.new(__FILE__).realpath) 14 | 15 | bundle_binstub = File.expand_path('bundle', __dir__) 16 | 17 | if File.file?(bundle_binstub) 18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ 19 | load(bundle_binstub) 20 | else 21 | abort( 22 | 'Your `bin/bundle` was not generated by Bundler, ' \ 23 | 'so this binstub cannot run. Replace `bin/bundle` by running ' \ 24 | '`bundle binstubs bundler --force`, then run this command again.' 25 | ) 26 | end 27 | end 28 | 29 | require 'rubygems' 30 | require 'bundler/setup' 31 | 32 | load Gem.bin_path('test-kitchen', 'kitchen') 33 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@commitlint/config-conventional'], 3 | rules: { 4 | 'body-max-line-length': [2, 'always', 120], 5 | 'footer-max-line-length': [2, 'always', 120], 6 | 'header-max-length': [2, 'always', 72], 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /docs/AUTHORS.rst: -------------------------------------------------------------------------------- 1 | .. role:: raw-html-m2r(raw) 2 | :format: html 3 | 4 | 5 | Authors 6 | ======= 7 | 8 | This list is sorted by the number of commits per contributor in *descending* order. 9 | 10 | .. list-table:: 11 | :header-rows: 1 12 | 13 | * - Avatar 14 | - Contributor 15 | - Contributions 16 | * - :raw-html-m2r:`@myii` 17 | - `@myii `_ 18 | - 97 19 | * - :raw-html-m2r:`@noelmcloughlin` 20 | - `@noelmcloughlin `_ 21 | - 47 22 | * - :raw-html-m2r:`@gravyboat` 23 | - `@gravyboat `_ 24 | - 18 25 | * - :raw-html-m2r:`@kevinschoon` 26 | - `@kevinschoon `_ 27 | - 9 28 | * - :raw-html-m2r:`@stp-ip` 29 | - `@stp-ip `_ 30 | - 5 31 | * - :raw-html-m2r:`@aboe76` 32 | - `@aboe76 `_ 33 | - 5 34 | * - :raw-html-m2r:`@genuss` 35 | - `@genuss `_ 36 | - 5 37 | * - :raw-html-m2r:`@nmadhok` 38 | - `@nmadhok `_ 39 | - 4 40 | * - :raw-html-m2r:`@wdalmut` 41 | - `@wdalmut `_ 42 | - 4 43 | * - :raw-html-m2r:`@puneetk` 44 | - `@puneetk `_ 45 | - 4 46 | * - :raw-html-m2r:`@sbreidba` 47 | - `@sbreidba `_ 48 | - 4 49 | * - :raw-html-m2r:`@dafyddj` 50 | - `@dafyddj `_ 51 | - 3 52 | * - :raw-html-m2r:`@vutny` 53 | - `@vutny `_ 54 | - 2 55 | * - :raw-html-m2r:`@whiteinge` 56 | - `@whiteinge `_ 57 | - 2 58 | * - :raw-html-m2r:`@blarghmatey` 59 | - `@blarghmatey `_ 60 | - 2 61 | * - :raw-html-m2r:`@viktortnk` 62 | - `@viktortnk `_ 63 | - 2 64 | * - :raw-html-m2r:`@babilen` 65 | - `@babilen `_ 66 | - 2 67 | * - :raw-html-m2r:`@amr` 68 | - `@amr `_ 69 | - 1 70 | * - :raw-html-m2r:`@andrew-vant` 71 | - `@andrew-vant `_ 72 | - 1 73 | * - :raw-html-m2r:`@auser` 74 | - `@auser `_ 75 | - 1 76 | * - :raw-html-m2r:`@iggy` 77 | - `@iggy `_ 78 | - 1 79 | * - :raw-html-m2r:`@baby-gnu` 80 | - `@baby-gnu `_ 81 | - 1 82 | * - :raw-html-m2r:`@UtahDave` 83 | - `@UtahDave `_ 84 | - 1 85 | * - :raw-html-m2r:`@HeinrichFilter` 86 | - `@HeinrichFilter `_ 87 | - 1 88 | * - :raw-html-m2r:`@techhat` 89 | - `@techhat `_ 90 | - 1 91 | * - :raw-html-m2r:`@maratsh` 92 | - `@maratsh `_ 93 | - 1 94 | * - :raw-html-m2r:`@holms` 95 | - `@holms `_ 96 | - 1 97 | * - :raw-html-m2r:`@thatch45` 98 | - `@thatch45 `_ 99 | - 1 100 | * - :raw-html-m2r:`@abednarik` 101 | - `@abednarik `_ 102 | - 1 103 | * - :raw-html-m2r:`@eglute` 104 | - `@eglute `_ 105 | - 1 106 | * - :raw-html-m2r:`@littleski` 107 | - `@littleski `_ 108 | - 1 109 | 110 | 111 | ---- 112 | 113 | Auto-generated by a `forked version `_ of `gaocegege/maintainer `_ on 2022-01-24. 114 | -------------------------------------------------------------------------------- /docs/CHANGELOG.rst: -------------------------------------------------------------------------------- 1 | 2 | Changelog 3 | ========= 4 | 5 | `1.1.1 `_ (2022-01-24) 6 | --------------------------------------------------------------------------------------------------------- 7 | 8 | Bug Fixes 9 | ^^^^^^^^^ 10 | 11 | 12 | * **repo:** do not override service from package (\ `789bb9a `_\ ) 13 | * **users:** mongodb as system user/group (\ `0054e6e `_\ ) 14 | 15 | Continuous Integration 16 | ^^^^^^^^^^^^^^^^^^^^^^ 17 | 18 | 19 | * **kitchen+ci:** update with ``3004`` pre-salted images/boxes [skip ci] (\ `1ed6fd5 `_\ ) 20 | * **kitchen+ci:** update with latest ``3003.2`` pre-salted images [skip ci] (\ `c66a656 `_\ ) 21 | * **kitchen+ci:** update with latest CVE pre-salted images [skip ci] (\ `67228eb `_\ ) 22 | 23 | `1.1.0 `_ (2021-08-09) 24 | --------------------------------------------------------------------------------------------------------- 25 | 26 | Continuous Integration 27 | ^^^^^^^^^^^^^^^^^^^^^^ 28 | 29 | 30 | * **gemfile+lock:** use ``ssf`` customised ``inspec`` repo [skip ci] (\ `0baed21 `_\ ) 31 | * add Debian 11 Bullseye & update ``yamllint`` configuration [skip ci] (\ `6266aa9 `_\ ) 32 | * **3003.1:** update inc. AlmaLinux, Rocky & ``rst-lint`` [skip ci] (\ `b34922b `_\ ) 33 | * **kitchen:** move ``provisioner`` block & update ``run_command`` [skip ci] (\ `a1af7a5 `_\ ) 34 | 35 | Features 36 | ^^^^^^^^ 37 | 38 | 39 | * **repository:** only take keys with values (\ `d71b5d1 `_\ ) 40 | 41 | `1.0.3 `_ (2021-06-24) 42 | --------------------------------------------------------------------------------------------------------- 43 | 44 | Bug Fixes 45 | ^^^^^^^^^ 46 | 47 | 48 | * remove firewalld from dependencies (\ `7bf363c `_\ ) 49 | 50 | Continuous Integration 51 | ^^^^^^^^^^^^^^^^^^^^^^ 52 | 53 | 54 | * **kitchen+gitlab:** remove Ubuntu 16.04 & Fedora 32 (EOL) [skip ci] (\ `f709345 `_\ ) 55 | * add ``arch-master`` to matrix and update ``.travis.yml`` [skip ci] (\ `706b49f `_\ ) 56 | * **commitlint:** ensure ``upstream/master`` uses main repo URL [skip ci] (\ `8c82e2b `_\ ) 57 | * **gemfile+lock:** use ``ssf`` customised ``kitchen-docker`` repo [skip ci] (\ `b24c101 `_\ ) 58 | * **gitlab-ci:** add ``rubocop`` linter (with ``allow_failure``\ ) [skip ci] (\ `586292c `_\ ) 59 | * **gitlab-ci:** use GitLab CI as Travis CI replacement (\ `b743808 `_\ ) 60 | * **kitchen+ci:** use latest pre-salted images (after CVE) [skip ci] (\ `74ce488 `_\ ) 61 | * **kitchen+gitlab:** adjust matrix to add ``3003`` [skip ci] (\ `d3e5feb `_\ ) 62 | * **kitchen+gitlab-ci:** use latest pre-salted images [skip ci] (\ `7db78ba `_\ ) 63 | * **pre-commit:** add to formula [skip ci] (\ `6849f80 `_\ ) 64 | * **pre-commit:** enable/disable ``rstcheck`` as relevant [skip ci] (\ `ffe3388 `_\ ) 65 | * **pre-commit:** finalise ``rstcheck`` configuration [skip ci] (\ `b9e0df0 `_\ ) 66 | * **pre-commit:** update hook for ``rubocop`` [skip ci] (\ `dccb17c `_\ ) 67 | 68 | Documentation 69 | ^^^^^^^^^^^^^ 70 | 71 | 72 | * remove files which aren't formula-specific [skip ci] (\ `b8bfdd3 `_\ ) 73 | * **readme:** fix headings and contributing link [skip ci] (\ `8e6d59b `_\ ) 74 | 75 | Tests 76 | ^^^^^ 77 | 78 | 79 | * standardise use of ``share`` suite & ``_mapdata`` state [skip ci] (\ `82a3b26 `_\ ) 80 | 81 | `1.0.2 `_ (2020-08-09) 82 | --------------------------------------------------------------------------------------------------------- 83 | 84 | Bug Fixes 85 | ^^^^^^^^^ 86 | 87 | 88 | * **issues:** file various minor issues (\ `cf8b457 `_\ ) 89 | 90 | `1.0.1 `_ (2020-08-09) 91 | --------------------------------------------------------------------------------------------------------- 92 | 93 | Bug Fixes 94 | ^^^^^^^^^ 95 | 96 | 97 | * **config:** rename config file to .conf (\ `274e50b `_\ ) 98 | * **linux:** fixup linux ci/cd (\ `b002965 `_\ ) 99 | * **macos:** hugepages in linux kernel only (\ `25a6883 `_\ ) 100 | * **macos:** launchctl and plist fixes (\ `543d5c7 `_\ ) 101 | 102 | Code Refactoring 103 | ^^^^^^^^^^^^^^^^ 104 | 105 | 106 | * **jinja:** depreciate/replacer two variable names (\ `2f07675 `_\ ) 107 | 108 | Continuous Integration 109 | ^^^^^^^^^^^^^^^^^^^^^^ 110 | 111 | 112 | * **kitchen:** use ``saltimages`` Docker Hub where available [skip ci] (\ `2f143f9 `_\ ) 113 | * **kitchen+travis:** add new platforms [skip ci] (\ `c16bb41 `_\ ) 114 | 115 | Styles 116 | ^^^^^^ 117 | 118 | 119 | * **libtofs.jinja:** use Black-inspired Jinja formatting [skip ci] (\ `af35635 `_\ ) 120 | 121 | `1.0.0 `_ (2020-05-26) 122 | ---------------------------------------------------------------------------------------------------------- 123 | 124 | Bug Fixes 125 | ^^^^^^^^^ 126 | 127 | 128 | * **script:** fix some travis tests (\ `63cfb1e `_\ ) 129 | 130 | Code Refactoring 131 | ^^^^^^^^^^^^^^^^ 132 | 133 | 134 | * **all:** align to template; fix bugs and ci (\ `fc1ff28 `_\ ) 135 | 136 | Continuous Integration 137 | ^^^^^^^^^^^^^^^^^^^^^^ 138 | 139 | 140 | * **gemfile.lock:** add to repo with updated ``Gemfile`` [skip ci] (\ `e76b40c `_\ ) 141 | * **kitchen:** avoid using bootstrap for ``master`` instances [skip ci] (\ `498b79f `_\ ) 142 | * **kitchen+travis:** adjust matrix to add ``3000.3`` [skip ci] (\ `f98319a `_\ ) 143 | * **kitchen+travis:** remove ``master-py2-arch-base-latest`` [skip ci] (\ `2220bd9 `_\ ) 144 | * **travis:** add notifications => zulip [skip ci] (\ `81d3677 `_\ ) 145 | * **workflows/commitlint:** add to repo [skip ci] (\ `3e8848d `_\ ) 146 | 147 | Documentation 148 | ^^^^^^^^^^^^^ 149 | 150 | 151 | * **readme:** add depth one (\ `5680c6b `_\ ) 152 | 153 | Features 154 | ^^^^^^^^ 155 | 156 | 157 | * **semantic-release:** standardise for this formula (\ `f56ba6a `_\ ) 158 | 159 | BREAKING CHANGES 160 | ^^^^^^^^^^^^^^^^ 161 | 162 | 163 | * **all:** The data dictionary is simplified and redesigned. 164 | This formula is aligned to template-formula with multiple fixes. 165 | Retest your states and update pillar data accordingly. 166 | For developer convenience, connectors and gui states are introduced. 167 | See pillar.example, defaults.yaml, and docs/README. 168 | -------------------------------------------------------------------------------- /docs/README.rst: -------------------------------------------------------------------------------- 1 | mongodb-formula 2 | =============== 3 | 4 | Formula for MongoDB on GNU/Linux and MacOS. 5 | 6 | |img_travis| |img_sr| 7 | 8 | .. |img_travis| image:: https://travis-ci.com/saltstack-formulas/mongodb-formula.svg?branch=master 9 | :alt: Travis CI Build Status 10 | :scale: 100% 11 | :target: https://travis-ci.com/saltstack-formulas/mongodb-formula 12 | .. |img_sr| image:: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg 13 | :alt: Semantic Release 14 | :scale: 100% 15 | :target: https://github.com/semantic-release/semantic-release 16 | 17 | 18 | .. contents:: **Table of Contents** 19 | :depth: 1 20 | 21 | General notes 22 | ------------- 23 | 24 | See the full `SaltStack Formulas installation and usage instructions 25 | `_. If you are interested in writing or contributing to formulas, please pay attention to the `Writing Formula Section 26 | `_. If you want to use this formula, please pay attention to the ``FORMULA`` file and/or ``git tag``, which contains the currently released version. This formula is versioned according to `Semantic Versioning `_. See `Formula Versioning Section `_ for more details. 27 | 28 | Special notes 29 | ------------- 30 | 31 | By default only MongoDB server component (`mongod`) is installed. This behaviour is configurable via pillars. 32 | 33 | .. code-block:: yaml 34 | 35 | mongodb: 36 | wanted: 37 | # choose what you want or everything 38 | database: 39 | - mongod 40 | - mongos 41 | - dbtools 42 | - shell 43 | gui: 44 | - robo3t 45 | - compass 46 | connectors: 47 | - bi 48 | - kafka 49 | 50 | Configuration can be supplied in yaml: 51 | 52 | .. code-block:: yaml 53 | 54 | mongodb: 55 | pkg: 56 | database: 57 | version: 4.2.6.1 58 | archive: 59 | skip_verify: true 60 | config: 61 | # http://docs.mongodb.org/manual/reference/configuration-options 62 | storage: 63 | dbPath: /var/lib/mongodb/mongod 64 | replication: 65 | replSetName: "rs1" 66 | sharding: 67 | clusterRole: shardsvr 68 | net: 69 | bindIp: '0.0.0.0,::' 70 | port: 27018 71 | firewall: 72 | ports: 73 | - tcp/27017 74 | - tcp/27018 75 | - tcp/27019 76 | 77 | Contributing to this repo 78 | ------------------------- 79 | 80 | **Commit message formatting is significant!!** 81 | 82 | Please see `How to contribute `_ for more details. 83 | 84 | Available metastates 85 | -------------------- 86 | 87 | .. contents:: 88 | :local: 89 | 90 | ``mongodb`` 91 | ^^^^^^^^^^^ 92 | 93 | *Meta-state (This is a state that includes other states)*. 94 | 95 | This installs the MongoDB solution. 96 | 97 | 98 | ``mongodb.install`` 99 | ^^^^^^^^^^^^^^^^^^^ 100 | 101 | This state will install mongodb components on MacOS and GNU/Linux from archive. 102 | 103 | ``mongodb.config`` 104 | ^^^^^^^^^^^^^^^^^^ 105 | 106 | This state will apply mongodb service configuration (files). 107 | 108 | ``mongodb.service`` 109 | ^^^^^^^^^^^^^^^^^^^ 110 | 111 | This state will start mongodb component services. 112 | 113 | ``mongodb.service.clean`` 114 | ^^^^^^^^^^^^^^^^^^^^^^^^^ 115 | 116 | This state will stop mongodb component services. 117 | 118 | ``mongodb.config.clean`` 119 | ^^^^^^^^^^^^^^^^^^^^^^^^ 120 | 121 | This state will remove mongodb service configuration (files). 122 | 123 | ``mongodb.clean`` 124 | ^^^^^^^^^^^^^^^^^ 125 | 126 | This state will remove mongodb components on MacOS and GNU/Linux. 127 | 128 | 129 | Testing 130 | ------- 131 | 132 | Linux testing is done with ``kitchen-salt``. 133 | 134 | Requirements 135 | ^^^^^^^^^^^^ 136 | 137 | * Ruby 138 | * Docker 139 | 140 | .. code-block:: bash 141 | 142 | $ gem install bundler 143 | $ bundle install 144 | $ bin/kitchen test [platform] 145 | 146 | Where ``[platform]`` is the platform name defined in ``kitchen.yml``, 147 | e.g. ``debian-9-2019-2-py3``. 148 | 149 | ``bin/kitchen converge`` 150 | ^^^^^^^^^^^^^^^^^^^^^^^^ 151 | 152 | Creates the docker instance and runs the ``mongodb`` main state, ready for testing. 153 | 154 | ``bin/kitchen verify`` 155 | ^^^^^^^^^^^^^^^^^^^^^^ 156 | 157 | Runs the ``inspec`` tests on the actual instance. 158 | 159 | ``bin/kitchen destroy`` 160 | ^^^^^^^^^^^^^^^^^^^^^^^ 161 | 162 | Removes the docker instance. 163 | 164 | ``bin/kitchen test`` 165 | ^^^^^^^^^^^^^^^^^^^^ 166 | 167 | Runs all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``verify`` + ``destroy``. 168 | 169 | ``bin/kitchen login`` 170 | ^^^^^^^^^^^^^^^^^^^^^ 171 | 172 | Gives you SSH access to the instance for manual testing. 173 | -------------------------------------------------------------------------------- /docs/TOFS_pattern.rst: -------------------------------------------------------------------------------- 1 | .. _tofs_pattern: 2 | 3 | TOFS: A pattern for using SaltStack 4 | =================================== 5 | 6 | .. list-table:: 7 | :name: tofs-authors 8 | :header-rows: 1 9 | :stub-columns: 1 10 | :widths: 2,2,3,2 11 | 12 | * - 13 | - Person 14 | - Contact 15 | - Date 16 | * - Authored by 17 | - Roberto Moreda 18 | - moreda@allenta.com 19 | - 29/12/2014 20 | * - Modified by 21 | - Daniel Dehennin 22 | - daniel.dehennin@baby-gnu.org 23 | - 07/02/2019 24 | * - Modified by 25 | - Imran Iqbal 26 | - https://github.com/myii 27 | - 23/02/2019 28 | 29 | All that follows is a proposal based on my experience with `SaltStack `_. The good thing of a piece of software like this is that you can "bend it" to suit your needs in many possible ways, and this is one of them. All the recommendations and thoughts are given "as it is" with no warranty of any type. 30 | 31 | .. contents:: **Table of Contents** 32 | 33 | Usage of values in pillar vs templates in ``file_roots`` 34 | -------------------------------------------------------- 35 | 36 | Among other functions, the *master* (or *salt-master*) serves files to the *minions* (or *salt-minions*). The `file_roots `_ is the list of directories used in sequence to find a file when a minion requires it: the first match is served to the minion. Those files could be `state files `_ or configuration templates, among others. 37 | 38 | Using SaltStack is a simple and effective way to implement configuration management, but even in a `non-multitenant `_ scenario, it is not a good idea to generally access some data (e.g. the database password in our `Zabbix `_ server configuration file or the private key of our `Nginx `_ TLS certificate). 39 | 40 | To avoid this situation we can use the `pillar mechanism `_, which is designed to provide controlled access to data from the minions based on some selection rules. As pillar data could be easily integrated in the `Jinja `_ templates, it is a good mechanism to store values to be used in the final rendering of state files and templates. 41 | 42 | There are a variety of approaches on the usage of pillar and templates as seen in the `saltstack-formulas `_' repositories. `Some `_ `developments `_ stress the initial purpose of pillar data into a storage for most of the possible variables for a determined system configuration. This, in my opinion, is shifting too much load from the original template files approach. Adding up some `non-trivial Jinja `_ code as essential part of composing the state file definitely makes SaltStack state files (hence formulas) more difficult to read. The extreme of this approach is that we could end up with a new render mechanism, implemented in Jinja, storing everything needed in pillar data to compose configurations. Additionally, we are establishing a strong dependency with the Jinja renderer. 43 | 44 | In opposition to the *put the code in file_roots and the data in pillars* approach, there is the *pillar as a store for a set of key-values* approach. A full-blown configuration file abstracted in pillar and jinja is complicated to develop, understand and maintain. I think a better and simpler approach is to keep a configuration file templated using just a basic (non-extensive but extensible) set of pillar values. 45 | 46 | On the reusability of SaltStack state files 47 | ------------------------------------------- 48 | 49 | There is a brilliant initiative of the SaltStack community called `salt-formulas `_. Their goal is to provide state files, pillar examples and configuration templates ready to be used for provisioning. I am a contributor for two small ones: `zabbix-formula `_ and `varnish-formula `_. 50 | 51 | The `design guidelines `_ for formulas are clear in many aspects and it is a recommended reading for anyone willing to write state files, even non-formulaic ones. 52 | 53 | In the next section, I am going to describe my proposal to extend further the reusability of formulas, suggesting some patterns of usage. 54 | 55 | The Template Override and Files Switch (TOFS) pattern 56 | ----------------------------------------------------- 57 | 58 | I understand a formula as a **complete, independent set of SaltStack state and configuration template files sufficient to configure a system**. A system could be something as simple as an NTP server or some other much more complex service that requires many state and configuration template files. 59 | 60 | The customization of a formula should be done mainly by providing pillar data used later to render either the state or the configuration template files. 61 | 62 | Example: NTP before applying TOFS 63 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 64 | 65 | Let's work with the NTP example. A basic formula that follows the `design guidelines `_ has the following files and directories tree: 66 | 67 | .. code-block:: console 68 | 69 | /srv/saltstack/salt-formulas/ntp-saltstack-formula/ 70 | ntp/ 71 | map.jinja 72 | init.sls 73 | conf.sls 74 | files/ 75 | default/ 76 | etc/ 77 | ntp.conf.jinja 78 | 79 | In order to use it, let's assume a `masterless configuration `_ and this relevant section of ``/etc/salt/minion``: 80 | 81 | .. code-block:: yaml 82 | 83 | pillar_roots: 84 | base: 85 | - /srv/saltstack/pillar 86 | file_client: local 87 | file_roots: 88 | base: 89 | - /srv/saltstack/salt 90 | - /srv/saltstack/salt-formulas/ntp-saltstack-formula 91 | 92 | .. code-block:: jinja 93 | 94 | {#- /srv/saltstack/salt-formulas/ntp-saltstack-formula/ntp/map.jinja #} 95 | {%- set ntp = salt['grains.filter_by']({ 96 | 'default': { 97 | 'pkg': 'ntp', 98 | 'service': 'ntp', 99 | 'config': '/etc/ntp.conf', 100 | }, 101 | }, merge=salt['pillar.get']('ntp:lookup')) %} 102 | 103 | In ``init.sls`` we have the minimal states required to have NTP configured. In many cases ``init.sls`` is almost equivalent to an ``apt-get install`` or a ``yum install`` of the package. 104 | 105 | .. code-block:: sls 106 | 107 | ## /srv/saltstack/salt-formulas/ntp-saltstack-formula/ntp/init.sls 108 | {%- from 'ntp/map.jinja' import ntp with context %} 109 | 110 | Install NTP: 111 | pkg.installed: 112 | - name: {{ ntp.pkg }} 113 | 114 | Enable and start NTP: 115 | service.running: 116 | - name: {{ ntp.service }} 117 | - enabled: True 118 | - require: 119 | - pkg: Install NTP package 120 | 121 | In ``conf.sls`` we have the configuration states. In most cases, that is just managing configuration file templates and making them to be watched by the service. 122 | 123 | .. code-block:: sls 124 | 125 | ## /srv/saltstack/salt-formulas/ntp-saltstack-formula/ntp/conf.sls 126 | include: 127 | - ntp 128 | 129 | {%- from 'ntp/map.jinja' import ntp with context %} 130 | 131 | Configure NTP: 132 | file.managed: 133 | - name: {{ ntp.config }} 134 | - template: jinja 135 | - source: salt://ntp/files/default/etc/ntp.conf.jinja 136 | - watch_in: 137 | - service: Enable and start NTP service 138 | - require: 139 | - pkg: Install NTP package 140 | 141 | Under ``files/default``, there is a structure that mimics the one in the minion in order to avoid clashes and confusion on where to put the needed templates. There you can find a mostly standard template for the configuration file. 142 | 143 | .. code-block:: jinja 144 | 145 | {#- /srv/saltstack/salt-formulas/ntp-saltstack-formula/ntp/files/default/etc/ntp.conf.jinja #} 146 | {#- Managed by saltstack #} 147 | {#- Edit pillars or override this template in saltstack if you need customization #} 148 | {%- set settings = salt['pillar.get']('ntp', {}) %} 149 | {%- set default_servers = ['0.ubuntu.pool.ntp.org', 150 | '1.ubuntu.pool.ntp.org', 151 | '2.ubuntu.pool.ntp.org', 152 | '3.ubuntu.pool.ntp.org'] %} 153 | 154 | driftfile /var/lib/ntp/ntp.drift 155 | statistics loopstats peerstats clockstats 156 | filegen loopstats file loopstats type day enable 157 | filegen peerstats file peerstats type day enable 158 | filegen clockstats file clockstats type day enable 159 | 160 | {%- for server in settings.get('servers', default_servers) %} 161 | server {{ server }} 162 | {%- endfor %} 163 | 164 | restrict -4 default kod notrap nomodify nopeer noquery 165 | restrict -6 default kod notrap nomodify nopeer noquery 166 | 167 | restrict 127.0.0.1 168 | restrict ::1 169 | 170 | With all this, it is easy to install and configure a simple NTP server by just running ``salt-call state.sls ntp.conf``: the package will be installed, the service will be running and the configuration should be correct for most of cases, even without pillar data. 171 | 172 | Alternatively, you can define a highstate in ``/srv/saltstack/salt/top.sls`` and run ``salt-call state.highstate``. 173 | 174 | .. code-block:: sls 175 | 176 | ## /srv/saltstack/salt/top.sls 177 | base: 178 | '*': 179 | - ntp.conf 180 | 181 | **Customizing the formula just with pillar data**, we have the option to define the NTP servers. 182 | 183 | .. code-block:: sls 184 | 185 | ## /srv/saltstack/pillar/top.sls 186 | base: 187 | '*': 188 | - ntp 189 | 190 | .. code-block:: sls 191 | 192 | ## /srv/saltstack/pillar/ntp.sls 193 | ntp: 194 | servers: 195 | - 0.ch.pool.ntp.org 196 | - 1.ch.pool.ntp.org 197 | - 2.ch.pool.ntp.org 198 | - 3.ch.pool.ntp.org 199 | 200 | Template Override 201 | ^^^^^^^^^^^^^^^^^ 202 | 203 | If the customization based on pillar data is not enough, we can override the template by creating a new one in ``/srv/saltstack/salt/ntp/files/default/etc/ntp.conf.jinja`` 204 | 205 | .. code-block:: jinja 206 | 207 | {#- /srv/saltstack/salt/ntp/files/default/etc/ntp.conf.jinja #} 208 | {#- Managed by saltstack #} 209 | {#- Edit pillars or override this template in saltstack if you need customization #} 210 | 211 | {#- Some bizarre configurations here #} 212 | {#- ... #} 213 | 214 | {%- for server in settings.get('servers', default_servers) %} 215 | server {{ server }} 216 | {%- endfor %} 217 | 218 | This way we are locally **overriding the template files** offered by the formula in order to make a more complex adaptation. Of course, this could be applied as well to any of the files, including the state files. 219 | 220 | Files Switch 221 | ^^^^^^^^^^^^ 222 | 223 | To bring some order into the set of template files included in a formula, as we commented, we suggest having a similar structure to a normal final file system under ``files/default``. 224 | 225 | We can make different templates coexist for different minions, classified by any `grain `_ value, by simply creating new directories under ``files``. This mechanism is based on **using values of some grains as a switch for the directories under** ``files/``. 226 | 227 | If we decide that we want ``os_family`` as switch, then we could provide the formula template variants for both the ``RedHat`` and ``Debian`` families. 228 | 229 | .. code-block:: console 230 | 231 | /srv/saltstack/salt-formulas/ntp-saltstack-formula/ntp/files/ 232 | default/ 233 | etc/ 234 | ntp.conf.jinja 235 | RedHat/ 236 | etc/ 237 | ntp.conf.jinja 238 | Debian/ 239 | etc/ 240 | ntp.conf.jinja 241 | 242 | To make this work we need a ``conf.sls`` state file that takes a list of possible files as the configuration template. 243 | 244 | .. code-block:: sls 245 | 246 | ## /srv/saltstack/salt-formulas/ntp-saltstack-formula/ntp/conf.sls 247 | include: 248 | - ntp 249 | 250 | {%- from 'ntp/map.jinja' import ntp with context %} 251 | 252 | Configure NTP: 253 | file.managed: 254 | - name: {{ ntp.config }} 255 | - template: jinja 256 | - source: 257 | - salt://ntp/files/{{ grains.get('os_family', 'default') }}/etc/ntp.conf.jinja 258 | - salt://ntp/files/default/etc/ntp.conf.jinja 259 | - watch_in: 260 | - service: Enable and start NTP service 261 | - require: 262 | - pkg: Install NTP package 263 | 264 | If we want to cover the possibility of a special template for a minion identified by ``node01`` then we could have a specific template in ``/srv/saltstack/salt/ntp/files/node01/etc/ntp.conf.jinja``. 265 | 266 | .. code-block:: jinja 267 | 268 | {#- /srv/saltstack/salt/ntp/files/node01/etc/ntp.conf.jinja #} 269 | {#- Managed by saltstack #} 270 | {#- Edit pillars or override this template in saltstack if you need customization #} 271 | 272 | {#- Some crazy configurations here for node01 #} 273 | {#- ... #} 274 | 275 | To make this work we could write a specially crafted ``conf.sls``. 276 | 277 | .. code-block:: sls 278 | 279 | ## /srv/saltstack/salt-formulas/ntp-saltstack-formula/ntp/conf.sls 280 | include: 281 | - ntp 282 | 283 | {%- from 'ntp/map.jinja' import ntp with context %} 284 | 285 | Configure NTP: 286 | file.managed: 287 | - name: {{ ntp.config }} 288 | - template: jinja 289 | - source: 290 | - salt://ntp/files/{{ grains.get('id') }}/etc/ntp.conf.jinja 291 | - salt://ntp/files/{{ grains.get('os_family') }}/etc/ntp.conf.jinja 292 | - salt://ntp/files/default/etc/ntp.conf.jinja 293 | - watch_in: 294 | - service: Enable and start NTP service 295 | - require: 296 | - pkg: Install NTP package 297 | 298 | Using the ``files_switch`` macro 299 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 300 | 301 | We can simplify the ``conf.sls`` with the new ``files_switch`` macro to use in the ``source`` parameter for the ``file.managed`` state. 302 | 303 | .. code-block:: sls 304 | 305 | ## /srv/saltstack/salt-formulas/ntp-saltstack-formula/ntp/conf.sls 306 | include: 307 | - ntp 308 | 309 | {%- set tplroot = tpldir.split('/')[0] %} 310 | {%- from 'ntp/map.jinja' import ntp with context %} 311 | {%- from 'ntp/libtofs.jinja' import files_switch %} 312 | 313 | Configure NTP: 314 | file.managed: 315 | - name: {{ ntp.config }} 316 | - template: jinja 317 | - source: {{ files_switch(['/etc/ntp.conf.jinja'], 318 | lookup='Configure NTP' 319 | ) 320 | }} 321 | - watch_in: 322 | - service: Enable and start NTP service 323 | - require: 324 | - pkg: Install NTP package 325 | 326 | 327 | * This uses ``config.get``, searching for ``ntp:tofs:source_files:Configure NTP`` to determine the list of template files to use. 328 | * If this returns a result, the default of ``['/etc/ntp.conf.jinja']`` will be appended to it. 329 | * If this does not yield any results, the default of ``['/etc/ntp.conf.jinja']`` will be used. 330 | 331 | In ``libtofs.jinja``, we define this new macro ``files_switch``. 332 | 333 | .. literalinclude:: ../template/libtofs.jinja 334 | :caption: /srv/saltstack/salt-formulas/ntp-saltstack-formula/ntp/libtofs.jinja 335 | :language: jinja 336 | 337 | How to customise the ``source`` further 338 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 339 | 340 | The examples below are based on an ``Ubuntu`` minion called ``theminion`` being configured via. pillar. 341 | 342 | Using the default settings of the ``files_switch`` macro above, 343 | the ``source`` will be: 344 | 345 | .. code-block:: sls 346 | 347 | - source: 348 | - salt://ntp/files/theminion/etc/ntp.conf.jinja 349 | - salt://ntp/files/Debian/etc/ntp.conf.jinja 350 | - salt://ntp/files/default/etc/ntp.conf.jinja 351 | 352 | Customise ``files`` 353 | ~~~~~~~~~~~~~~~~~~~ 354 | 355 | The ``files`` portion can be customised: 356 | 357 | .. code-block:: sls 358 | 359 | ntp: 360 | tofs: 361 | dirs: 362 | files: files_alt 363 | 364 | Resulting in: 365 | 366 | .. code-block:: sls 367 | 368 | - source: 369 | - salt://ntp/files_alt/theminion/etc/ntp.conf.jinja 370 | - salt://ntp/files_alt/Debian/etc/ntp.conf.jinja 371 | - salt://ntp/files_alt/default/etc/ntp.conf.jinja 372 | 373 | Customise the use of grains 374 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 375 | 376 | Grains can be customised and even arbitrary paths can be supplied: 377 | 378 | .. code-block:: sls 379 | 380 | ntp: 381 | tofs: 382 | files_switch: 383 | - any/path/can/be/used/here 384 | - id 385 | - os 386 | - os_family 387 | 388 | Resulting in: 389 | 390 | .. code-block:: sls 391 | 392 | - source: 393 | - salt://ntp/files/any/path/can/be/used/here/etc/ntp.conf.jinja 394 | - salt://ntp/files/theminion/etc/ntp.conf.jinja 395 | - salt://ntp/files/Ubuntu/etc/ntp.conf.jinja 396 | - salt://ntp/files/Debian/etc/ntp.conf.jinja 397 | - salt://ntp/files/default/etc/ntp.conf.jinja 398 | 399 | Customise the ``default`` path 400 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 401 | 402 | The ``default`` portion of the path can be customised: 403 | 404 | .. code-block:: sls 405 | 406 | ntp: 407 | tofs: 408 | dirs: 409 | default: default_alt 410 | 411 | Resulting in: 412 | 413 | .. code-block:: sls 414 | 415 | - source: 416 | ... 417 | - salt://ntp/files/default_alt/etc/ntp.conf.jinja 418 | 419 | Customise the list of ``source_files`` 420 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 421 | 422 | The list of ``source_files`` can be given: 423 | 424 | .. code-block:: sls 425 | 426 | ntp: 427 | tofs: 428 | source_files: 429 | Configure NTP: 430 | - '/etc/ntp.conf_alt.jinja' 431 | 432 | Resulting in: 433 | 434 | .. code-block:: sls 435 | 436 | - source: 437 | - salt://ntp/files/theminion/etc/ntp.conf_alt.jinja 438 | - salt://ntp/files/theminion/etc/ntp.conf.jinja 439 | - salt://ntp/files/Debian/etc/ntp.conf_alt.jinja 440 | - salt://ntp/files/Debian/etc/ntp.conf.jinja 441 | - salt://ntp/files/default/etc/ntp.conf_alt.jinja 442 | - salt://ntp/files/default/etc/ntp.conf.jinja 443 | 444 | Note: This does *not* override the default value. 445 | Rather, the value from the pillar/config is prepended to the default. 446 | 447 | Using sub-directories for ``components`` 448 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 449 | 450 | If your formula is composed of several components, you may prefer to provides files under sub-directories, like in the `systemd-formula `_. 451 | 452 | .. code-block:: console 453 | 454 | /srv/saltstack/systemd-formula/ 455 | systemd/ 456 | init.sls 457 | libtofs.jinja 458 | map.jinja 459 | networkd/ 460 | init.sls 461 | files/ 462 | default/ 463 | network/ 464 | 99-default.link 465 | resolved/ 466 | init.sls 467 | files/ 468 | default/ 469 | resolved.conf 470 | timesyncd/ 471 | init.sls 472 | files/ 473 | Arch/ 474 | resolved.conf 475 | Debian/ 476 | resolved.conf 477 | default/ 478 | resolved.conf 479 | Ubuntu/ 480 | resolved.conf 481 | 482 | For example, the following ``formula.component.config`` SLS: 483 | 484 | .. code-block:: sls 485 | 486 | {%- from "formula/libtofs.jinja" import files_switch with context %} 487 | 488 | formula configuration file: 489 | file.managed: 490 | - name: /etc/formula.conf 491 | - user: root 492 | - group: root 493 | - mode: 644 494 | - template: jinja 495 | - source: {{ files_switch(['formula.conf'], 496 | lookup='formula', 497 | use_subpath=True 498 | ) 499 | }} 500 | 501 | will be rendered on a ``Debian`` minion named ``salt-formula.ci.local`` as: 502 | 503 | .. code-block:: sls 504 | 505 | formula configuration file: 506 | file.managed: 507 | - name: /etc/formula.conf 508 | - user: root 509 | - group: root 510 | - mode: 644 511 | - template: jinja 512 | - source: 513 | - salt://formula/component/files/salt-formula.ci.local/formula.conf 514 | - salt://formula/component/files/Debian/formula.conf 515 | - salt://formula/component/files/default/formula.conf 516 | - salt://formula/files/salt-formula.ci.local/formula.conf 517 | - salt://formula/files/Debian/formula.conf 518 | - salt://formula/files/default/formula.conf 519 | -------------------------------------------------------------------------------- /docs/_static/css/custom.css: -------------------------------------------------------------------------------- 1 | /* 2 | Override styles for in-use Sphinx theme 3 | */ 4 | 5 | /* The next two `.wy`-based rules are specifically needed for the dealing with */ 6 | /* the `sphinx_rtd_theme` bug where long lines do not wrap in tables */ 7 | 8 | /* override table width restrictions */ 9 | .wy-table-responsive table th 10 | , .wy-table-responsive table td 11 | { 12 | /* !important prevents the common CSS stylesheets from 13 | overriding this as on RTD they are loaded after this stylesheet */ 14 | white-space: normal !important; 15 | } 16 | 17 | .wy-table-responsive 18 | { 19 | overflow: visible !important; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """Configuration file for the Sphinx documentation builder. 3 | 4 | This file does only contain a selection of the most common options. For a 5 | full list see the documentation: 6 | 7 | * http://www.sphinx-doc.org/en/stable/config 8 | 9 | """ 10 | 11 | from __future__ import division, print_function, unicode_literals 12 | 13 | # from datetime import datetime 14 | 15 | from recommonmark.parser import CommonMarkParser 16 | 17 | # You should have received a copy of the GNU Affero General Public License 18 | # along with this program. If not, see . 19 | __author__ = 'Imran Iqbal' # noqa: E221 20 | __copyright__ = 'Copyright (C) 2019, MYII' # noqa: E221 21 | __license__ = 'Apache-2.0' # noqa: E221 22 | __version__ = 'latest' # noqa: E221 23 | __maintainer__ = 'Imran Iqbal' # noqa: E221 24 | 25 | 26 | # -- Project information ----------------------------------------------------- 27 | 28 | project = 'template-formula' 29 | copyright = __copyright__.replace('Copyright (C) ', '') # noqa: A001 30 | author = __author__ 31 | version = __version__ 32 | release = __version__ 33 | 34 | 35 | # -- General configuration --------------------------------------------------- 36 | 37 | # If your documentation needs a minimal Sphinx version, state it here. 38 | # 39 | # needs_sphinx = '1.0' 40 | 41 | # Add any Sphinx extension module names here, as strings. They can be 42 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 43 | # ones. 44 | extensions = [] 45 | 46 | # Add any paths that contain templates here, relative to this directory. 47 | templates_path = ['templates', '_templates', '.templates'] 48 | 49 | # The suffix(es) of source filenames. 50 | # You can specify multiple suffix as a list of string: 51 | # 52 | source_suffix = ['.rst', '.md'] 53 | 54 | # The master toctree document. 55 | master_doc = 'index' 56 | 57 | # The language for content autogenerated by Sphinx. Refer to documentation 58 | # for a list of supported languages. 59 | # 60 | # This is also used if you do content translation via gettext catalogs. 61 | # Usually you set "language" from the command line for these cases. 62 | language = None 63 | 64 | # List of patterns, relative to source directory, that match files and 65 | # directories to ignore when looking for source files. 66 | # This pattern also affects html_static_path and html_extra_path . 67 | exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] 68 | 69 | # The name of the Pygments (syntax highlighting) style to use. 70 | pygments_style = 'sphinx' 71 | 72 | 73 | # -- Options for the reStructuredText parser --------------------------------- 74 | 75 | file_insertion_enabled = False 76 | 77 | 78 | # -- Options for HTML output ------------------------------------------------- 79 | 80 | # The theme to use for HTML and HTML Help pages. See the documentation for 81 | # a list of builtin themes. 82 | # 83 | html_theme = 'sphinx_rtd_theme' 84 | 85 | # Theme options are theme-specific and customize the look and feel of a theme 86 | # further. For a list of options available for each theme, see the 87 | # documentation. 88 | # 89 | # html_theme_options = {} 90 | 91 | # Add any paths that contain custom static files (such as style sheets) here, 92 | # relative to this directory. They are copied after the builtin static files, 93 | # so a file named "default.css" will overwrite the builtin "default.css". 94 | html_static_path = ['_static'] 95 | 96 | # Custom sidebar templates, must be a dictionary that maps document names 97 | # to template names. 98 | # 99 | # The default sidebars (for documents that don't match any pattern) are 100 | # defined by theme itself. Builtin themes are using these templates by 101 | # default: ``['localtoc.html', 'relations.html', 'sourcelink.html', 102 | # 'searchbox.html']``. 103 | # 104 | # html_sidebars = {} 105 | 106 | 107 | # -- Options for HTMLHelp output --------------------------------------------- 108 | 109 | # Output file base name for HTML help builder. 110 | htmlhelp_basename = 'template-formula' 111 | 112 | 113 | # -- Options for Markdown output --------------------------------------------- 114 | 115 | source_parsers = { 116 | '.md': CommonMarkParser, 117 | } 118 | 119 | 120 | # -- Options for LaTeX output ------------------------------------------------ 121 | 122 | latex_elements = { 123 | # The paper size ('letterpaper' or 'a4paper'). 124 | # 125 | # 'papersize': 'letterpaper', 126 | 127 | # The font size ('10pt', '11pt' or '12pt'). 128 | # 129 | # 'pointsize': '10pt', 130 | 131 | # Additional stuff for the LaTeX preamble. 132 | # 133 | # 'preamble': '', 134 | 135 | # Latex figure (float) alignment 136 | # 137 | # 'figure_align': 'htbp', 138 | } 139 | 140 | # Grouping the document tree into LaTeX files. List of tuples 141 | # (source start file, target name, title, 142 | # author, documentclass [howto, manual, or own class]). 143 | latex_documents = [ 144 | ( 145 | 'index', 146 | 'template-formula.tex', 147 | u'template-formula Documentation', 148 | u'', 149 | 'manual', 150 | ), 151 | ] 152 | 153 | 154 | # -- Functions: `setup`, docstring preprocessing, etc. ----------------------- 155 | 156 | def setup(app): 157 | """Prepare the Sphinx application object. 158 | 159 | Used for providing a custom CSS file for override styles. 160 | 161 | Parameters 162 | ---------- 163 | app : object 164 | The Sphinx application object. 165 | 166 | Returns 167 | ------- 168 | app : object 169 | The Sphinx application object. 170 | 171 | """ 172 | app.add_stylesheet('css/custom.css') 173 | return app 174 | -------------------------------------------------------------------------------- /kitchen.yml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | # For help on this file's format, see https://kitchen.ci/ 5 | driver: 6 | name: docker 7 | use_sudo: false 8 | privileged: true 9 | run_command: /usr/lib/systemd/systemd 10 | 11 | provisioner: 12 | name: salt_solo 13 | log_level: debug 14 | salt_install: none 15 | require_chef: false 16 | formula: mongodb 17 | salt_copy_filter: 18 | - .kitchen 19 | - .git 20 | 21 | platforms: 22 | ## SALT `tiamat` 23 | - name: debian-11-tiamat-py3 24 | driver: 25 | image: saltimages/salt-tiamat-py3:debian-11 26 | run_command: /lib/systemd/systemd 27 | - name: debian-10-tiamat-py3 28 | driver: 29 | image: saltimages/salt-tiamat-py3:debian-10 30 | run_command: /lib/systemd/systemd 31 | - name: debian-9-tiamat-py3 32 | driver: 33 | image: saltimages/salt-tiamat-py3:debian-9 34 | run_command: /lib/systemd/systemd 35 | - name: ubuntu-2204-tiamat-py3 36 | driver: 37 | image: saltimages/salt-tiamat-py3:ubuntu-22.04 38 | run_command: /lib/systemd/systemd 39 | - name: ubuntu-2004-tiamat-py3 40 | driver: 41 | image: saltimages/salt-tiamat-py3:ubuntu-20.04 42 | run_command: /lib/systemd/systemd 43 | - name: ubuntu-1804-tiamat-py3 44 | driver: 45 | image: saltimages/salt-tiamat-py3:ubuntu-18.04 46 | run_command: /lib/systemd/systemd 47 | - name: centos-stream8-tiamat-py3 48 | driver: 49 | image: saltimages/salt-tiamat-py3:centos-stream8 50 | - name: centos-7-tiamat-py3 51 | driver: 52 | image: saltimages/salt-tiamat-py3:centos-7 53 | - name: amazonlinux-2-tiamat-py3 54 | driver: 55 | image: saltimages/salt-tiamat-py3:amazonlinux-2 56 | - name: oraclelinux-8-tiamat-py3 57 | driver: 58 | image: saltimages/salt-tiamat-py3:oraclelinux-8 59 | - name: oraclelinux-7-tiamat-py3 60 | driver: 61 | image: saltimages/salt-tiamat-py3:oraclelinux-7 62 | - name: almalinux-8-tiamat-py3 63 | driver: 64 | image: saltimages/salt-tiamat-py3:almalinux-8 65 | - name: rockylinux-8-tiamat-py3 66 | driver: 67 | image: saltimages/salt-tiamat-py3:rockylinux-8 68 | 69 | ## SALT `master` 70 | - name: debian-11-master-py3 71 | driver: 72 | image: saltimages/salt-master-py3:debian-11 73 | run_command: /lib/systemd/systemd 74 | - name: debian-10-master-py3 75 | driver: 76 | image: saltimages/salt-master-py3:debian-10 77 | run_command: /lib/systemd/systemd 78 | - name: debian-9-master-py3 79 | driver: 80 | image: saltimages/salt-master-py3:debian-9 81 | run_command: /lib/systemd/systemd 82 | - name: ubuntu-2204-master-py3 83 | driver: 84 | image: saltimages/salt-master-py3:ubuntu-22.04 85 | run_command: /lib/systemd/systemd 86 | - name: ubuntu-2004-master-py3 87 | driver: 88 | image: saltimages/salt-master-py3:ubuntu-20.04 89 | run_command: /lib/systemd/systemd 90 | - name: ubuntu-1804-master-py3 91 | driver: 92 | image: saltimages/salt-master-py3:ubuntu-18.04 93 | run_command: /lib/systemd/systemd 94 | - name: centos-stream8-master-py3 95 | driver: 96 | image: saltimages/salt-master-py3:centos-stream8 97 | - name: centos-7-master-py3 98 | driver: 99 | image: saltimages/salt-master-py3:centos-7 100 | - name: fedora-36-master-py3 101 | driver: 102 | image: saltimages/salt-master-py3:fedora-36 103 | - name: fedora-35-master-py3 104 | driver: 105 | image: saltimages/salt-master-py3:fedora-35 106 | - name: opensuse-leap-153-master-py3 107 | driver: 108 | image: saltimages/salt-master-py3:opensuse-leap-15.3 109 | # Workaround to avoid intermittent failures on `opensuse-leap-15.3`: 110 | # => SCP did not finish successfully (255): (Net::SCP::Error) 111 | transport: 112 | max_ssh_sessions: 1 113 | - name: opensuse-tmbl-latest-master-py3 114 | driver: 115 | image: saltimages/salt-master-py3:opensuse-tumbleweed-latest 116 | # Workaround to avoid intermittent failures on `opensuse-tumbleweed`: 117 | # => SCP did not finish successfully (255): (Net::SCP::Error) 118 | transport: 119 | max_ssh_sessions: 1 120 | - name: amazonlinux-2-master-py3 121 | driver: 122 | image: saltimages/salt-master-py3:amazonlinux-2 123 | - name: oraclelinux-8-master-py3 124 | driver: 125 | image: saltimages/salt-master-py3:oraclelinux-8 126 | - name: oraclelinux-7-master-py3 127 | driver: 128 | image: saltimages/salt-master-py3:oraclelinux-7 129 | - name: arch-base-latest-master-py3 130 | driver: 131 | image: saltimages/salt-master-py3:arch-base-latest 132 | - name: gentoo-stage3-latest-master-py3 133 | driver: 134 | image: saltimages/salt-master-py3:gentoo-stage3-latest 135 | run_command: /sbin/init 136 | - name: gentoo-stage3-systemd-master-py3 137 | driver: 138 | image: saltimages/salt-master-py3:gentoo-stage3-systemd 139 | - name: almalinux-8-master-py3 140 | driver: 141 | image: saltimages/salt-master-py3:almalinux-8 142 | - name: rockylinux-8-master-py3 143 | driver: 144 | image: saltimages/salt-master-py3:rockylinux-8 145 | 146 | ## SALT `3004.1` 147 | - name: debian-11-3004-1-py3 148 | driver: 149 | image: saltimages/salt-3004.1-py3:debian-11 150 | run_command: /lib/systemd/systemd 151 | - name: debian-10-3004-1-py3 152 | driver: 153 | image: saltimages/salt-3004.1-py3:debian-10 154 | run_command: /lib/systemd/systemd 155 | - name: debian-9-3004-1-py3 156 | driver: 157 | image: saltimages/salt-3004.1-py3:debian-9 158 | run_command: /lib/systemd/systemd 159 | - name: ubuntu-2204-3004-1-py3 160 | driver: 161 | image: saltimages/salt-3004.1-py3:ubuntu-22.04 162 | run_command: /lib/systemd/systemd 163 | - name: ubuntu-2004-3004-1-py3 164 | driver: 165 | image: saltimages/salt-3004.1-py3:ubuntu-20.04 166 | run_command: /lib/systemd/systemd 167 | - name: ubuntu-1804-3004-1-py3 168 | driver: 169 | image: saltimages/salt-3004.1-py3:ubuntu-18.04 170 | run_command: /lib/systemd/systemd 171 | - name: centos-stream8-3004-1-py3 172 | driver: 173 | image: saltimages/salt-3004.1-py3:centos-stream8 174 | - name: centos-7-3004-1-py3 175 | driver: 176 | image: saltimages/salt-3004.1-py3:centos-7 177 | - name: fedora-36-3004-1-py3 178 | driver: 179 | image: saltimages/salt-3004.1-py3:fedora-36 180 | - name: fedora-35-3004-1-py3 181 | driver: 182 | image: saltimages/salt-3004.1-py3:fedora-35 183 | - name: amazonlinux-2-3004-1-py3 184 | driver: 185 | image: saltimages/salt-3004.1-py3:amazonlinux-2 186 | - name: oraclelinux-8-3004-1-py3 187 | driver: 188 | image: saltimages/salt-3004.1-py3:oraclelinux-8 189 | - name: oraclelinux-7-3004-1-py3 190 | driver: 191 | image: saltimages/salt-3004.1-py3:oraclelinux-7 192 | - name: arch-base-latest-3004-1-py3 193 | driver: 194 | image: saltimages/salt-3004.1-py3:arch-base-latest 195 | - name: gentoo-stage3-latest-3004-1-py3 196 | driver: 197 | image: saltimages/salt-3004.1-py3:gentoo-stage3-latest 198 | run_command: /sbin/init 199 | - name: gentoo-stage3-systemd-3004-1-py3 200 | driver: 201 | image: saltimages/salt-3004.1-py3:gentoo-stage3-systemd 202 | - name: almalinux-8-3004-1-py3 203 | driver: 204 | image: saltimages/salt-3004.1-py3:almalinux-8 205 | - name: rockylinux-8-3004-1-py3 206 | driver: 207 | image: saltimages/salt-3004.1-py3:rockylinux-8 208 | 209 | ## SALT `3004.0` 210 | - name: opensuse-leap-153-3004-0-py3 211 | driver: 212 | image: saltimages/salt-3004.0-py3:opensuse-leap-15.3 213 | # Workaround to avoid intermittent failures on `opensuse-leap-15.3`: 214 | # => SCP did not finish successfully (255): (Net::SCP::Error) 215 | transport: 216 | max_ssh_sessions: 1 217 | - name: opensuse-tmbl-latest-3004-0-py3 218 | driver: 219 | image: saltimages/salt-3004.0-py3:opensuse-tumbleweed-latest 220 | # Workaround to avoid intermittent failures on `opensuse-tumbleweed`: 221 | # => SCP did not finish successfully (255): (Net::SCP::Error) 222 | transport: 223 | max_ssh_sessions: 1 224 | 225 | ## SALT `3003.4` 226 | - name: debian-10-3003-4-py3 227 | driver: 228 | image: saltimages/salt-3003.4-py3:debian-10 229 | run_command: /lib/systemd/systemd 230 | - name: debian-9-3003-4-py3 231 | driver: 232 | image: saltimages/salt-3003.4-py3:debian-9 233 | run_command: /lib/systemd/systemd 234 | - name: ubuntu-2004-3003-4-py3 235 | driver: 236 | image: saltimages/salt-3003.4-py3:ubuntu-20.04 237 | run_command: /lib/systemd/systemd 238 | - name: ubuntu-1804-3003-4-py3 239 | driver: 240 | image: saltimages/salt-3003.4-py3:ubuntu-18.04 241 | run_command: /lib/systemd/systemd 242 | - name: centos-stream8-3003-4-py3 243 | driver: 244 | image: saltimages/salt-3003.4-py3:centos-stream8 245 | - name: centos-7-3003-4-py3 246 | driver: 247 | image: saltimages/salt-3003.4-py3:centos-7 248 | - name: amazonlinux-2-3003-4-py3 249 | driver: 250 | image: saltimages/salt-3003.4-py3:amazonlinux-2 251 | - name: oraclelinux-8-3003-4-py3 252 | driver: 253 | image: saltimages/salt-3003.4-py3:oraclelinux-8 254 | - name: oraclelinux-7-3003-4-py3 255 | driver: 256 | image: saltimages/salt-3003.4-py3:oraclelinux-7 257 | - name: almalinux-8-3003-4-py3 258 | driver: 259 | image: saltimages/salt-3003.4-py3:almalinux-8 260 | 261 | verifier: 262 | # https://www.inspec.io/ 263 | name: inspec 264 | sudo: true 265 | reporter: 266 | # cli, documentation, html, progress, json, json-min, json-rspec, junit 267 | - cli 268 | 269 | suites: 270 | - name: default 271 | provisioner: 272 | state_top: 273 | base: 274 | '*': 275 | - mongodb._mapdata 276 | - mongodb 277 | pillars: 278 | top.sls: 279 | base: 280 | '*': 281 | - mongodb 282 | pillars_from_files: 283 | mongodb.sls: test/salt/pillar/default.sls 284 | verifier: 285 | inspec_tests: 286 | - path: test/integration/default 287 | -------------------------------------------------------------------------------- /mongodb/_mapdata/_mapdata.jinja: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:indentation rule:line-length 2 | # {{ grains.get("osfinger", grains.os) }} 3 | --- 4 | {#- use salt.slsutil.serialize to avoid encoding errors on some platforms #} 5 | {{ salt["slsutil.serialize"]( 6 | "yaml", 7 | map, 8 | default_flow_style=False, 9 | allow_unicode=True, 10 | ) 11 | | regex_replace("^\s+'$", "'", multiline=True) 12 | | trim 13 | }} 14 | -------------------------------------------------------------------------------- /mongodb/_mapdata/init.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | --- 4 | {#- Get the `tplroot` from `tpldir` #} 5 | {%- set tplroot = tpldir.split("/")[0] %} 6 | {%- from tplroot ~ "/map.jinja" import data with context %} 7 | 8 | {%- set _mapdata = { 9 | "values": data, 10 | } %} 11 | {%- do salt["log.debug"]("### MAP.JINJA DUMP ###\n" ~ _mapdata | yaml(False)) %} 12 | 13 | {%- set output_dir = "/temp" if grains.os_family == "Windows" else "/tmp" %} 14 | {%- set output_file = output_dir ~ "/salt_mapdata_dump.yaml" %} 15 | 16 | {{ tplroot }}-mapdata-dump: 17 | file.managed: 18 | - name: {{ output_file }} 19 | - source: salt://{{ tplroot }}/_mapdata/_mapdata.jinja 20 | - template: jinja 21 | - context: 22 | map: {{ _mapdata | yaml }} 23 | -------------------------------------------------------------------------------- /mongodb/clean.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import data as d with context %} 6 | {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} 7 | {%- set sls_config_clean = tplroot ~ '.config.clean' %} 8 | {%- set sls_service_clean = tplroot ~ '.service.clean' %} 9 | {%- set formula = d.formula %} 10 | 11 | include: 12 | - {{ sls_service_clean }} 13 | - {{ sls_config_clean }} 14 | 15 | {{ formula }}-clean-prerequisites: 16 | pip.removed: 17 | - names: {{ d.pkg.pips|json }} 18 | - require: 19 | - sls: {{ sls_service_clean }} 20 | - sls: {{ sls_config_clean }} 21 | - require_in: 22 | - file: {{ formula }}-clean-prerequisites 23 | file.absent: 24 | - names: 25 | - {{ d.dir.tmp }} 26 | - {{ d.dir.var }} 27 | - /tmp/mac_shortcut.sh 28 | 29 | {%- for comp in d.componentypes %} 30 | {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} 31 | {%- for name,v in d.pkg[comp].items() %} 32 | {%- if name in d.wanted[comp] %} 33 | {%- set software = d.pkg[comp][name] %} 34 | {%- set package = software['use_upstream'] %} 35 | {%- if package in d.packagetypes %} 36 | 37 | {#- PACKAGE CLEAN #} 38 | {%- if package in software and software[package] is mapping %} 39 | 40 | {{ formula }}-{{ comp }}-{{ name }}-clean: 41 | pkg.removed: 42 | - name: {{ software.get('name', name) }} 43 | - require: 44 | - file: {{ formula }}-clean-prerequisites 45 | file.absent: 46 | - name: {{ software['path'] }} 47 | - require: 48 | - file: {{ formula }}-clean-prerequisites 49 | {%- if package == 'repo' %} 50 | pkgrepo.absent: 51 | - name: {{ d.pkg['repo']['name'] }} 52 | {%- endif %} 53 | 54 | {%- endif %} 55 | {%- if grains.kernel|lower in ('linux', 'darwin') %} 56 | {%- if package in ('macapp', 'archive',) %} 57 | {#- SYMLINK CLEAN #} 58 | {%- if d.linux.altpriority|int <= 0 or grains.os_family in ('MacOS', 'Arch',) %} 59 | {%- if 'commands' in software and software['commands'] is iterable %} 60 | {%- for cmd in software['commands'] %} 61 | 62 | {{ formula }}-{{ comp }}-{{ name }}-{{ package }}-clean-symlink-{{ cmd }}: 63 | file.absent: 64 | - names: 65 | - {{ d.dir.symlink }}/{{ 's' if 'service' in software else '' }}bin/{{ cmd }} 66 | - {{ d.dir.macapp }}/{{ software['name'] }}.app 67 | - require: 68 | - file: {{ formula }}-clean-prerequisites 69 | 70 | {%- endfor %} {# command #} 71 | {%- endif %} {# commands #} 72 | {%- endif %} {# wanted #} 73 | {%- endif %} {# symlink #} 74 | {%- endif %} {# darwin/linux #} 75 | {%- endif %} {# software/package #} 76 | 77 | {#- SERVICE CLEAN #} 78 | 79 | {%- if 'service' in software and software['service'] %} 80 | {%- set service = software['service'] %} 81 | 82 | {{ formula }}-{{ comp }}-{{ package }}-{{ name }}-clean-service: 83 | file.absent: 84 | - names: 85 | - {{ d.dir.var }}/{{ name }} 86 | - {{ d.dir.service }}/{{ name }}.service 87 | - /Library/LaunchAgents/{{ name if 'name' not in service else service.name }}.plist 88 | - require: 89 | - file: {{ formula }}-clean-prerequisites 90 | cmd.run: 91 | - name: systemctl daemon-reload >/dev/null 2>&1 || true 92 | - onlyif: {{ grains.kernel|lower == 'linux' }} 93 | - onchanges: 94 | - file: {{ formula }}-{{ comp }}-{{ package }}-{{ name }}-clean-service 95 | 96 | {%- endif %} {# service #} 97 | {%- endif %} {# wanted #} 98 | {%- endfor %} {# component #} 99 | {%- endif %} {# wanted #} 100 | {%- endfor %} {# components #} 101 | -------------------------------------------------------------------------------- /mongodb/config/alternatives/clean.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import data as d with context %} 6 | {%- set formula = d.formula %} 7 | 8 | {%- if grains.kernel|lower == 'linux' and d.linux.altpriority|int > 0 and grains.os_family != 'Arch' %} 9 | {%- for comp in d.componentypes %} 10 | {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} 11 | {%- for name,v in d.pkg[comp].items() %} 12 | {%- if name in d.wanted[comp] %} 13 | {%- set software = d.pkg[comp][name] %} 14 | {%- set package = software['use_upstream'] %} 15 | {%- if package == 'archive' and package in software and software[package] is mapping %} 16 | 17 | {# LINUX ALTERNATIVES #} 18 | 19 | {%- set bindir = '/sbin' if 'service' in software else '/bin' %} 20 | {%- if 'commands' in software and software['commands'] is iterable %} 21 | {%- for cmd in software['commands'] %} 22 | 23 | {{ formula }}-{{ comp }}-{{ name }}-{{ cmd }}-alternatives-clean: 24 | alternatives.remove: 25 | - name: link-{{ formula }}-{{ name }}-{{ cmd }} 26 | - path: {{ software['path'] }}/bin/{{ cmd }} 27 | - onlyif: update-alternatives --get-selections |grep ^{{ formula }}-{{ name }}-{{ cmd }} 28 | 29 | {%- endfor %} {# alternative #} 30 | {%- endif %} {# commands #} 31 | {%- endif %} {# archive #} 32 | {%- endif %} {# wanted #} 33 | {%- endfor %} {# component #} 34 | {%- endif %} {# wanted #} 35 | {%- endfor %} {# components #} 36 | 37 | {%- else %} 38 | 39 | {{ formula }}-config-alternatives-clean-notification: 40 | test.show_notification: 41 | - text: | 42 | Note: The linux alternatives state is not applicable for {{ grains.os }} 43 | 44 | {%- endif %} {# linux #} -------------------------------------------------------------------------------- /mongodb/config/alternatives/init.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | include: 5 | - .install 6 | -------------------------------------------------------------------------------- /mongodb/config/alternatives/install.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import data as d with context %} 6 | {%- set sls_software_install = tplroot ~ '.install' %} 7 | {%- set formula = d.formula %} 8 | 9 | include: 10 | - {{ sls_software_install }} 11 | 12 | {%- if grains.kernel|lower == 'linux' and d.linux.altpriority|int > 0 and grains.os_family != 'Arch' %} 13 | {%- for comp in d.componentypes %} 14 | {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} 15 | {%- for name,v in d.pkg[comp].items() %} 16 | {%- if name in d.wanted[comp] %} 17 | {%- set software = d.pkg[comp][name] %} 18 | {%- set path = software['path'] %} 19 | {%- set package = software['use_upstream'] %} 20 | {%- if package == 'archive' and package in software and software[package] is mapping %} 21 | 22 | {# LINUX ALTERNATIVES #} 23 | 24 | {%- set bindir = '/sbin' if 'service' in software else '/bin' %} 25 | {%- if 'commands' in software and software['commands'] is iterable %} 26 | {%- for cmd in software['commands'] %} 27 | 28 | {{ formula }}-{{ comp }}-archive-{{ name }}-{{ cmd }}-alternatives-install: 29 | {%- if grains.os_family in ('Suse',) %} 30 | cmd.run: 31 | - name: update-alternatives --install {{ dir_symlink }}/{{ bindir }}/{{ cmd }} link-{{ formula }}-{{ name }}-{{ cmd }} {{ path }}/bin/{{ cmd }} {{ d.linux.altpriority }} # noqa 204 32 | - require_in: 33 | - alternatives: {{ formula }}-{{ comp }}-archive-{{ name }}-{{ cmd }}-alternatives-set 34 | {%- else %} 35 | alternatives.install: 36 | - link: {{ d.dir.symlink }}/{{ bindir }}/{{ cmd }} 37 | - path: {{ path }}/bin/{{ cmd }} 38 | - order: 10 39 | - priority: {{ d.linux.altpriority }} 40 | - name: link-{{ formula }}-{{ name }}-{{ cmd }} 41 | {%- endif %} 42 | - require: 43 | - sls: {{ sls_software_install }} 44 | - onlyif: test -x {{ path }}/bin/{{ cmd }} 45 | - require_in: 46 | - alternatives: {{ formula }}-{{ comp }}-archive-{{ name }}-{{ cmd }}-alternatives-set 47 | 48 | {{ formula }}-{{ comp }}-archive-{{ name }}-{{ cmd }}-alternatives-set: 49 | alternatives.set: 50 | - name: link-{{ formula }}-{{ name }}-{{ cmd }} 51 | - path: {{ path }}/bin/{{ cmd }} 52 | - onlyif: test -x {{ path }}/bin/{{ cmd }} 53 | 54 | {%- endfor %} {# alternative #} 55 | {%- endif %} {# commands #} 56 | {%- endif %} {# archive #} 57 | {%- endif %} {# wanted #} 58 | {%- endfor %} {# component #} 59 | {%- endif %} {# wanted #} 60 | {%- endfor %} {# components #} 61 | 62 | {%- else %} 63 | 64 | {{ formula }}-config-alternatives-install-notification: 65 | test.show_notification: 66 | - text: | 67 | Note: The linux alternatives state is not applicable for {{ grains.os }} 68 | 69 | {%- endif %} {# linux #} -------------------------------------------------------------------------------- /mongodb/config/clean.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import data as d with context %} 6 | {%- set sls_service_clean = tplroot ~ '.service.clean' %} 7 | {%- set sls_alternatives_clean = tplroot ~ '.config.alternatives.clean' %} 8 | {%- set formula = d.formula %} 9 | 10 | include: 11 | - {{ sls_service_clean }} 12 | - {{ sls_alternatives_clean }} 13 | 14 | {%- for comp in d.componentypes %} 15 | {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} 16 | {%- for name,v in d.pkg[comp].items() %} 17 | {%- if name in d.wanted[comp] %} 18 | {%- set software = d.pkg[comp][name] %} 19 | {%- if 'user' in software and 'group' in software %} 20 | 21 | {{ formula }}-config-clean-{{ name }}-usergroup: 22 | user.absent: 23 | - name: {{ software['user'] }} 24 | {%- if grains.os_family == 'MacOS' %} 25 | - onlyif: /usr/bin/dscl . list /Users | grep {{ name }} >/dev/null 2>&1 26 | {%- endif %} 27 | - require_in: 28 | - group: {{ formula }}-config-clean-{{ name }}-usergroup 29 | - require: 30 | - sls: {{ sls_service_clean }} 31 | - sls: {{ sls_alternatives_clean }} 32 | group.absent: 33 | - name: {{ software['group'] }} 34 | - require: 35 | - user: {{ formula }}-config-clean-{{ name }}-usergroup 36 | {%- endif %} {# users #} 37 | 38 | {{ formula }}-config-clean-{{ name }}-files: 39 | file.absent: 40 | - names: 41 | {%- if 'service' in software and software['service'] is mapping %} 42 | {%- set servicename = name if 'service' not in software else software.service.name %} 43 | - {{ d.dir.etc }}/{{ servicename|replace('org.mongo.mongodb.', '') }}.conf 44 | {%- endif %} 45 | {%- if 'config_file' in software and 'config' in software and software['config'] is mapping %} 46 | - {{ software['config_file'] }} 47 | {%- endif %} 48 | {%- if 'environ_file' in software and 'environ' in software and software['environ'] is mapping %} 49 | - {{ software['environ_file'] }} 50 | {%- endif %} 51 | - require: 52 | - sls: {{ sls_service_clean }} 53 | - sls: {{ sls_alternatives_clean }} 54 | 55 | {%- endif %} {# wanted #} 56 | {%- endfor %} {# component #} 57 | {%- endif %} {# wanted #} 58 | {%- endfor %} {# components #} 59 | -------------------------------------------------------------------------------- /mongodb/config/environ.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import data as d with context %} 6 | {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} 7 | {%- set sls_software_install = tplroot ~ '.install' %} 8 | {%- set formula = d.formula %} 9 | 10 | include: 11 | - {{ sls_software_install }} 12 | 13 | {%- for comp in d.componentypes %} 14 | {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} 15 | {%- for name,v in d.pkg[comp].items() %} 16 | {%- if name in d.wanted[comp] %} 17 | {%- set software = d.pkg[comp][name] %} 18 | {%- if 'environ_file' in software and 'environ' in software and software['environ'] is mapping %} 19 | 20 | {{ formula }}-config-install-{{ name }}-environ_file: 21 | file.managed: 22 | - name: {{ software['environ_file'] }} 23 | - source: {{ files_switch(['environ.sh.jinja'], 24 | lookup=formula ~ ' -config-install-' ~ name ~ '-environ_file' 25 | ) 26 | }} 27 | - mode: 640 28 | - user: {{ d.identity.rootuser }} 29 | - group: {{ d.identity.rootgroup }} 30 | - makedirs: True 31 | - template: jinja 32 | - context: 33 | path: {{ software['path']|json }} 34 | environ: {{ software['environ']|json }} 35 | - require: 36 | - sls: {{ sls_software_install }} 37 | 38 | {%- endif %} {# environ #} 39 | {%- endif %} {# wanted #} 40 | {%- endfor %} {# component #} 41 | {%- endif %} {# wanted #} 42 | {%- endfor %} {# components #} 43 | -------------------------------------------------------------------------------- /mongodb/config/file.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import data as d with context %} 6 | {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} 7 | {%- set sls_software_install = tplroot ~ '.install' %} 8 | {%- set sls_config_users = tplroot ~ '.config.users' %} 9 | {%- set formula = d.formula %} 10 | 11 | include: 12 | - {{ sls_software_install }} 13 | - {{ sls_config_users }} 14 | 15 | {{ formula }}-config-file-etc-file-directory: 16 | file.directory: 17 | - name: {{ d.dir.etc }} 18 | - user: {{ d.identity.rootuser }} 19 | - group: {{ d.identity.rootgroup }} 20 | - mode: '0755' 21 | - makedirs: True 22 | - require: 23 | - sls: {{ sls_software_install }} 24 | - sls: {{ sls_config_users }} 25 | 26 | {%- for comp in d.componentypes %} 27 | {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} 28 | {%- for name,v in d.pkg[comp].items() %} 29 | {%- if name in d.wanted[comp] %} 30 | {%- set software = d.pkg[comp][name] %} 31 | {%- if 'service' in software and software['service'] is mapping %} 32 | {%- set servicename = name if 'service' not in software else software.service.name %} 33 | {%- if 'config_file' in software and 'config' in software and software['config'] is mapping %} 34 | 35 | {{ formula }}-config-file-{{ servicename }}-file-managed: 36 | file.managed: 37 | - name: {{ d.dir.etc }}/{{ servicename|replace('org.mongo.mongodb.', '') }}.conf 38 | - source: {{ files_switch(['config.yml.jinja'], 39 | lookup=formula ~ '-config-file-' ~ servicename ~ '-file-managed' 40 | ) 41 | }} 42 | - mode: 644 43 | - user: {{ software['user'] }} 44 | - group: {{ software['group'] }} 45 | - makedirs: True 46 | - template: jinja 47 | - context: 48 | config: {{ software['config']|json }} 49 | - require: 50 | - user: {{ formula }}-config-usergroup-{{ servicename }}-install-usergroup-present 51 | - group: {{ formula }}-config-usergroup-{{ servicename }}-install-usergroup-present 52 | - sls: {{ sls_software_install }} 53 | 54 | {%- endif %} {# config #} 55 | {%- endif %} {# service #} 56 | {%- endif %} {# wanted #} 57 | {%- endfor %} {# component #} 58 | {%- endif %} {# wanted #} 59 | {%- endfor %} {# components #} 60 | -------------------------------------------------------------------------------- /mongodb/config/init.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | include: 5 | - .users 6 | - .file 7 | - .environ 8 | - .alternatives 9 | -------------------------------------------------------------------------------- /mongodb/config/users.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import data as d with context %} 6 | {%- set formula = d.formula %} 7 | {%- set sls_software_install = tplroot ~ '.install' %} 8 | 9 | include: 10 | - {{ sls_software_install }} 11 | 12 | {%- for comp in d.componentypes %} 13 | {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} 14 | {%- for name,v in d.pkg[comp].items() %} 15 | {%- if name in d.wanted[comp] %} 16 | {%- set software = d.pkg[comp][name] %} 17 | {%- if 'user' in software and 'service' in software and software['service'] is mapping %} 18 | {%- set servicename = name if 'service' not in software else software.service.name %} 19 | 20 | {{ formula }}-config-usergroup-{{ servicename }}-install-usergroup-present: 21 | group.present: 22 | - name: {{ software['group'] }} 23 | - system: true 24 | - require_in: 25 | - user: {{ formula }}-config-usergroup-{{ servicename }}-install-usergroup-present 26 | - require_in: 27 | - sls: {{ sls_software_install }} 28 | user.present: 29 | - name: {{ software['user'] }} 30 | - system: true 31 | - shell: /bin/false 32 | - createhome: false 33 | - groups: 34 | - {{ software['group'] }} 35 | {%- if grains.os_family == 'MacOS' %} 36 | - unless: /usr/bin/dscl . list /Users | grep {{ software['user'] }} >/dev/null 2>&1 37 | {%- endif %} {# darwin #} 38 | 39 | {%- endif %} {# service-users #} 40 | {%- endif %} {# wanted #} 41 | {%- endfor %} {# component #} 42 | {%- endif %} {# wanted #} 43 | {%- endfor %} {# components #} 44 | -------------------------------------------------------------------------------- /mongodb/defaults.yaml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | mongodb: 5 | componentypes: ['database', 'gui', 'connectors'] 6 | packagetypes: ['archive', 'package', 'repo', 'native'] 7 | wanted: 8 | database: 9 | - mongod 10 | gui: [] 11 | connectors: [] 12 | firewall: false 13 | selinux: false 14 | disable_transparent_hugepages: true 15 | pkg: 16 | deps: 17 | - python-pip 18 | - gzip 19 | - unzip 20 | - tar 21 | pips: 22 | - pymongo 23 | repo: 24 | humanname: mongodb 25 | name: mongodb 26 | comments: 27 | - installed by salt 28 | enabled: 1 29 | gpgcheck: 1 30 | 31 | database: 32 | dbtools: 33 | version: 100.0.1 34 | name: mongodb-database-tools 35 | use_upstream: 'archive' 36 | archive: 37 | skip_verify: true 38 | commands: 39 | - bsondump 40 | - mongoexport 41 | - mongoimport 42 | - mongostat 43 | - mongodump 44 | - mongofiles 45 | - mongorestore 46 | - mongotop 47 | shell: 48 | version: 4.2.6 49 | name: mongodb-org-shell 50 | use_upstream: 'archive' 51 | config_file: /etc/mongodb/mongorc.js 52 | commands: 53 | - mongo 54 | mongod: 55 | version: 4.2.6 56 | name: mongodb-org-server 57 | use_upstream: 'archive' 58 | user: mongodb 59 | group: mongodb 60 | config_file: /etc/mongodb/mongod.conf 61 | native: 62 | # see osfingermap 63 | skip_verify: true 64 | archive: 65 | skip_verify: true 66 | source: https://fastdl.mongodb.org/linux/mongodb-linux-ARCH-debian10-VER.tgz 67 | config: 68 | # http://docs.mongodb.org/manual/reference/configuration-options 69 | storage: 70 | dbPath: /var/lib/mongodb/mongod 71 | systemLog: 72 | quiet: true 73 | traceAllExceptions: false 74 | path: /var/log/mongodb/mongod.log 75 | destination: file 76 | logAppend: true 77 | # replication: 78 | # replSetName: "rs1" 79 | # sharding: 80 | # clusterRole: shardsvr 81 | net: 82 | port: 27017 83 | environ_file: /etc/default/mongod.sh 84 | environ: {} 85 | service: 86 | name: mongod 87 | commands: 88 | - mongod 89 | - mongodump 90 | - mongorestore 91 | - mongoexport 92 | - mongoimport 93 | - mongostat 94 | - mongotop 95 | - bsondump 96 | - mongofiles 97 | - mongoreplay 98 | - mongos 99 | - mongo 100 | firewall: 101 | ports: 102 | - tcp/27017 103 | - tcp/27018 104 | - tcp/27019 105 | mongos: 106 | version: 4.2.6 107 | name: mongodb-org-mongos 108 | use_upstream: null # installed with mongod 109 | user: mongos 110 | group: mongos 111 | config_file: /etc/mongodb/mongos.conf 112 | config: 113 | sharding: 114 | configDB: 'rs1/127.0.0.1:27018' 115 | systemLog: 116 | quiet: true 117 | traceAllExceptions: false 118 | path: /var/log/mongodb/mongos.log 119 | service: 120 | name: mongos 121 | firewall: 122 | ports: 123 | - tcp/9093 124 | # tcp/9094 125 | gui: 126 | compass: 127 | version: 1.21.2 128 | name: mongo-compass 129 | use_upstream: native 130 | robo3t: 131 | version: 1.3.1 132 | use_upstream: archive 133 | archive: 134 | # yamllint disable-line rule:line-length 135 | source: https://download-test.robomongo.org/linux/robo3t-VER-linux-ARCH-7419c406.tar.gz 136 | skip_verify: true 137 | commands: 138 | - robo3t 139 | 140 | connectors: 141 | bi: 142 | name: mongodb-bi 143 | version: 2.13.4 144 | use_upstream: archive 145 | archive: 146 | # for linux, see osfingermap; bi is unavailable for macos 147 | skip_verify: true 148 | service: 149 | name: mongosqld 150 | firewall: 151 | ports: tcp/29017 152 | commands: 153 | - mongodrdl 154 | - mongosqld 155 | - mongotranslate 156 | kafka: 157 | version: 1.1.0 158 | name: mongo-kafka 159 | use_upstream: archive 160 | archive: 161 | # yamllint disable-line rule:line-length 162 | source: https://github.com/mongodb/mongo-kafka/releases/download/rVER/mongodb-kafka-connect-mongodb-VER.zip 163 | skip_verify: true 164 | spark: 165 | version: 2.4.1 166 | name: mongo-spark 167 | use_upstream: archive 168 | archive: 169 | source: https://github.com/mongodb/mongo-spark/archive/rVER.tar.gz 170 | skip_verify: true 171 | 172 | # Just here for testing 173 | added_in_defaults: defaults_value 174 | winner: defaults 175 | 176 | identity: 177 | user: root 178 | rootuser: root 179 | rootgroup: root 180 | 181 | retry_option: 182 | # https://docs.saltstack.com/en/latest/ref/states/requisites.html#retrying-states 183 | attempts: 3 184 | until: true 185 | interval: 60 186 | splay: 10 187 | linux: 188 | altpriority: 0 189 | limits: 190 | soft: 2048 191 | hard: 4096 192 | 193 | dir: 194 | archive: /usr/local/mongodb 195 | macapp: /Applications 196 | native: /tmp/downloads 197 | default: /etc/default 198 | etc: /etc/mongodb 199 | homes: /home 200 | pid: /var/run/mongodb 201 | log: /var/log/mongodb 202 | service: /usr/lib/systemd/system 203 | symlink: /usr/local 204 | tmp: /tmp/downloads 205 | var: /var/lib/mongodb 206 | -------------------------------------------------------------------------------- /mongodb/files/default/config.yml.jinja: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | # File managed by Salt at <{{ source }}>. 3 | # Your changes may be overwritten. 4 | ######################################################################## 5 | 6 | {{ config|yaml(False) }} 7 | -------------------------------------------------------------------------------- /mongodb/files/default/environ.sh.jinja: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | # File managed by Salt at <{{ source }}>. 3 | # Your changes may be overwritten. 4 | ######################################################################## 5 | 6 | export PATH=${PATH}:{{ path }} 7 | {{ environ|yaml(False) }} 8 | -------------------------------------------------------------------------------- /mongodb/files/default/logrotate.jinja: -------------------------------------------------------------------------------- 1 | ######################################################### 2 | # File managed by Salt. Changes risk being overwritten. 3 | ######################################################### 4 | # MongoDB {{ svc }} logrotate 5 | {{ pattern }} { 6 | daily 7 | missingok 8 | rotate {{ days }} 9 | compress 10 | dateext 11 | notifempty 12 | sharedscripts 13 | postrotate 14 | /bin/kill -SIGUSR1 `cat {{ pidpath }}/{{ svc }}.pid 2> /dev/null` 2> /dev/null || true 15 | endscript 16 | } 17 | -------------------------------------------------------------------------------- /mongodb/files/default/mac_shortcut.sh.jinja: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | Source="{{ appdir }}/{{ appname }}.app" 4 | Destination="{{ homes }}/{{ user }}/Desktop" 5 | diskutil resetUserPermissions / {{ user }} 6 | /usr/bin/osascript -e "tell application \"Finder\" to make alias file to POSIX file \"$Source\" at POSIX file \"$Destination\"" 7 | -------------------------------------------------------------------------------- /mongodb/files/default/macos.plist.jinja: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Label 6 | org.mongo.mongodb.{{ svc }} 7 | ProgramArguments 8 | 9 | {{ binpath }}/bin/{{ svc }} 10 | {{ '--config' }} 11 | {{ config }} 12 | 13 | RunAtLoad 14 | 15 | SoftResourceLimits 16 | 17 | NumberOfFiles 18 | {{ limits.soft }} 19 | 20 | HardResourceLimits 21 | 22 | NumberOfFiles 23 | {{ limits.hard }} 24 | 25 | StandardErrorPath 26 | /var/log/mongodb/{{ svc }}.log 27 | StandardOutPath 28 | /var/log/mongodb/{{ svc }}.log 29 | 30 | 31 | -------------------------------------------------------------------------------- /mongodb/files/default/mongorc.js.jinja: -------------------------------------------------------------------------------- 1 | //######################################################### 2 | //# File managed by Salt. Changes risk being overwritten. 3 | //######################################################### 4 | //# MongoDB {{ svc }} 5 | // disable dropDatabase 6 | db.dropDatabase = DB.prototype.dropDatabase = function() { 7 | print("dropDatabase is disabled on this environment"); 8 | }; 9 | 10 | prompt = function() { 11 | // case mongos 12 | if (rs.status().info = 'mongos') { 13 | return rs.status().info + ':[' + db.version() + '] > '; 14 | } 15 | 16 | // for replicasets 17 | switch (rs.status().myState) { 18 | case 1: 19 | stateStr = 'PRIMARY' 20 | break; 21 | 22 | case 2: 23 | stateStr = 'SECONDARY' 24 | break; 25 | 26 | case 7: 27 | stateStr = 'ARBITER' 28 | break; 29 | 30 | dafault: 31 | stateStr = 'MONGO' 32 | break; 33 | } 34 | return rs.status().set + ':' + stateStr + ':[' + db.version() + '] > '; 35 | } 36 | -------------------------------------------------------------------------------- /mongodb/files/default/systemd.ini.jinja: -------------------------------------------------------------------------------- 1 | ######################################################### 2 | # File managed by Salt. Changes risk being overwritten. 3 | ######################################################### 4 | [Unit] 5 | Description={{ desc }} 6 | Wants=network-online.target 7 | After= 8 | Documentation=https://github.com/saltstack-formulas/mongodb-formula 9 | 10 | [Service] 11 | User={{ user }} 12 | Group={{ group }} 13 | WorkingDirectory={{ workdir }} 14 | ExecStart={{ start }} 15 | ExecStop={{ stop }} 16 | PIDFile=/var/run/{{ name }}.pid 17 | 18 | # Recommended limits for for mongod as specified in 19 | # http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings 20 | # file size 21 | LimitFSIZE=infinity 22 | # cpu time 23 | LimitCPU=infinity 24 | # virtual memory size 25 | LimitAS=infinity 26 | # open files 27 | LimitNOFILE=64000 28 | # processes/threads 29 | LimitNPROC=64000 30 | # locked memory 31 | LimitMEMLOCK=infinity 32 | # total threads (user+kernel) 33 | TasksMax=infinity 34 | TasksAccounting=False 35 | # Recommended limits for for mongod as specified in 36 | # http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings 37 | 38 | [Install] 39 | WantedBy=multi-user.target 40 | -------------------------------------------------------------------------------- /mongodb/files/disable-transparent-hugepages.init: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### BEGIN INIT INFO 3 | # Provides: disable-transparent-hugepages 4 | # Required-Start: $local_fs 5 | # Required-Stop: 6 | # X-Start-Before: mongod mongodb-mms-automation-agent 7 | # Default-Start: 2 3 4 5 8 | # Default-Stop: 0 1 6 9 | # Short-Description: Disable Linux transparent huge pages 10 | # Description: Disable Linux transparent huge pages, to improve 11 | # database performance. 12 | ### END INIT INFO 13 | 14 | ######################################################### 15 | # File managed by Salt. Changes risk being overwritten. 16 | ######################################################### 17 | 18 | case $1 in 19 | start) 20 | if [ -d /sys/kernel/mm/transparent_hugepage ]; then 21 | thp_path=/sys/kernel/mm/transparent_hugepage 22 | elif [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; then 23 | thp_path=/sys/kernel/mm/redhat_transparent_hugepage 24 | else 25 | return 0 26 | fi 27 | 28 | echo 'never' > ${thp_path}/enabled 29 | echo 'never' > ${thp_path}/defrag 30 | 31 | re='^[0-1]+$' 32 | if [[ $(cat ${thp_path}/khugepaged/defrag) =~ $re ]] 33 | then 34 | # RHEL 7 35 | echo 0 > ${thp_path}/khugepaged/defrag 36 | else 37 | # RHEL 6 38 | echo 'no' > ${thp_path}/khugepaged/defrag 39 | fi 40 | 41 | unset re 42 | unset thp_path 43 | ;; 44 | esac 45 | 46 | -------------------------------------------------------------------------------- /mongodb/files/macros.jinja: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=jinja 3 | # 4 | # Collection of common macros 5 | 6 | {%- macro format_kwargs(kwarg) -%} 7 | 8 | {%- filter indent(4) %} 9 | {%- for k, v in kwarg|dictsort() %} 10 | - {{ k }}: {{ v }} 11 | {%- endfor %} 12 | {%- endfilter %} 13 | {%- endmacro %} 14 | 15 | {%- macro concat_args(args) %} 16 | {%- set args = args|dictsort %} 17 | {%- if args|length > 0 %} 18 | {%- for k,v in args -%} 19 | {%- if not k or not v %}{% continue %}{% endif -%} 20 | {%- if v == True -%} 21 | --{{ k }} 22 | {%- elif v == False -%} 23 | --no-{{ k }} 24 | {%- else -%} 25 | --{{ k }}={{ v }} 26 | {%- endif -%} 27 | {%- if not loop.last %} {% endif -%} 28 | {%- endfor -%} 29 | {%- endif -%} 30 | {%- endmacro %} 31 | -------------------------------------------------------------------------------- /mongodb/init.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | {%- if grains.kernel|lower in ('linux', 'darwin',) %} 5 | 6 | include: 7 | - .install 8 | - .config 9 | - .service 10 | 11 | {%- else %} 12 | 13 | m-not-available-to-install: 14 | test.show_notification: 15 | - text: | 16 | This formula is unavailable for {{ salt['grains.get']('finger', grains.os_family) }} 17 | 18 | {%- endif %} 19 | -------------------------------------------------------------------------------- /mongodb/install.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import data as d with context %} 6 | {%- from tplroot ~ "/files/macros.jinja" import format_kwargs with context %} 7 | {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} 8 | {%- set sls_config_users = tplroot ~ '.config.users' %} 9 | {%- set formula = d.formula %} 10 | 11 | include: 12 | - {{ sls_config_users }} 13 | 14 | {{ formula }}-install-prerequisites: 15 | pkg.installed: 16 | - names: {{ d.pkg.deps|json }} 17 | pip.installed: 18 | - names: {{ d.pkg.pips|json }} 19 | - reload_modules: True 20 | - require: 21 | - pkg: {{ formula }}-install-prerequisites 22 | file.directory: 23 | - names: 24 | - {{ d.dir.var }} 25 | - {{ d.dir.tmp }} 26 | - user: root 27 | - group: {{ d.identity.rootgroup }} 28 | - mode: '0755' 29 | - makedirs: True 30 | - require: 31 | - pkg: {{ formula }}-install-prerequisites 32 | - pip: {{ formula }}-install-prerequisites 33 | 34 | {%- for comp in d.componentypes %} 35 | {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} 36 | {%- for name,v in d.pkg[comp].items() %} 37 | {%- if name in d.wanted[comp] %} 38 | {%- set software = d.pkg[comp][name] %} 39 | {%- set package = software['use_upstream'] %} 40 | {%- if package in d.packagetypes %} 41 | 42 | {# DOWNLOAD NATIVE PACKAGE #} 43 | 44 | {%- if package != 'archive' and package in software and software[package] is mapping %} 45 | {%- if 'source' in software[package] %} 46 | 47 | {{ formula }}-{{ comp }}-{{ name }}-{{ package }}-download: 48 | cmd.run: 49 | - name: curl -Lo {{ d.dir.tmp ~ '/' ~ comp ~ name ~ software['version'] }} {{ software[package]['source'] }} 50 | - unless: test -f {{ d.dir.tmp ~ '/' ~ comp ~ name ~ software['version'] }} 51 | - retry: {{ d.retry_option|json }} 52 | - require: 53 | - file: {{ formula }}-install-prerequisites 54 | - require_in: 55 | - {{ formula }}-{{ comp }}-{{ name }}-{{ package }}-install 56 | {%- if 'source_hash' in software[package] %} 57 | module.run: 58 | - name: file.check_hash 59 | - path: {{ d.dir.tmp ~ '/' ~ comp ~ name ~ software['version'] }} 60 | - file_hash: {{ software[package]['source_hash'] }} 61 | file.absent: 62 | - name: {{ d.dir.tmp ~ '/' ~ comp ~ name ~ software['version'] }} 63 | - onfail: 64 | - module: {{ formula }}-{{ comp }}-{{ name }}-{{ package }}-download 65 | {%- endif %} 66 | 67 | {%- else %} 68 | test.show_notification: 69 | - text: | 70 | Note: there is no dict named 'source' in 'pkg:{{ comp }}:{{ name }}'. 71 | {%- endif %} {# source #} 72 | {%- endif %} {# download #} 73 | 74 | {{ formula }}-{{ comp }}-{{ name }}-{{ package }}-install: 75 | 76 | {#- NATIVE PACKAGE INSTALL #} 77 | 78 | {%- if package in ('native', 'repo') %} 79 | {%- if package == 'repo' and 'repo' in d.pkg and d.pkg.repo %} 80 | pkgrepo.managed: 81 | {%- for k, v in d.pkg.repo|dictsort %} 82 | {%- if v %} 83 | - {{ k }}: {{ v|json }} 84 | {%- endif %} 85 | {%- endfor %} 86 | {%- endif %} 87 | pkg.installed: 88 | {%- if package in software and software[package] is mapping %} 89 | - sources: 90 | - {{ software.name }}: {{ d.dir.tmp ~ '/' ~ comp ~ name ~ software['version'] }} 91 | - {{ software.name }}: {{ software[package]['source'] }} 92 | {%- if 'source_hash' in software[package] %} 93 | - require: 94 | - module: {{ formula }}-{{ comp }}-{{ name }}-{{ package }}-download 95 | {%- endif %} 96 | {%- else %} {# package #} 97 | - name: {{ software.get('name', name) }} 98 | {%- endif %} 99 | - reload_modules: true 100 | 101 | {#- ARCHIVE PACKAGE INSTALL #} 102 | 103 | {%- elif package == 'archive' and package in software and software[package] is mapping %} 104 | {%- if 'source' in software[package] %} 105 | file.directory: 106 | - name: {{ software['path'] }} 107 | - user: {{ d.identity.rootuser }} 108 | - group: {{ d.identity.rootgroup }} 109 | - mode: '0755' 110 | - makedirs: True 111 | - require: 112 | - file: {{ formula }}-install-prerequisites 113 | - require_in: 114 | - archive: {{ formula }}-{{ comp }}-{{ name }}-{{ package }}-install 115 | - recurse: 116 | - user 117 | - group 118 | - mode 119 | archive.extracted: 120 | {{- format_kwargs(software[package]) }} 121 | - trim_output: true 122 | {%- if 'tar' in software[package]['source'] or 'tgz' in software[package]['source'] %} 123 | - enforce_toplevel: false 124 | - options: --strip-components=1 125 | {%- endif %} 126 | - retry: {{ d.retry_option|json }} 127 | - user: {{ d.identity.rootuser }} 128 | - group: {{ d.identity.rootgroup }} 129 | - require: 130 | - file: {{ formula }}-{{ comp }}-{{ name }}-{{ package }}-install 131 | - unless: 132 | - test -f {{ software['path'] }}/dummyFILENAME 133 | {%- if 'commands' in software and software['commands'] is iterable %} 134 | {%- for cmd in software['commands'] %} 135 | - test -x {{ software['path'] }}/bin/{{ cmd }} 136 | {%- endfor %} 137 | {%- endif %} 138 | 139 | {%- else %} 140 | test.show_notification: 141 | - text: | 142 | Note: there is no dict named 'source' in 'pkg:{{ comp }}:{{ name }}'. 143 | {%- endif %} 144 | 145 | {#- MACAPP PACKAGE INSTALL #} 146 | 147 | {%- elif package == 'macapp' and package in software and software[package] is mapping %} 148 | {%- if 'source' in software[package] %} 149 | macpackage.installed: 150 | - name: {{ d.dir.tmp ~ '/' ~ comp ~ name ~ software['version'] }} 151 | - store: True 152 | - dmg: True 153 | - app: True 154 | - force: True 155 | - allow_untrusted: True 156 | - onchanges: 157 | - cmd: {{ formula }}-{{ comp }}-{{ name }}-{{ package }}-download 158 | file.managed: 159 | - name: /tmp/mac_shortcut.sh 160 | - source: {{ files_switch(['mac_shortcut.sh.jinja'], 161 | lookup=formula ~ '-' ~ comp ~ '-' ~ name ~ '-' ~ package ~ '-install' 162 | ) 163 | }} 164 | - mode: 755 165 | - template: jinja 166 | - context: 167 | appdir: {{ d.dir.macapp }} 168 | appname: {{ software['name'] }} 169 | user: {{ d.identity.rootuser }} 170 | homes: {{ d.dir.homes }} 171 | - require: 172 | - macpackage: {{ formula }}-{{ comp }}-{{ name }}-{{ package }}-install 173 | cmd.run: 174 | - name: /tmp/mac_shortcut.sh 175 | - runas: {{ d.identity.user }} 176 | - require: 177 | - file: {{ formula }}-{{ comp }}-{{ name }}-{{ package }}-install 178 | 179 | {%- else %} 180 | test.show_notification: 181 | - text: | 182 | Note: there is no dict named 'source' in 'pkg:{{ comp }}:{{ name }}'. 183 | {%- endif %} 184 | {%- else %} 185 | test.show_notification: 186 | - text: | 187 | Note: there is no dict named {{ package }} in 'pkg:{{ comp }}:{{ name }}'. 188 | Maybe the value of 'pkg:{{ comp }}:{{ name }}:package_format' is incorrect. 189 | {%- endif %} 190 | 191 | {#- SYMLINK INSTALL #} 192 | 193 | {%- if grains.kernel|lower in ('linux', 'darwin') %} 194 | {%- if package in ('archive', 'macapp') %} 195 | {%- if d.linux.altpriority|int <= 0 or grains.os_family in ('MacOS', 'Arch') %} 196 | {%- if 'commands' in software and software['commands'] is iterable %} 197 | {%- for cmd in software['commands'] %} 198 | 199 | {{ formula }}-{{ comp }}-{{ name }}-{{ package }}-install-symlink-{{ cmd }}: 200 | file.symlink: 201 | - name: {{ d.dir.symlink }}/{{ 's' if 'service' in software else '' }}bin/{{ cmd }} 202 | - target: {{ software['path'] }}/{{ cmd }} 203 | - onlyif: test -f {{ d.dir.symlink }}/{{ 's' if 'service' in software else '' }}bin/{{ cmd }} 204 | - force: True 205 | 206 | {%- endfor %} {# command #} 207 | {%- endif %} {# commands #} 208 | {%- endif %} {# service #} 209 | {%- endif %} {# symlink #} 210 | {%- endif %} {# darwin/linux #} 211 | {%- endif %} {# software/package #} 212 | 213 | {#- SERVICE INSTALL #} 214 | 215 | {%- if 'service' in software and software['service'] %} 216 | {%- set service = software['service'] %} 217 | 218 | {%- if package != 'repo' %} 219 | {{ formula }}-{{ comp }}-{{ service.name }}-install-service-directory: 220 | file.directory: 221 | - name: {{ d.dir.var }}/{{ name }} 222 | - user: {{ software['user'] }} 223 | - group: {{ software['group'] }} 224 | - mode: '0755' 225 | - makedirs: True 226 | - require: 227 | - sls: {{ sls_config_users }} 228 | - file: {{ formula }}-install-prerequisites 229 | - require_in: 230 | {%- if grains.kernel == 'Linux' %} 231 | - file: {{ formula }}-{{ comp }}-{{ service.name }}-install-service-systemd 232 | 233 | {{ formula }}-{{ comp }}-{{ service.name }}-install-service-systemd: 234 | file.managed: 235 | - name: {{ d.dir.service }}/{{ name }}.service 236 | - source: {{ files_switch(['systemd.ini.jinja'], 237 | lookup=formula ~ '-' ~ comp ~ '-' ~ service.name ~ '-install-service-systemd' 238 | ) 239 | }} 240 | - mode: '0644' 241 | - user: {{ d.identity.rootuser }} 242 | - group: {{ d.identity.rootgroup }} 243 | - makedirs: True 244 | - template: jinja 245 | - context: 246 | desc: {{ formula }} {{ name }} service 247 | name: {{ name }} 248 | workdir: {{ d.dir.var }}/{{ name }} 249 | user: {{ software['user'] }} 250 | group: {{ software['group'] }} 251 | stop: '' 252 | start: {{ software['path'] }}/bin/{{ name }} 253 | - watch_in: 254 | - cmd: {{ formula }}-{{ comp }}-{{ service.name }}-install-service-systemd 255 | cmd.wait: # noqa: 213 256 | - name: systemctl daemon-reload 257 | {%- elif grains.kernel == 'Darwin' %} 258 | {%- set servicename = name if 'name' not in service else service.name %} 259 | - require_in: 260 | - file: {{ formula }}-{{ comp }}-{{ servicename }}-install-service-launched 261 | 262 | {{ formula }}-{{ comp }}-{{ servicename }}-install-service-launched: 263 | file.managed: 264 | - name: /Library/LaunchAgents/{{ servicename }}.plist 265 | - source: salt://{{ formula }}/files/default/macos.plist.jinja 266 | - mode: '0644' 267 | - user: root 268 | - group: wheel 269 | - template: jinja 270 | - makedirs: True 271 | - context: 272 | svc: {{ servicename|replace('org.mongo.mongodb.', '') }} 273 | config: {{ software['config_file'] }} 274 | binpath: {{ software['path'] }} 275 | user: {{ software['user'] }} 276 | limits: {{ d.limits }} 277 | 278 | {%- endif %} {# linux/darwin #} 279 | {%- endif %} {# !repo #} 280 | {%- endif %} {# service #} 281 | {%- endif %} {# wanted #} 282 | {%- endfor %} {# component #} 283 | {%- endif %} {# wanted #} 284 | {%- endfor %} {# components #} 285 | -------------------------------------------------------------------------------- /mongodb/libtofs.jinja: -------------------------------------------------------------------------------- 1 | {%- macro files_switch( 2 | source_files, 3 | lookup=None, 4 | default_files_switch=["id", "os_family"], 5 | indent_width=6, 6 | use_subpath=False 7 | ) %} 8 | {#- 9 | Returns a valid value for the "source" parameter of a "file.managed" 10 | state function. This makes easier the usage of the Template Override and 11 | Files Switch (TOFS) pattern. 12 | Params: 13 | * source_files: ordered list of files to look for 14 | * lookup: key under ":tofs:source_files" to prepend to the 15 | list of source files 16 | * default_files_switch: if there's no config (e.g. pillar) 17 | ":tofs:files_switch" this is the ordered list of grains to 18 | use as selector switch of the directories under 19 | "/files" 20 | * indent_width: indentation of the result value to conform to YAML 21 | * use_subpath: defaults to `False` but if set, lookup the source file 22 | recursively from the current state directory up to `tplroot` 23 | Example (based on a `tplroot` of `xxx`): 24 | If we have a state: 25 | Deploy configuration: 26 | file.managed: 27 | - name: /etc/yyy/zzz.conf 28 | - source: {{ files_switch( 29 | ["/etc/yyy/zzz.conf", "/etc/yyy/zzz.conf.jinja"], 30 | lookup="Deploy configuration", 31 | ) }} 32 | - template: jinja 33 | In a minion with id=theminion and os_family=RedHat, it's going to be 34 | rendered as: 35 | Deploy configuration: 36 | file.managed: 37 | - name: /etc/yyy/zzz.conf 38 | - source: 39 | - salt://xxx/files/theminion/etc/yyy/zzz.conf 40 | - salt://xxx/files/theminion/etc/yyy/zzz.conf.jinja 41 | - salt://xxx/files/RedHat/etc/yyy/zzz.conf 42 | - salt://xxx/files/RedHat/etc/yyy/zzz.conf.jinja 43 | - salt://xxx/files/default/etc/yyy/zzz.conf 44 | - salt://xxx/files/default/etc/yyy/zzz.conf.jinja 45 | - template: jinja 46 | #} 47 | {#- Get the `tplroot` from `tpldir` #} 48 | {%- set tplroot = tpldir.split("/")[0] %} 49 | {%- set path_prefix = salt["config.get"](tplroot ~ ":tofs:path_prefix", tplroot) %} 50 | {%- set files_dir = salt["config.get"](tplroot ~ ":tofs:dirs:files", "files") %} 51 | {%- set files_switch_list = salt["config.get"]( 52 | tplroot ~ ":tofs:files_switch", default_files_switch 53 | ) %} 54 | {#- Lookup source_files (v2), files (v1), or fallback to an empty list #} 55 | {%- set src_files = salt["config.get"]( 56 | tplroot ~ ":tofs:source_files:" ~ lookup, 57 | salt["config.get"](tplroot ~ ":tofs:files:" ~ lookup, []), 58 | ) %} 59 | {#- Append the default source_files #} 60 | {%- set src_files = src_files + source_files %} 61 | {#- Only add to [""] when supporting older TOFS implementations #} 62 | {%- set path_prefix_exts = [""] %} 63 | {%- if use_subpath and tplroot != tpldir %} 64 | {#- Walk directory tree to find {{ files_dir }} #} 65 | {%- set subpath_parts = tpldir.lstrip(tplroot).lstrip("/").split("/") %} 66 | {%- for path in subpath_parts %} 67 | {%- set subpath = subpath_parts[0 : loop.index] | join("/") %} 68 | {%- do path_prefix_exts.append("/" ~ subpath) %} 69 | {%- endfor %} 70 | {%- endif %} 71 | {%- for path_prefix_ext in path_prefix_exts | reverse %} 72 | {%- set path_prefix_inc_ext = path_prefix ~ path_prefix_ext %} 73 | {#- For older TOFS implementation, use `files_switch` from the config #} 74 | {#- Use the default, new method otherwise #} 75 | {%- set fsl = salt["config.get"]( 76 | tplroot ~ path_prefix_ext | replace("/", ":") ~ ":files_switch", 77 | files_switch_list, 78 | ) %} 79 | {#- Append an empty value to evaluate as `default` in the loop below #} 80 | {%- if "" not in fsl %} 81 | {%- set fsl = fsl + [""] %} 82 | {%- endif %} 83 | {%- for fs in fsl %} 84 | {%- for src_file in src_files %} 85 | {%- if fs %} 86 | {%- set fs_dirs = salt["config.get"](fs, fs) %} 87 | {%- else %} 88 | {%- set fs_dirs = salt["config.get"]( 89 | tplroot ~ ":tofs:dirs:default", "default" 90 | ) %} 91 | {%- endif %} 92 | {#- Force the `config.get` lookup result as a list where necessary #} 93 | {#- since we need to also handle grains that are lists #} 94 | {%- if fs_dirs is string %} 95 | {%- set fs_dirs = [fs_dirs] %} 96 | {%- endif %} 97 | {%- for fs_dir in fs_dirs %} 98 | {#- strip empty elements by using a select #} 99 | {%- set url = ( 100 | [ 101 | "- salt:/", 102 | path_prefix_inc_ext.strip("/"), 103 | files_dir.strip("/"), 104 | fs_dir.strip("/"), 105 | src_file.strip("/"), 106 | ] 107 | | select 108 | | join("/") 109 | ) %} 110 | {{ url | indent(indent_width, true) }} 111 | {%- endfor %} 112 | {%- endfor %} 113 | {%- endfor %} 114 | {%- endfor %} 115 | {%- endmacro %} 116 | -------------------------------------------------------------------------------- /mongodb/map.jinja: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=jinja 3 | 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %} 6 | {%- import_yaml tplroot ~ "/osfingermap.yaml" as osfingermap %} 7 | {%- import_yaml tplroot ~ "/osarchmap.yaml" as osarchmap %} 8 | {%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %} 9 | {%- set _config = salt['config.get'](tplroot, default={}) %} 10 | 11 | {%- set defaults = salt['grains.filter_by']( 12 | default_settings, 13 | default=tplroot, 14 | merge=salt['grains.filter_by']( osfamilymap, grain='os_family', 15 | merge=salt['grains.filter_by']( osarchmap, grain='osarch', 16 | merge=salt['grains.filter_by']( osfingermap, grain='osfinger', 17 | merge=salt['grains.filter_by']( _config, default='lookup' 18 | ) 19 | ) 20 | ) 21 | ) 22 | ) 23 | %} 24 | {%- set d = salt['grains.filter_by']( {'defaults': defaults}, default='defaults', merge=_config) %} 25 | 26 | # depreciate two params 27 | {%- if 'software_component_matrix' in d %} 28 | {%- do d.update({ 'components': d.software_component_matrix }) %} 29 | {%- endif %} 30 | {%- if 'software_package_matrix' in d %} 31 | {%- do d.update({ 'packagetypes': d.software_package_matrix }) %} 32 | {%- endif %} 33 | 34 | # build dict 35 | {%- for comp in d.componentypes %} 36 | {%- if comp in d.pkg and d.pkg[comp] is mapping %} 37 | {%- for name,v in d.pkg[comp].items() %} 38 | {%- set software = d.pkg[comp][name] %} 39 | {%- set url = None %} 40 | {%- set path = d.dir.archive ~ '/' ~ name %} 41 | {%- if 'version' in v and v.version %} 42 | {%- set release = v.version.split('.')[0] ~ '.' ~ v.version.split('.')[1] %} 43 | {%- set dir = '%s-%s'|format(name, v.version) %} 44 | {%- set path = d.dir.archive ~ '/' ~ dir %} 45 | {%- for package in d.packagetypes %} 46 | {%- if package in v and v[package] %} 47 | {%- set path = d.dir[package] if package == 'macapp' else path %} 48 | {%- do software[package].update({'name': path}) %} 49 | {%- if 'source' in v[package] %} 50 | {%- set u = v[package]['source']|replace('VER', v.version) %} 51 | {%- set url = u|replace('REL', release)|replace('ARCH', d.arch) %} 52 | {%- do software[package].update({'source': url}) %} 53 | {%- endif %} 54 | {%- if 'source_hash' in v[package] %} 55 | {%- set h = v[package]['source_hash']|replace('VER', v.version) %} 56 | {%- set hash = h|replace('REL', release)|replace('ARCH', d.arch) %} 57 | {%- do software[package].update({'source_hash': hash}) %} 58 | {%- endif %} 59 | {%- endif %} 60 | {%- endfor %} 61 | {%- endif %} 62 | {%- do software.update({'path': path}) %} 63 | {%- endfor %} 64 | {%- endif %} 65 | {%- endfor %} 66 | 67 | {# MONGODB #} 68 | {%- do d.update({'formula': 'mongodb'}) %} 69 | 70 | {%- do d.pkg.database.mongos.update({'path': d.pkg.database.mongod.path}) %} 71 | {%- if 'repo' in d.pkg and 'mongod' in d.pkg.database %} 72 | {%- for fname in ('file', 'name', 'humanname', 'gpgkey',) %} 73 | {%- if fname in d.pkg.repo %} 74 | {%- do d.pkg.repo.update({fname: d.pkg.repo[fname]|replace('REL', d.pkg.database.mongod.version)}) %} 75 | {%- endif %} 76 | {%- endfor %} 77 | {%- endif %} 78 | 79 | {%- set data = d %} 80 | -------------------------------------------------------------------------------- /mongodb/osarchmap.yaml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | # 4 | # Setup variables using grains['osarch'] based logic. 5 | # You just need to add the key:values for an `osarch` that differ 6 | # from `defaults.yaml` + `os_family.yaml`. 7 | # Only add an `osarch` which is/will be supported by the formula 8 | # 9 | # If you do not need to provide defaults via the `osarch` grain, 10 | # you will need to provide at least an empty dict in this file, e.g. 11 | # osarch: {} 12 | --- 13 | amd64: 14 | arch: x86_64 15 | 16 | x86_64: 17 | arch: x86_64 18 | 19 | 386: 20 | arch: 386 21 | 22 | arm64: 23 | arch: arm64 24 | 25 | armv6l: 26 | arch: armv6l 27 | 28 | armv7l: 29 | arch: armv7l 30 | 31 | ppc64le: 32 | arch: ppc64le 33 | 34 | s390x: 35 | arch: s390x 36 | -------------------------------------------------------------------------------- /mongodb/osfamilymap.yaml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | # 4 | # Setup variables using grains['os_family'] based logic. 5 | # You just need to add the key:values for an `os_family` that differ 6 | # from `defaults.yaml`. 7 | # Only add an `os_family` which is/will be supported by the formula 8 | # 9 | # If you do not need to provide defaults via the `os_family` grain, 10 | # you will need to provide at least an empty dict in this file, e.g. 11 | # osfamilymap: {} 12 | --- 13 | {%- if grains.os == 'MacOS' %} 14 | {%- set macos_rootuser = salt['cmd.run']("stat -f '%Su' /dev/console") %} 15 | {%- set macos_rootgroup = salt['cmd.run']("stat -f '%Sg' /dev/console") %} 16 | {%- endif %} 17 | 18 | Arch: 19 | wanted: 20 | firewall: false 21 | pkg: 22 | deps: 23 | - tar 24 | - curl 25 | - openssl 26 | 27 | Alpine: {} 28 | 29 | Debian: 30 | wanted: 31 | firewall: false 32 | pkg: 33 | deps: 34 | - curl 35 | - openssl 36 | - tar 37 | - unzip 38 | repo: 39 | file: /etc/apt/sources.list.d/mongodb-org-REL.list 40 | from_repo_value: {{ '' if 'oscodename' not in grains else grains.oscodename }} 41 | keyid: 9DA31620334BD75D9DCB49F368818C72E52529D4 42 | keyserver: hkp://keyserver.ubuntu.com:80 43 | {%- if 'oscodename' in grains %} 44 | # yamllint disable-line rule:line-length 45 | name: deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/{{ grains.os_family|lower }} {{ grains.oscodename }}/mongodb-org/REL {{ 'main' if grains.os in ('Debian',) else 'multiverse' }} 46 | # yamllint enable-line rule:line-length 47 | {%- endif %} 48 | database: 49 | mongod: 50 | name: mongodb-org 51 | use_upstream: 'archive' # using 'repo' caused a conflict 52 | gui: 53 | compass: 54 | use_upstream: native 55 | native: 56 | source: https://downloads.mongodb.com/compass/mongodb-compass-community_VER_amd64.deb 57 | source_hash: 8101ae6c2294072090751c7226dd0ee0467f65217bf68886a9b8b6b1f3441bc8 58 | skip_verify: false 59 | 60 | RedHat: 61 | wanted: 62 | firewall: false # turned off for travis ci 63 | selinux: false # turrned off for travs citrue 64 | default: 65 | user: mongod 66 | group: mongod 67 | pkg: 68 | deps: 69 | - python2-pip 70 | - libcurl 71 | - openssl 72 | - tar 73 | - unzip 74 | - {{ 'policycoreutils' if grains.osrelease|int >= 8 else 'policycoreutils-python' }} 75 | - selinux-policy-targeted 76 | repo: 77 | # yamllint disable-line rule:line-length 78 | basesource: https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/REL/$basearch 79 | name: mongodb-org-REL 80 | humanname: MongoDB REL Repository 81 | gpgkey: https://www.mongodb.org/static/pgp/server-REL.asc 82 | from_repo_value: '' 83 | database: 84 | mongod: 85 | {%- if 'osfinger' in grains and 'amazon' in grains.osfinger|lower %} 86 | use_upstream: 'archive' 87 | {%- else %} 88 | use_upstream: 'repo' 89 | {%- endif %} 90 | user: mongod 91 | group: mongod 92 | gui: 93 | compass: 94 | use_upstream: native 95 | native: 96 | source: https://downloads.mongodb.com/compass/mongodb-compass-community-VER.ARCH.rpm 97 | source_hash: ee4ab84302710686e8bec0309c68de5ab49d85a77b60e244a63be3e0e93562ca 98 | skip_verify: false 99 | connectors: 100 | bi: 101 | user: mongod 102 | group: mongod 103 | 104 | Suse: {} 105 | 106 | Gentoo: {} 107 | 108 | FreeBSD: 109 | identity: 110 | rootgroup: wheel 111 | 112 | OpenBSD: 113 | identity: 114 | rootgroup: wheel 115 | kernel: openbsd 116 | 117 | Solaris: {} 118 | 119 | Windows: 120 | wanted: 121 | disable_transparent_hugepages: false 122 | dir: 123 | archive: C:\\Program Files\\MongoDB 124 | pkg: 125 | gui: 126 | robo3t: 127 | archive: 128 | source: https://download-test.robomongo.org/windows/robo3t-VER-windows-ARCH-7419c406.zip 129 | skip_verify: true 130 | 131 | MacOS: 132 | wanted: 133 | disable_transparent_hugepages: false 134 | dir: 135 | default: /etc/defaults 136 | homes: /Users 137 | identity: 138 | user: {{ macos_rootuser | d('') }} 139 | rootuser: {{ macos_rootuser | d('') }} 140 | rootgroup: {{ macos_rootgroup | d('') }} 141 | pkg: 142 | deps: 143 | - curl 144 | database: 145 | mongod: 146 | service: 147 | name: org.mongo.mongodb.mongod 148 | archive: 149 | source: https://fastdl.mongodb.org/osx/mongodb-macos-ARCH-VER.tgz 150 | source_hash: 701fda6ab0b49121913204596d527d89d4a533a3a7d1ca2f245c7908e1342c5b 151 | mongos: 152 | service: 153 | name: org.mongo.mongodb.mongos 154 | dbtools: 155 | use_upstream: archive 156 | archive: 157 | source: https://fastdl.mongodb.org/tools/db/mongodb-database-tools-macos-ARCH-VER.tgz 158 | shell: 159 | use_upstream: archive 160 | archive: 161 | source: https://fastdl.mongodb.org/osx/mongodb-macos-ARCH-VER.tgz 162 | skip_verify: true 163 | gui: 164 | compass: 165 | name: MongoDB Compass Community 166 | use_upstream: macapp 167 | macapp: 168 | source: https://downloads.mongodb.com/compass/mongodb-compass-community-VER-darwin-x64.dmg 169 | source_hash: af2840d0a71a15d01160b547766cd291acc2f15955f1dee1ac79cc9db60153ba 170 | skip_verify: true 171 | robo3t: 172 | name: Robo 3T 173 | use_upstream: macapp 174 | macapp: 175 | source: https://download-test.robomongo.org/mac/robo3t-VER-darwin-ARCH-7419c40.dmg 176 | skip_verify: true 177 | -------------------------------------------------------------------------------- /mongodb/osfingermap.yaml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | {% macro m(name, uri, oscode) %} 5 | {{ uriname|default(name, true) }}: 6 | pkg: 7 | database: 8 | mongod: 9 | use_upstream: archive 10 | archive: 11 | source: https://fastdl.mongodb.org/linux/mongodb-linux-ARCH-{{ oscode }}-VER.tgz 12 | source_hash: https://fastdl.mongodb.org/linux/mongodb-linux-ARCH-{{ oscode }}-VER.tgz.sha256 13 | native: 14 | source: https://repo.mongodb.org/{{ uri|replace('COMP', 'mongodb-org-server') }} 15 | skip_verify: true 16 | dbtools: 17 | use_upstream: archive 18 | archive: 19 | source: https://fastdl.mongodb.org/tools/db/mongodb-database-tools-{{ oscode }}-ARCH-VER.tgz # noqa 204 20 | skip_verify: true 21 | shell: 22 | # use_upstream: native # Debian 10 error: 'LookupError There is no member named control' 23 | native: 24 | source: https://repo.mongodb.org/{{ uri|replace('COMP', 'mongodb-org-shell') }} 25 | skip_verify: true 26 | connectors: 27 | bi: 28 | use_upstream: archive 29 | archive: 30 | source: https://info-mongodb-com.s3.amazonaws.com/mongodb-bi/v2/mongodb-bi-linux-ARCH-{{ oscode }}-vVER.tgz # noqa 204 31 | source_hash: https://info-mongodb-com.s3.amazonaws.com/mongodb-bi/v2/mongodb-bi-linux-ARCH-{{ oscode }}-vVER.tgz.sha256 # noqa 204 32 | 33 | {% endmacro %} 34 | 35 | {# native sources: https://www.mongodb.com/download-center/community #} 36 | {{ m('Amazon-2', 'yum/amazon/2/mongodb-org/REL/ARCH/RPMS/COMP-VER.amzn2.ARCH.rpm', 'amazon2') }} 37 | {{ m('CentOS Linux-6', 'yum/redhat/6/mongodb-org/REL/ARCH/RPMS/COMP-VER.el6.ARCH.rpm', 'rhel62') }} 38 | {{ m('CentOS Linux-7', 'yum/redhat/7/mongodb-org/REL/ARCH/RPMS/COMP-VER.el7.ARCH.rpm', 'rhel70') }} 39 | {{ m('CentOS Linux-8', 'um/redhat/8/mongodb-org/REL/ARCH/RPMS/COMP-VER.el8.ARCH.rpm', 'rhel80') }} 40 | {{ m('Fedora-31', 'yum/redhat/8/mongodb-org/REL/ARCH/RPMS/COMP-VER.el8.ARCH.rpm', 'rhel80') }} 41 | {{ m('Fedora-32', 'yum/redhat/8/mongodb-org/REL/ARCH/RPMS/COMP-VER.el8.ARCH.rpm', 'rhel80') }} 42 | {{ m('Fedora-33', 'yum/redhat/8/mongodb-org/REL/ARCH/RPMS/COMP-VER.el8.ARCH.rpm', 'rhel80') }} 43 | {{ m('Leap-15', 'zypper/suse/15/mongodb-org/REL/ARCH/RPMS/COMP-VER.suse15.ARCH.rpm', 'suse15') }} 44 | {{ m('Suse', 'zypper/suse/12/mongodb-org/REL/ARCH/RPMS/COMP-VER.suse12.ARCH.rpm', 'suse12') }} 45 | {{ m('Debian-9', 'apt/debian/dists/stretch/mongodb-org/REL/main/binary-amd64/COMP_VER_amd64.deb', 'debian92') }} 46 | {{ m('Debian-10', 'apt/debian/dists/buster/mongodb-org/REL/main/binary-amd64/COMP_VER_amd64.deb', 'debian10') }} 47 | 48 | {{ m('Ubuntu-16.04', 'apt/ubuntu/dists/xenial/mongodb-org/REL/multiverse/binary-amd64/COMP_VER_amd64.deb', 'ubuntu1604') }} # noqa 204 49 | {{ m('Ubuntu-18.04', 'apt/ubuntu/dists/bionic/mongodb-org/REL/multiverse/binary-amd64/COMP_VER_amd64.deb', 'ubuntu1804') }} # noqa 204 50 | {{ m('Ubuntu-20.04', 'apt/ubuntu/dists/bionic/mongodb-org/REL/multiverse/binary-amd64/COMP_VER_amd64.deb', 'ubuntu2004') }} # noqa 204 51 | -------------------------------------------------------------------------------- /mongodb/service/clean.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import data as d with context %} 6 | {%- set sls_config_clean = tplroot ~ '.config.clean' %} 7 | {%- set formula = d.formula %} 8 | 9 | include: 10 | - {{ sls_config_clean }} 11 | 12 | {%- for comp in d.componentypes %} 13 | {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} 14 | {%- for name,v in d.pkg[comp].items() %} 15 | {%- if name in d.wanted[comp] %} 16 | {%- set software = d.pkg[comp][name] %} 17 | {%- if 'service' in software and software['service'] is mapping %} 18 | {%- if 'config' in software and software['config'] is mapping %} 19 | {%- set config = software['config'] %} 20 | {%- set servicename = name if 'service' not in software else software.service.name %} 21 | 22 | {{ formula }}-service-dead-{{ comp }}-{{ servicename }}-clean: 23 | {%- if grains.kernel|lower == 'darwin' %} {# service.running is buggy #} 24 | cmd.run: 25 | - names: 26 | - launchctl stop {{ servicename }} || true 27 | - launchctl unload /Library/LaunchAgents/{{ servicename }}.plist || true 28 | {%- else %} 29 | service.dead: 30 | - name: {{ servicename }} 31 | {% if grains.kernel|lower == 'linux' %} 32 | - onlyif: systemctl list-units |grep {{ servicename }} >/dev/null 2>&1 33 | {%- endif %} {# linux #} 34 | - enable: False 35 | {%- endif %} 36 | - require_in: 37 | - sls: {{ sls_config_clean }} 38 | file.absent: 39 | - names: 40 | - {{ d.dir.service }}/{{ servicename }}.service 41 | - /etc/logrotate.d/{{ formula }}_{{ servicename }} 42 | {%- if 'systemLog' in config and 'destination' in config['systemLog'] %} 43 | {%- if config['systemLog']['destination'] == 'file' %} 44 | - {{ config['systemLog']['path'] }} 45 | {%- else %} 46 | - {{ '/var/log/mongodb/' ~ servicename ~ '.log' }} 47 | {%- endif %} 48 | {%- endif %} 49 | - require_in: 50 | - sls: {{ sls_config_clean }} 51 | {% if grains.kernel|lower == 'linux' %} 52 | cmd.run: 53 | - name: systemctl daemon-reload 54 | - watch: 55 | - file: {{ formula }}-service-dead-{{ comp }}-{{ servicename }}-clean 56 | {%- endif %} {# linux #} 57 | 58 | {{ formula }}-service-dead-{{ comp }}-{{ servicename }}-clean-dirs: 59 | file.absent: 60 | - names: 61 | - /tmp/MySiLydUmMyFiLE 62 | {%- if 'processManagement' in config and 'pidFilePath' in config['processManagement'] %} 63 | - {{ config['processManagement']['pidFilePath'] }} 64 | {%- else %} 65 | - {{ '/var/run/{{ name }}.pid' }} 66 | {%- endif %} 67 | {%- if 'storage' in config and 'dbPath' in config['storage'] %} 68 | - {{ config['storage']['dbPath'] }} 69 | {%- endif %} 70 | {%- if 'schema' in config and 'path' in config['schema'] %} 71 | - {{ config['schema']['path'] }} 72 | {%- endif %} 73 | {%- if 'systemLog' in config and 'path' in config['systemLog'] %} 74 | - {{ config['systemLog']['path'] }} 75 | {%- endif %} 76 | - require_in: 77 | - sls: {{ sls_config_clean }} 78 | 79 | {%- endif %} {# service #} 80 | {%- endif %} {# service #} 81 | {%- endif %} {# wanted #} 82 | {%- endfor %} {# component #} 83 | {%- endif %} {# wanted #} 84 | {%- endfor %} {# components #} 85 | -------------------------------------------------------------------------------- /mongodb/service/init.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | include: 5 | - .running 6 | -------------------------------------------------------------------------------- /mongodb/service/running.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import data as d with context %} 6 | {%- set sls_config_users = tplroot ~ '.config.users' %} 7 | {%- set sls_software_install = tplroot ~ '.install' %} 8 | {%- set formula = d.formula %} 9 | 10 | include: 11 | - {{ sls_config_users }} 12 | - {{ sls_software_install }} 13 | 14 | {%- if grains.kernel|lower == 'linux' %} 15 | {{ formula }}-service-running-prerequisites: 16 | file.managed: 17 | - name: /etc/init.d/disable-transparent-hugepages 18 | - source: salt://{{ formula }}/files/disable-transparent-hugepages.init 19 | - unless: test -f /etc/init.d/disable-transparent-hugepages 2>/dev/null 20 | - onlyif: {{ d.wanted.disable_transparent_hugepages }} 21 | - mode: '0755' 22 | - makedirs: True 23 | - require: 24 | - sls: {{ sls_software_install }} 25 | - sls: {{ sls_config_users }} 26 | cmd.run: 27 | - name: echo never >/sys/kernel/mm/transparent_hugepage/enabled 28 | - onlyif: {{ d.wanted.disable_transparent_hugepages }} 29 | - require: 30 | - file: {{ formula }}-service-running-prerequisites 31 | {%- if d.wanted.firewall %} 32 | pkg.installed: 33 | - name: firewalld 34 | - reload_modules: true 35 | service.running: 36 | - name: firewalld 37 | - onlyif: systemctl list-units | grep firewalld >/dev/null 2>&1 38 | - enable: True 39 | {%- endif %} 40 | {%- endif %} 41 | 42 | {%- for comp in d.componentypes %} 43 | {%- if comp in d.wanted and d.wanted is iterable and comp in d.pkg and d.pkg[comp] is mapping %} 44 | {%- for name,v in d.pkg[comp].items() %} 45 | {%- if name in d.wanted[comp] %} 46 | {%- set software = d.pkg[comp][name] %} 47 | {%- if 'service' in software and software['service'] is mapping %} 48 | {%- set service = software['service'] %} 49 | {%- set servicename = name if 'name' not in service else service.name %} 50 | {%- if 'config' in software and software['config'] is mapping %} 51 | {%- set config = software['config'] %} 52 | 53 | {%- set service_files = [] %} 54 | {%- if 'processManagement' in config and 'pidFilePath' in config['processManagement'] %} 55 | {%- do service_files.append(config['processManagement']['pidFilePath']) %} 56 | 57 | {{ formula }}-service-running-{{ comp }}-{{ servicename }}-install-pidpath: 58 | file.directory: 59 | - name: {{ config['processManagement']['pidFilePath'] }} 60 | - user: {{ software['user'] }} 61 | - group: {{ software['group'] }} 62 | - dir_mode: '0775' 63 | - makedirs: True 64 | - require: 65 | - sls: {{ sls_config_users }} 66 | - sls: {{ sls_software_install }} 67 | - require_in: 68 | - service: {{ formula }}-service-running-{{ comp }}-{{ servicename }} 69 | - recurse: 70 | - user 71 | - group 72 | {%- if 'selinux' in d.wanted and d.wanted.selinux %} 73 | selinux.fcontext_policy_present: 74 | - name: '{{ config['processManagement']['pidFilePath'] }}(/.*)?' 75 | - sel_type: {{ name }}_var_t 76 | - require_in: 77 | - selinux: {{ formula }}-service-running-{{ comp }}-{{ servicename }}-selinux-applied 78 | {%- endif %} 79 | 80 | {%- endif %} 81 | {%- if 'storage' in config and 'dbPath' in config['storage'] %} 82 | {%- do service_files.append(config['storage']['dbPath']) %} 83 | 84 | {{ formula }}-service-running-{{ comp }}-{{ servicename }}-install-datapath: 85 | file.directory: 86 | - name: {{ config['storage']['dbPath'] }} 87 | - user: {{ software['user'] }} 88 | - group: {{ software['group'] }} 89 | - dir_mode: '0775' 90 | - makedirs: True 91 | - recurse: 92 | - user 93 | - group 94 | - require: 95 | - sls: {{ sls_config_users }} 96 | - unless: test -d {{ config['storage']['dbPath'] }} 97 | - require_in: 98 | - service: {{ formula }}-service-running-{{ comp }}-{{ servicename }} 99 | {%- if 'selinux' in d.wanted and d.wanted.selinux %} 100 | selinux.fcontext_policy_present: 101 | - name: '{{ config['storage']['dbPath'] }}(/.*)?' 102 | - sel_type: {{ name }}_var_lib_t 103 | - onchanges: 104 | - file: {{ formula }}-service-running-{{ comp }}-{{ servicename }}-install-datapath 105 | - require_in: 106 | - selinux: {{ formula }}-service-running-{{ comp }}-{{ servicename }}-selinux-applied 107 | {%- endif %} 108 | 109 | {%- endif %} 110 | {%- if 'schema' in config and 'path' in config['schema'] %} 111 | {%- do service_files.append(config['schema']['path']) %} 112 | 113 | {{ formula }}-service-running-{{ comp }}-{{ servicename }}-install-schemapath: 114 | file.directory: 115 | - name: {{ config['schema']['path'] }} 116 | - user: {{ software['user'] }} 117 | - group: {{ software['group'] }} 118 | - dir_mode: '0775' 119 | - makedirs: True 120 | - recurse: 121 | - user 122 | - group 123 | - require: 124 | - sls: {{ sls_config_users }} 125 | - require_in: 126 | - service: {{ formula }}-service-running-{{ comp }}-{{ servicename }} 127 | {%- if 'selinux' in d.wanted and d.wanted.selinux %} 128 | selinux.fcontext_policy_present: 129 | - name: '{{ config['schema']['path'] }}(/.*)?' 130 | - sel_type: etc_t 131 | - require: 132 | - file: {{ formula }}-service-running-{{ comp }}-{{ servicename }}-install-schemapath 133 | - require_in: 134 | - selinux: {{ formula }}-service-running-{{ comp }}-{{ servicename }}-selinux-applied 135 | {%- endif %} 136 | 137 | {%- endif %} 138 | {%- set path = '/var/log/mongodb/' ~ servicename ~ '.log' %} 139 | {%- if 'systemLog' in config and 'destination' in config['systemLog'] %} 140 | {%- if config['systemLog']['destination'] == 'file' %} 141 | {%- if 'path' in config['systemLog'] %} 142 | {%- set path = config['systemLog']['path'] %} 143 | {%- endif %} 144 | {%- endif %} 145 | {%- endif %} 146 | {%- do service_files.append(path) %} 147 | 148 | {{ formula }}-service-running-{{ comp }}-{{ servicename }}-install-syslogpath: 149 | file.directory: 150 | - name: {{ salt['cmd.run']( 'dirname ' ~ path ) }} 151 | - user: {{ software['user'] }} 152 | - group: {{ software['group'] }} 153 | - dir_mode: '0775' 154 | - makedirs: True 155 | - require: 156 | - sls: {{ sls_config_users }} 157 | - recurse: 158 | - user 159 | - group 160 | 161 | {{ formula }}-service-running-{{ comp }}-{{ servicename }}-install-syslogfile: 162 | file.managed: 163 | - name: {{ path }} 164 | - user: {{ software['user'] }} 165 | - group: {{ software['group'] }} 166 | - mode: '0775' 167 | - create: true 168 | - replace: false 169 | - require: 170 | - file: {{ formula }}-service-running-{{ comp }}-{{ servicename }}-install-syslogpath 171 | - require_in: 172 | - service: {{ formula }}-service-running-{{ comp }}-{{ servicename }} 173 | {%- if 'selinux' in d.wanted and d.wanted.selinux %} 174 | selinux.fcontext_policy_present: 175 | - name: {{ salt['cmd.run']( 'dirname ' ~ path ) }}'(/.*)?' 176 | - sel_type: {{ name }}_var_log_t 177 | - require_in: 178 | - selinux: {{ formula }}-service-running-{{ comp }}-{{ servicename }}-selinux-applied 179 | {%- endif %} 180 | 181 | {{ formula }}-service-running-{{ comp }}-{{ servicename }}-install-logrotate: 182 | file.managed: 183 | - name: /etc/logrotate.d/{{ formula }}_{{ name }} 184 | - unless: ls /etc/logrotate.d/{{ formula }}_{{ name }} 185 | - user: root 186 | - group: {{ 'wheel' if grains.os in ('MacOS',) else 'root' }} 187 | - mode: '0440' 188 | - makedirs: True 189 | - source: salt://{{ formula }}/files/default/logrotate.jinja 190 | - context: 191 | svc: {{ name }} 192 | pattern: {{ salt['cmd.run']( 'dirname ' ~ path ) }} 193 | {%- if 'processManagement' in config and 'pidFilePath' in config['processManagement'] %} 194 | pidpath: {{ config['processManagement']['pidFilePath'] }} 195 | {%- else %} 196 | pidpath: {{ '/var/run/{{ name }}.pid' }} 197 | {%- endif %} 198 | days: 7 199 | - require_in: 200 | - service: {{ formula }}-service-running-{{ comp }}-{{ servicename }} 201 | {%- if 'selinux' in d.wanted and d.wanted.selinux %} 202 | selinux.fcontext_policy_present: 203 | - name: '/etc/logrotate.d/{{ formula }}_{{ svc }}(/.*)?' 204 | - sel_type: etc_t 205 | - require_in: 206 | - selinux: {{ formula }}-service-running-{{ comp }}-{{ servicename }}-selinux-applied 207 | - recursive: True 208 | {%- endif %} 209 | 210 | {%- if 'selinux' in d.wanted and d.wanted.selinux %} 211 | {{ formula }}-service-running-{{ comp }}-{{ servicename }}-selinux-applied: 212 | selinux.fcontext_policy_applied: 213 | - names: {{ service_files|json }} 214 | - require_in: 215 | - service: {{ formula }}-service-running-{{ comp }}-{{ servicename }} 216 | {%- endif %} 217 | 218 | {%- endif %} {# config #} 219 | {%- if grains.kernel == 'Linux' and d.wanted.firewall and 'firewall' in software %} 220 | 221 | {{ formula }}-service-running-{{ comp }}-{{ servicename }}-firewall-present: 222 | firewalld.present: 223 | - name: public 224 | - ports: {{ software['firewall']['ports']|json }} 225 | {%- if grains.kernel|lower == 'linux' %} 226 | - require: 227 | - pkg: {{ formula }}-service-running-prerequisites 228 | - service: {{ formula }}-service-running-prerequisites 229 | {%- endif %} 230 | - require_in: 231 | - service: {{ formula }}-service-running-{{ comp }}-{{ servicename }} 232 | {%- endif %} {# firewall #} 233 | 234 | {{ formula }}-service-running-{{ comp }}-{{ servicename }}-unmasked: 235 | service.unmasked: 236 | - name: {{ servicename }} 237 | - onlyif: 238 | - {{ grains.kernel|lower == 'linux' }} 239 | - systemctl list-units | grep {{ servicename }} >/dev/null 2>&1 240 | - require: 241 | - sls: {{ sls_software_install }} 242 | - sls: {{ sls_config_users }} 243 | - require_in: 244 | - service: {{ formula }}-service-running-{{ comp }}-{{ servicename }} 245 | 246 | {{ formula }}-service-running-{{ comp }}-{{ servicename }}: 247 | {%- if grains.kernel|lower == 'darwin' %} {# service.running is buggy #} 248 | cmd.run: 249 | - names: 250 | - launchctl load /Library/LaunchAgents/{{ servicename }}.plist || true 251 | - launchctl start {{ servicename }} 252 | {%- else %} 253 | service.running: 254 | - name: {{ servicename }} 255 | - enable: True 256 | - onlyif: systemctl list-units | grep {{ servicename }} >/dev/null 2>&1 257 | {%- endif %} 258 | - require: 259 | - sls: {{ sls_software_install }} 260 | - sls: {{ sls_config_users }} 261 | {%- if 'config' in software and software['config'] is mapping %} 262 | - watch: 263 | - file: {{ formula }}-config-file-{{ servicename }}-file-managed 264 | {%- endif %} 265 | 266 | {%- endif %} {# service #} 267 | {%- endif %} {# wanted #} 268 | {%- endfor %} {# component #} 269 | {%- endif %} {# wanted #} 270 | {%- endfor %} {# components #} 271 | -------------------------------------------------------------------------------- /pillar.example: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | mongodb: 5 | wanted: 6 | # choose what you want 7 | database: 8 | - mongod 9 | - mongos 10 | # dbtools 11 | # shell 12 | gui: 13 | - robo3t 14 | {%- if grains.kernel|lower == 'darwin' %} 15 | - compass # mongodb compass upstream rpm/deb packages has gui dependencies 16 | {%- endif %} 17 | connectors: 18 | # bi # enterprise subscription only 19 | - kafka 20 | 21 | pkg: 22 | deps: 23 | - python-pip 24 | 25 | database: 26 | dbtools: 27 | version: 100.0.1 28 | archive: 29 | skip_verify: true 30 | shell: 31 | archive: 32 | skip_verify: true 33 | mongod: 34 | version: 4.2.6.1 35 | archive: 36 | skip_verify: true 37 | config: 38 | # http://docs.mongodb.org/manual/reference/configuration-options 39 | storage: 40 | dbPath: /var/lib/mongodb/mongod 41 | replication: 42 | replSetName: "rs1" 43 | sharding: 44 | clusterRole: shardsvr 45 | net: 46 | bindIp: {{ grains.ipv4[-1] or grains.ipv6[-1] or '0.0.0.0,::' }} 47 | port: 27018 48 | firewall: 49 | ports: 50 | - tcp/27017 51 | - tcp/27018 52 | - tcp/27019 53 | mongos: 54 | config: 55 | net: 56 | bindIp: '{{ grains.ipv4[-1] or grains.ipv6[-1] or '0.0.0.0' }}' 57 | net: 58 | sharding: 59 | configDB: 'rs1/{{ grains.ipv4[-1] or grains.ipv6[-1] }}:27018' 60 | firewall: 61 | ports: 62 | - tcp/9093 63 | # tcp/9094 64 | gui: 65 | compass: 66 | version: 1.21.2 67 | archive: 68 | skip_verify: true 69 | robo3t: 70 | version: 1.3.1 71 | connectors: 72 | bi: 73 | version: 2.13.4 74 | archive: 75 | skip_verify: true 76 | service: 77 | name: mongosqld 78 | firewall: 79 | ports: tcp/29017 80 | kafka: 81 | version: 1.1.0 82 | archive: 83 | skip_verify: true 84 | spark: 85 | name: mongo-spark 86 | version: 2.4.1 87 | archive: 88 | skip_verify: true 89 | 90 | # Just here for testing 91 | added_in_defaults: pillar_value 92 | winner: pillar 93 | 94 | linux: 95 | altpriority: 10000 96 | -------------------------------------------------------------------------------- /pre-commit_semantic-release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ############################################################################### 4 | # (A) Update `FORMULA` with `${nextRelease.version}` 5 | ############################################################################### 6 | sed -i -e "s_^\(version:\).*_\1 ${1}_" FORMULA 7 | 8 | 9 | ############################################################################### 10 | # (B) Use `m2r2` to convert automatically produced `.md` docs to `.rst` 11 | ############################################################################### 12 | 13 | # Install `m2r2` 14 | pip3 install m2r2 15 | 16 | # Copy and then convert the `.md` docs 17 | cp ./*.md docs/ 18 | cd docs/ || exit 19 | m2r2 --overwrite ./*.md 20 | 21 | # Change excess `H1` headings to `H2` in converted `CHANGELOG.rst` 22 | sed -i -e '/^=.*$/s/=/-/g' CHANGELOG.rst 23 | sed -i -e '1,4s/-/=/g' CHANGELOG.rst 24 | 25 | # Use for debugging output, when required 26 | # cat AUTHORS.rst 27 | # cat CHANGELOG.rst 28 | 29 | # Return back to the main directory 30 | cd .. 31 | -------------------------------------------------------------------------------- /release-rules.js: -------------------------------------------------------------------------------- 1 | // No release is triggered for the types commented out below. 2 | // Commits using these types will be incorporated into the next release. 3 | // 4 | // NOTE: Any changes here must be reflected in `CONTRIBUTING.md`. 5 | module.exports = [ 6 | {breaking: true, release: 'major'}, 7 | // {type: 'build', release: 'patch'}, 8 | // {type: 'chore', release: 'patch'}, 9 | // {type: 'ci', release: 'patch'}, 10 | {type: 'docs', release: 'patch'}, 11 | {type: 'feat', release: 'minor'}, 12 | {type: 'fix', release: 'patch'}, 13 | {type: 'perf', release: 'patch'}, 14 | {type: 'refactor', release: 'patch'}, 15 | {type: 'revert', release: 'patch'}, 16 | {type: 'style', release: 'patch'}, 17 | {type: 'test', release: 'patch'}, 18 | ]; 19 | -------------------------------------------------------------------------------- /release.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | branch: 'master', 3 | repositoryUrl: 'https://github.com/saltstack-formulas/mongodb-formula', 4 | plugins: [ 5 | ['@semantic-release/commit-analyzer', { 6 | preset: 'angular', 7 | releaseRules: './release-rules.js', 8 | }], 9 | '@semantic-release/release-notes-generator', 10 | ['@semantic-release/changelog', { 11 | changelogFile: 'CHANGELOG.md', 12 | changelogTitle: '# Changelog', 13 | }], 14 | ['@semantic-release/exec', { 15 | prepareCmd: 'sh ./pre-commit_semantic-release.sh ${nextRelease.version}', 16 | }], 17 | ['@semantic-release/git', { 18 | assets: ['*.md', 'docs/*.rst', 'FORMULA'], 19 | }], 20 | '@semantic-release/github', 21 | ], 22 | generateNotes: { 23 | preset: 'angular', 24 | writerOpts: { 25 | // Required due to upstream bug preventing all types being displayed. 26 | // Bug: https://github.com/conventional-changelog/conventional-changelog/issues/317 27 | // Fix: https://github.com/conventional-changelog/conventional-changelog/pull/410 28 | transform: (commit, context) => { 29 | const issues = [] 30 | 31 | commit.notes.forEach(note => { 32 | note.title = `BREAKING CHANGES` 33 | }) 34 | 35 | // NOTE: Any changes here must be reflected in `CONTRIBUTING.md`. 36 | if (commit.type === `feat`) { 37 | commit.type = `Features` 38 | } else if (commit.type === `fix`) { 39 | commit.type = `Bug Fixes` 40 | } else if (commit.type === `perf`) { 41 | commit.type = `Performance Improvements` 42 | } else if (commit.type === `revert`) { 43 | commit.type = `Reverts` 44 | } else if (commit.type === `docs`) { 45 | commit.type = `Documentation` 46 | } else if (commit.type === `style`) { 47 | commit.type = `Styles` 48 | } else if (commit.type === `refactor`) { 49 | commit.type = `Code Refactoring` 50 | } else if (commit.type === `test`) { 51 | commit.type = `Tests` 52 | } else if (commit.type === `build`) { 53 | commit.type = `Build System` 54 | // } else if (commit.type === `chore`) { 55 | // commit.type = `Maintenance` 56 | } else if (commit.type === `ci`) { 57 | commit.type = `Continuous Integration` 58 | } else { 59 | return 60 | } 61 | 62 | if (commit.scope === `*`) { 63 | commit.scope = `` 64 | } 65 | 66 | if (typeof commit.hash === `string`) { 67 | commit.shortHash = commit.hash.substring(0, 7) 68 | } 69 | 70 | if (typeof commit.subject === `string`) { 71 | let url = context.repository 72 | ? `${context.host}/${context.owner}/${context.repository}` 73 | : context.repoUrl 74 | if (url) { 75 | url = `${url}/issues/` 76 | // Issue URLs. 77 | commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => { 78 | issues.push(issue) 79 | return `[#${issue}](${url}${issue})` 80 | }) 81 | } 82 | if (context.host) { 83 | // User URLs. 84 | commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => { 85 | if (username.includes('/')) { 86 | return `@${username}` 87 | } 88 | 89 | return `[@${username}](${context.host}/${username})` 90 | }) 91 | } 92 | } 93 | 94 | // remove references that already appear in the subject 95 | commit.references = commit.references.filter(reference => { 96 | if (issues.indexOf(reference.issue) === -1) { 97 | return true 98 | } 99 | 100 | return false 101 | }) 102 | 103 | return commit 104 | }, 105 | }, 106 | }, 107 | }; 108 | -------------------------------------------------------------------------------- /test/integration/default/README.md: -------------------------------------------------------------------------------- 1 | # InSpec Profile: `default` 2 | 3 | This shows the implementation of the `default` InSpec [profile](https://github.com/inspec/inspec/blob/master/docs/profiles.md). 4 | 5 | ## Verify a profile 6 | 7 | InSpec ships with built-in features to verify a profile structure. 8 | 9 | ```bash 10 | $ inspec check default 11 | Summary 12 | ------- 13 | Location: default 14 | Profile: profile 15 | Controls: 4 16 | Timestamp: 2019-06-24T23:09:01+00:00 17 | Valid: true 18 | 19 | Errors 20 | ------ 21 | 22 | Warnings 23 | -------- 24 | ``` 25 | 26 | ## Execute a profile 27 | 28 | To run all **supported** controls on a local machine use `inspec exec /path/to/profile`. 29 | 30 | ```bash 31 | $ inspec exec default 32 | .. 33 | 34 | Finished in 0.0025 seconds (files took 0.12449 seconds to load) 35 | 8 examples, 0 failures 36 | ``` 37 | 38 | ## Execute a specific control from a profile 39 | 40 | To run one control from the profile use `inspec exec /path/to/profile --controls name`. 41 | 42 | ```bash 43 | $ inspec exec default --controls package 44 | . 45 | 46 | Finished in 0.0025 seconds (files took 0.12449 seconds to load) 47 | 1 examples, 0 failures 48 | ``` 49 | 50 | See an [example control here](https://github.com/inspec/inspec/blob/master/examples/profile/controls/example.rb). 51 | -------------------------------------------------------------------------------- /test/integration/default/controls/archive_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | control 'mongodb components' do 4 | title 'should be installed' 5 | 6 | # describe package('unzip') do 7 | # it { should be_installed } 8 | # end 9 | # describe group('mongodb') do 10 | # it { should exist } 11 | # end 12 | # describe user('mongodb') do 13 | # it { should exist } 14 | # end 15 | describe group('mongos') do 16 | it { should exist } 17 | end 18 | # describe user('mongos') do 19 | # it { should exist } 20 | # end 21 | describe directory('/var/lib/mongodb') do 22 | it { should exist } 23 | its('group') { should eq 'root' } 24 | end 25 | # describe directory('/usr/local/mongodb/dbtools-100.0.1') do 26 | # it { should exist } 27 | # its('group') { should eq 'root' } 28 | # end 29 | # describe file('/usr/local/mongodb/dbtools-100.0.1/bin/mongodump') do 30 | # it { should exist } 31 | # its('group') { should eq 'root' } 32 | # end 33 | # describe file('/usr/local/mongodb/dbtools-100.0.1/bin/bsondump') do 34 | # it { should exist } 35 | # its('group') { should eq 'root' } 36 | # end 37 | describe directory('/tmp/downloads') do 38 | it { should exist } 39 | end 40 | describe directory('/usr/local/mongodb/mongod-4.2.6') do 41 | it { should exist } 42 | its('group') { should eq 'root' } 43 | end 44 | describe file('/usr/local/mongodb/mongod-4.2.6/bin/mongod') do 45 | it { should exist } 46 | end 47 | describe file('/usr/local/mongodb/mongod-4.2.6/bin/mongos') do 48 | it { should exist } 49 | end 50 | describe directory('/var/lib/mongodb/mongod') do 51 | it { should exist } 52 | end 53 | describe file('/usr/lib/systemd/system/mongod.service') do 54 | it { should exist } 55 | its('group') { should eq 'root' } 56 | its('mode') { should cmp '0644' } 57 | end 58 | describe directory('/usr/local/mongodb/robo3t-1.3.1') do 59 | it { should exist } 60 | its('group') { should eq 'root' } 61 | end 62 | describe file('/usr/local/mongodb/robo3t-1.3.1/bin/robo3t') do 63 | it { should exist } 64 | its('group') { should eq 'root' } 65 | end 66 | describe directory('/usr/local/mongodb/robo3t-1.3.1/include') do 67 | it { should exist } 68 | its('group') { should eq 'root' } 69 | end 70 | describe directory('/usr/local/mongodb/kafka-1.1.0') do 71 | it { should exist } 72 | its('group') { should eq 'root' } 73 | end 74 | # describe file('/usr/lib/mongodb/kafka-1.1.0/lib/mongo-kafka-1.1.0-all.jar') do 75 | # it { should exist } 76 | # its('group') { should eq 'root' } 77 | # its('mode') { should cmp '0644' } 78 | # end 79 | describe file('/etc/init.d/disable-transparent-hugepages') do 80 | it { should exist } 81 | its('mode') { should cmp '0755' } 82 | end 83 | describe file('/sys/kernel/mm/transparent_hugepage/enabled') do 84 | it { should exist } 85 | its('group') { should eq 'root' } 86 | # its('content') { should eq 'always madvise [never]' } 87 | end 88 | describe file('/etc/mongodb') do 89 | it { should exist } 90 | its('owner') { should eq 'root' } 91 | its('group') { should eq 'root' } 92 | end 93 | describe file('/etc/mongodb/mongod.conf') do 94 | it { should exist } 95 | its('mode') { should cmp '0644' } 96 | # its('owner') { should eq 'mongodb' } 97 | # its('group') { should eq 'mongodb' } 98 | end 99 | describe file('/etc/mongodb/mongos.conf') do 100 | it { should exist } 101 | its('mode') { should cmp '0644' } 102 | its('owner') { should eq 'mongos' } 103 | its('group') { should eq 'mongos' } 104 | end 105 | describe file('/etc/default/mongod.sh') do 106 | it { should exist } 107 | its('mode') { should cmp '0640' } 108 | end 109 | end 110 | -------------------------------------------------------------------------------- /test/integration/default/inspec.yml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | name: default 5 | title: mongodb formula 6 | maintainer: SaltStack Formulas 7 | license: Apache-2.0 8 | summary: Verify that the mongodb formula is setup and configured correctly 9 | depends: 10 | - name: share 11 | path: test/integration/share 12 | supports: 13 | - platform-name: debian 14 | - platform-name: ubuntu 15 | - platform-name: centos 16 | - platform-name: fedora 17 | - platform-name: opensuse 18 | - platform-name: suse 19 | - platform-name: freebsd 20 | - platform-name: openbsd 21 | - platform-name: amazon 22 | - platform-name: oracle 23 | - platform-name: arch 24 | - platform-name: gentoo 25 | - platform-name: almalinux 26 | - platform-name: rocky 27 | - platform-name: mac_os_x 28 | - platform: windows 29 | -------------------------------------------------------------------------------- /test/integration/share/README.md: -------------------------------------------------------------------------------- 1 | # InSpec Profile: `share` 2 | 3 | This shows the implementation of the `share` InSpec [profile](https://github.com/inspec/inspec/blob/master/docs/profiles.md). 4 | 5 | Its goal is to share the libraries between all profiles. 6 | 7 | ## Libraries 8 | 9 | ### `system` 10 | 11 | The `system` library provides easy access to system dependent information: 12 | 13 | - `system.platform`: based on `inspec.platform`, modify to values that are more consistent from a SaltStack perspective 14 | - `system.platform[:family]` provide a family name for Arch and Gentoo 15 | - `system.platform[:name]` append `linux` to both `amazon` and `oracle`; ensure Windows platforms are resolved as simply `windows` 16 | - `system.platform[:release]` tweak Arch, Amazon Linux, Gentoo, openSUSE and Windows: 17 | - `Arch` is always `base-latest` 18 | - `Amazon Linux` release `2018` is resolved as `1` 19 | - `Gentoo` release is trimmed to its major version number and then the init system is appended (i.e. `sysv` or `sysd`) 20 | - `openSUSE` is resolved as `tumbleweed` if the `platform[:release]` is in date format 21 | - `Windows` uses the widely-used release number (e.g. `8.1` or `2019-server`) in place of the actual system release version 22 | - `system.platform[:finger]` is the concatenation of the name and the major release number (except for Ubuntu, which gives `ubuntu-20.04` for example) 23 | -------------------------------------------------------------------------------- /test/integration/share/inspec.yml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | name: share 5 | title: InSpec shared resources 6 | maintainer: SaltStack Formulas 7 | license: Apache-2.0 8 | summary: shared resources 9 | supports: 10 | - platform-name: debian 11 | - platform-name: ubuntu 12 | - platform-name: centos 13 | - platform-name: fedora 14 | - platform-name: opensuse 15 | - platform-name: suse 16 | - platform-name: freebsd 17 | - platform-name: openbsd 18 | - platform-name: amazon 19 | - platform-name: oracle 20 | - platform-name: arch 21 | - platform-name: gentoo 22 | - platform-name: almalinux 23 | - platform-name: rocky 24 | - platform-name: mac_os_x 25 | - platform: windows 26 | -------------------------------------------------------------------------------- /test/integration/share/libraries/system.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # system.rb -- InSpec resources for system values 4 | # Author: Daniel Dehennin 5 | # Copyright (C) 2020 Daniel Dehennin 6 | 7 | # rubocop:disable Metrics/ClassLength 8 | class SystemResource < Inspec.resource(1) 9 | name 'system' 10 | 11 | attr_reader :platform 12 | 13 | def initialize 14 | super 15 | @platform = build_platform 16 | end 17 | 18 | private 19 | 20 | def build_platform 21 | { 22 | family: build_platform_family, 23 | name: build_platform_name, 24 | release: build_platform_release, 25 | finger: build_platform_finger, 26 | codename: build_platform_codename 27 | } 28 | end 29 | 30 | def build_platform_family 31 | case inspec.platform[:name] 32 | when 'arch', 'gentoo' 33 | inspec.platform[:name] 34 | else 35 | inspec.platform[:family] 36 | end 37 | end 38 | 39 | def build_platform_name 40 | case inspec.platform[:name] 41 | when 'amazon', 'oracle', 'rocky' 42 | "#{inspec.platform[:name]}linux" 43 | when /^windows_/ 44 | inspec.platform[:family] 45 | else 46 | inspec.platform[:name] 47 | end 48 | end 49 | 50 | # rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity 51 | def build_platform_release 52 | case inspec.platform[:name] 53 | when 'amazon' 54 | # `2018` relase is named `1` in `kitchen.yml` 55 | inspec.platform[:release].gsub(/2018.*/, '1') 56 | when 'arch' 57 | 'base-latest' 58 | when 'gentoo' 59 | "#{inspec.platform[:release].split('.')[0]}-#{derive_gentoo_init_system}" 60 | when 'mac_os_x' 61 | inspec.command('sw_vers -productVersion').stdout.to_s 62 | when 'opensuse' 63 | # rubocop:disable Style/NumericLiterals,Layout/LineLength 64 | inspec.platform[:release].to_i > 20210101 ? 'tumbleweed' : inspec.platform[:release] 65 | # rubocop:enable Style/NumericLiterals,Layout/LineLength 66 | when 'windows_8.1_pro' 67 | '8.1' 68 | when 'windows_server_2022_datacenter' 69 | '2022-server' 70 | when 'windows_server_2019_datacenter' 71 | '2019-server' 72 | when 'windows_server_2016_datacenter' 73 | '2016-server' 74 | else 75 | inspec.platform[:release] 76 | end 77 | end 78 | # rubocop:enable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity 79 | 80 | def derive_gentoo_init_system 81 | inspec.command('systemctl').exist? ? 'sysd' : 'sysv' 82 | end 83 | 84 | def build_platform_finger 85 | "#{build_platform_name}-#{build_finger_release}" 86 | end 87 | 88 | def build_finger_release 89 | case inspec.platform[:name] 90 | when 'ubuntu' 91 | build_platform_release.split('.').slice(0, 2).join('.') 92 | else 93 | build_platform_release.split('.')[0] 94 | end 95 | end 96 | 97 | # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity 98 | def build_platform_codename 99 | case build_platform_finger 100 | when 'ubuntu-22.04' 101 | 'jammy' 102 | when 'ubuntu-20.04' 103 | 'focal' 104 | when 'ubuntu-18.04' 105 | 'bionic' 106 | when 'debian-11' 107 | 'bullseye' 108 | when 'debian-10' 109 | 'buster' 110 | when 'debian-9' 111 | 'stretch' 112 | when 'almalinux-8' 113 | "AlmaLinux #{build_platform_release} (Arctic Sphynx)" 114 | when 'amazonlinux-2' 115 | 'Amazon Linux 2' 116 | when 'arch-base-latest' 117 | 'Arch Linux' 118 | when 'centos-7' 119 | 'CentOS Linux 7 (Core)' 120 | when 'centos-8' 121 | 'CentOS Stream 8' 122 | when 'opensuse-tumbleweed' 123 | 'openSUSE Tumbleweed' 124 | when 'opensuse-15' 125 | "openSUSE Leap #{build_platform_release}" 126 | when 'oraclelinux-8', 'oraclelinux-7' 127 | "Oracle Linux Server #{build_platform_release}" 128 | when 'gentoo-2-sysd', 'gentoo-2-sysv' 129 | 'Gentoo/Linux' 130 | when 'rockylinux-8' 131 | "Rocky Linux #{build_platform_release} (Green Obsidian)" 132 | else 133 | '' 134 | end 135 | end 136 | # rubocop:enable Metrics/MethodLength,Metrics/CyclomaticComplexity 137 | end 138 | # rubocop:enable Metrics/ClassLength 139 | -------------------------------------------------------------------------------- /test/salt/pillar/default.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | mongodb: 5 | wanted: 6 | # choose what you want 7 | database: 8 | - mongod 9 | - mongos 10 | - dbtools 11 | - shell 12 | gui: 13 | - robo3t 14 | {%- if grains.kernel|lower == 'darwin' %} 15 | - compass 16 | {%- endif %} 17 | connectors: 18 | # bi # enterprise advanced subscription 19 | - kafka 20 | upstream_repo: false 21 | linux: 22 | altpriority: 10000 23 | --------------------------------------------------------------------------------