├── .github └── workflows │ └── commitlint.yml ├── .gitignore ├── .kitchen.yml ├── .pre-commit-config.yaml ├── .rstcheck.cfg ├── .rubocop.yml ├── .salt-lint ├── .travis.yml ├── .yamllint ├── CODEOWNERS ├── FORMULA ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── bin ├── install-hooks └── kitchen ├── commitlint.config.js ├── docs ├── README.rst └── TOFS_pattern.rst ├── kitchen.yml ├── pillar.example ├── pre-commit_semantic-release.sh ├── release-rules.js ├── release.config.js ├── test ├── integration │ ├── default │ │ ├── README.md │ │ ├── controls │ │ │ ├── _mapdata_spec.rb │ │ │ ├── config_spec.rb │ │ │ ├── packages_spec.rb │ │ │ └── services_spec.rb │ │ ├── files │ │ │ └── _mapdata │ │ │ │ ├── amazonlinux-1.yaml │ │ │ │ ├── amazonlinux-2.yaml │ │ │ │ ├── arch-base-latest.yaml │ │ │ │ ├── centos-6.yaml │ │ │ │ ├── centos-7.yaml │ │ │ │ ├── centos-8.yaml │ │ │ │ ├── debian-10.yaml │ │ │ │ ├── debian-9.yaml │ │ │ │ ├── fedora-31.yaml │ │ │ │ ├── fedora-32.yaml │ │ │ │ ├── gentoo-2-sysd.yaml │ │ │ │ ├── gentoo-2-sysv.yaml │ │ │ │ ├── opensuse-15.yaml │ │ │ │ ├── oracle-7.yaml │ │ │ │ ├── oracle-8.yaml │ │ │ │ ├── ubuntu-16.yaml │ │ │ │ ├── ubuntu-18.yaml │ │ │ │ └── ubuntu-20.yaml │ │ └── inspec.yml │ └── share │ │ ├── README.md │ │ ├── inspec.yml │ │ └── libraries │ │ └── system.rb └── salt │ └── pillar │ ├── define_roles.sls │ ├── gentoo.sls │ └── upstart.sls └── zookeeper ├── _mapdata ├── _mapdata.jinja └── init.sls ├── archive ├── clean.sls ├── init.sls ├── install.sls └── javajdk.sls ├── clean.sls ├── config ├── clean.sls ├── file.sls └── init.sls ├── defaults.yaml ├── files └── default │ ├── example.tmpl │ ├── example.tmpl.jinja │ ├── systemd.tmpl.jinja │ ├── zoo.tmpl.jinja │ └── zookeepermyid.tmpl.jinja ├── init.sls ├── libsaltcli.jinja ├── libtofs.jinja ├── map.jinja ├── osarchmap.yaml ├── osfamilymap.yaml ├── osfingermap.yaml ├── osmap.yaml └── service ├── clean.sls ├── init.sls └── running.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 | # Spyder project settings 95 | .spyderproject 96 | .spyproject 97 | 98 | # Rope project settings 99 | .ropeproject 100 | 101 | # mkdocs documentation 102 | /site 103 | 104 | # mypy 105 | .mypy_cache/ 106 | 107 | # Bundler 108 | .bundle/ 109 | 110 | # copied `.md` files used for conversion to `.rst` using `m2r` 111 | docs/*.md 112 | 113 | # Vim 114 | *.sw? 115 | 116 | ## Collected when centralising formulas (check and sort) 117 | # `collectd-formula` 118 | .pytest_cache/ 119 | /.idea/ 120 | Dockerfile.*_* 121 | ignore/ 122 | tmp/ 123 | -------------------------------------------------------------------------------- /.kitchen.yml: -------------------------------------------------------------------------------- 1 | --- 2 | driver: 3 | name: docker 4 | use_sudo: false 5 | privileged: true 6 | 7 | verifier: 8 | name: inspec 9 | format: doc 10 | 11 | provisioner: 12 | name: salt_solo 13 | require_chef: false 14 | formula: zookeeper 15 | 16 | platforms: 17 | - name: ubuntu-16.04 18 | driver_config: 19 | provision_command: 20 | # yamllint disable rule:line-length 21 | - apt-get update && apt-get install -y netcat-openbsd locales && locale-gen en_US.UTF-8 22 | # yamllint enable 23 | run_command: /sbin/init 24 | privileged: true 25 | pid_one_command: /usr/lib/systemd/systemd 26 | - name: centos-7 27 | driver_config: 28 | image: centos:7 29 | provision_command: 30 | - yum -y install initscripts nmap-ncat 31 | platform: rhel 32 | run_command: /sbin/init 33 | privileged: true 34 | pid_one_command: /usr/lib/systemd/systemd 35 | 36 | suites: 37 | - name: default 38 | provisioner: 39 | vendor_path: vendor/sun-java-formula 40 | state_top: 41 | base: 42 | '*': 43 | - sun-java 44 | - sun-java.env 45 | - zookeeper 46 | - zookeeper.server 47 | pillars: 48 | top.sls: 49 | base: 50 | '*': 51 | - zookeeper 52 | - sun-java 53 | sun-java.sls: 54 | java: 55 | version_name: jdk1.8.0_131 56 | # yamllint disable rule:line-length 57 | source_url: http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz 58 | source_hash: 62b215bdfb48bace523723cdbb2157c665e6a25429c73828a32f00e587301236 59 | # yamllint enable 60 | zookeeper.sls: 61 | zookeeper: 62 | version: 3.4.10 63 | source_md5: e4cf1b1593ca870bf1c7a75188f09678 64 | config: 65 | port: 2181 66 | -------------------------------------------------------------------------------- /.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.56.4 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.9.0.6 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.32.0 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.9.2 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=error 3 | ignore_language=rst 4 | -------------------------------------------------------------------------------- /.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 | 204: 7 | ignore: 'zookeeper/files/default/systemd.tmpl.jinja' 8 | skip_list: 9 | # Using `salt-lint` for linting other files as well, such as Jinja macros/templates 10 | - 205 # Use ".sls" as a Salt State file extension 11 | # Skipping `207` and `208` because `210` is sufficient, at least for the time-being 12 | # I.e. Allows 3-digit unquoted codes to still be used, such as `644` and `755` 13 | - 207 # File modes should always be encapsulated in quotation marks 14 | - 208 # File modes should always contain a leading zero 15 | tags: [] 16 | verbosity: 1 17 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | ## Machine config 5 | os: 'linux' 6 | arch: 'amd64' 7 | dist: 'bionic' 8 | version: '~> 1.0' 9 | 10 | ## Language and cache config 11 | language: 'ruby' 12 | cache: 'bundler' 13 | 14 | ## Services config 15 | services: 16 | - docker 17 | 18 | ## Script to run for the test stage 19 | script: 20 | - bin/kitchen verify "${INSTANCE}" 21 | 22 | ## Stages and jobs matrix 23 | stages: 24 | - test 25 | - name: 'release' 26 | if: 'branch = master AND type != pull_request' 27 | jobs: 28 | include: 29 | ## Define the test stage that runs the linters (and testing matrix, if applicable) 30 | 31 | # Run all of the linters in a single job 32 | - language: 'node_js' 33 | node_js: 'lts/*' 34 | env: 'Lint' 35 | name: 'Lint: salt-lint, yamllint, rubocop, shellcheck & commitlint' 36 | before_install: 'skip' 37 | script: 38 | # Install and run `salt-lint` 39 | - pip install --user salt-lint 40 | - git ls-files -- '*.sls' '*.jinja' '*.j2' '*.tmpl' '*.tst' 41 | | xargs salt-lint 42 | # Install and run `yamllint` 43 | # Need at least `v1.17.0` for the `yaml-files` setting 44 | - pip install --user yamllint>=1.17.0 45 | - yamllint -s . 46 | # Install and run `rubocop` 47 | - gem install rubocop 48 | - rubocop -d 49 | # Run `shellcheck` (already pre-installed in Travis) 50 | - shellcheck --version 51 | - git ls-files -- '*.sh' '*.bash' '*.ksh' 52 | | xargs shellcheck 53 | # Install and run `commitlint` 54 | - npm i -D @commitlint/config-conventional 55 | @commitlint/travis-cli 56 | - commitlint-travis 57 | 58 | # Run `pre-commit` linters in a single job 59 | - language: 'python' 60 | env: 'Lint_pre-commit' 61 | name: 'Lint: pre-commit' 62 | before_install: 'skip' 63 | cache: 64 | directories: 65 | - $HOME/.cache/pre-commit 66 | script: 67 | # Install and run `pre-commit` 68 | - pip install pre-commit==2.7.1 69 | - pre-commit run --all-files --color always --verbose 70 | - pre-commit run --color always --hook-stage manual --verbose commitlint-travis 71 | 72 | ## Define the rest of the matrix based on Kitchen testing 73 | # Make sure the instances listed below match up with 74 | # the `platforms` defined in `kitchen.yml` 75 | # NOTE: Please try to select up to six instances that add some meaningful 76 | # testing of the formula's behaviour. If possible, try to refrain from 77 | # the classical "chosing all the instances because I want to test on 78 | # another/all distro/s" trap: it will just add time to the testing (see 79 | # the discussion on #121). As an example, the set chosen below covers 80 | # the most used distros families, systemd and non-systemd and the latest 81 | # three supported Saltstack versions with python2 and 3. 82 | # As for `kitchen.yml`, that should still contain all of the platforms, 83 | # to allow for comprehensive local testing 84 | # Ref: https://github.com/saltstack-formulas/template-formula/issues/118 85 | # Ref: https://github.com/saltstack-formulas/template-formula/issues/121 86 | - env: INSTANCE=default-debian-10-tiamat-py3 87 | # - env: INSTANCE=default-debian-9-tiamat-py3 88 | - env: INSTANCE=default-ubuntu-2004-tiamat-py3 89 | # - env: INSTANCE=default-ubuntu-1804-tiamat-py3 90 | # - env: INSTANCE=default-ubuntu-1604-tiamat-py3 91 | - env: INSTANCE=default-centos-8-tiamat-py3 92 | # - env: INSTANCE=default-centos-7-tiamat-py3 93 | - env: INSTANCE=default-amazonlinux-2-tiamat-py3 94 | - env: INSTANCE=default-oraclelinux-8-tiamat-py3 95 | # - env: INSTANCE=default-oraclelinux-7-tiamat-py3 96 | # - env: INSTANCE=default-debian-10-master-py3 97 | # - env: INSTANCE=default-ubuntu-2004-master-py3 98 | # - env: INSTANCE=default-ubuntu-1804-master-py3 99 | # - env: INSTANCE=default-centos-8-master-py3 100 | - env: INSTANCE=default-fedora-32-master-py3 101 | # - env: INSTANCE=default-fedora-31-master-py3 102 | - env: INSTANCE=default-opensuse-leap-152-master-py3 103 | # - env: INSTANCE=default-amazonlinux-2-master-py3 104 | - env: INSTANCE=gentoo-gentoo-stage3-latest-master-py3 105 | - env: INSTANCE=gentoo-gentoo-stage3-systemd-master-py3 106 | # - env: INSTANCE=default-debian-10-3001-py3 107 | # - env: INSTANCE=default-debian-9-3001-py3 108 | # - env: INSTANCE=default-ubuntu-2004-3001-py3 109 | # - env: INSTANCE=default-ubuntu-1804-3001-py3 110 | # - env: INSTANCE=default-centos-8-3001-py3 111 | # - env: INSTANCE=default-centos-7-3001-py3 112 | # - env: INSTANCE=default-fedora-32-3001-py3 113 | # - env: INSTANCE=default-fedora-31-3001-py3 114 | # - env: INSTANCE=default-opensuse-leap-152-3001-py3 115 | # - env: INSTANCE=default-amazonlinux-2-3001-py3 116 | # - env: INSTANCE=default-oraclelinux-8-3001-py3 117 | # - env: INSTANCE=default-oraclelinux-7-3001-py3 118 | # - env: INSTANCE=gentoo-gentoo-stage3-latest-3001-py3 119 | # - env: INSTANCE=gentoo-gentoo-stage3-systemd-3001-py3 120 | # - env: INSTANCE=default-debian-10-3000-3-py3 121 | # - env: INSTANCE=default-debian-9-3000-3-py3 122 | # - env: INSTANCE=default-ubuntu-1804-3000-3-py3 123 | # - env: INSTANCE=default-centos-8-3000-3-py3 124 | # - env: INSTANCE=default-centos-7-3000-3-py3 125 | # - env: INSTANCE=default-fedora-31-3000-3-py3 126 | # - env: INSTANCE=default-opensuse-leap-152-3000-3-py3 127 | # - env: INSTANCE=default-amazonlinux-2-3000-3-py3 128 | # - env: INSTANCE=gentoo-gentoo-stage3-latest-3000-3-py3 129 | # - env: INSTANCE=gentoo-gentoo-stage3-systemd-3000-3-py3 130 | # - env: INSTANCE=default-ubuntu-1804-3000-3-py2 131 | # - env: INSTANCE=default-ubuntu-1604-3000-3-py2 132 | - env: INSTANCE=default-arch-base-latest-3000-3-py2 133 | - env: INSTANCE=upstart-centos-6-2019-2-py2 134 | - env: INSTANCE=upstart-amazonlinux-1-2019-2-py2 135 | 136 | ## Define the release stage that runs `semantic-release` 137 | - stage: 'release' 138 | language: 'node_js' 139 | node_js: 'lts/*' 140 | env: 'Release' 141 | name: 'Run semantic-release inc. file updates to AUTHORS, CHANGELOG & FORMULA' 142 | before_install: 'skip' 143 | script: 144 | # Update `AUTHORS.md` 145 | - export MAINTAINER_TOKEN=${GH_TOKEN} 146 | - go get github.com/myii/maintainer 147 | - maintainer contributor 148 | 149 | # Install all dependencies required for `semantic-release` 150 | - npm i -D @semantic-release/changelog@3 151 | @semantic-release/exec@3 152 | @semantic-release/git@7 153 | deploy: 154 | provider: 'script' 155 | # Opt-in to `dpl v2` to complete the Travis build config validation (beta) 156 | # * https://docs.travis-ci.com/user/build-config-validation 157 | # Deprecated `skip_cleanup` can now be avoided, `cleanup: false` is by default 158 | edge: true 159 | # Run `semantic-release` 160 | script: 'npx semantic-release@15.14' 161 | -------------------------------------------------------------------------------- /.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 `node_modules/`, introduced during the Travis run 9 | # 2. Any SLS files under directory `test/`, which are actually state files 10 | # 3. Any YAML files under directory `.kitchen/`, introduced during local testing 11 | ignore: | 12 | node_modules/ 13 | test/**/states/**/*.sls 14 | .kitchen/ 15 | 16 | yaml-files: 17 | # Default settings 18 | - '*.yaml' 19 | - '*.yml' 20 | - .salt-lint 21 | - .yamllint 22 | # SaltStack Formulas additional settings 23 | - '*.example' 24 | - test/**/*.sls 25 | 26 | rules: 27 | empty-values: 28 | forbid-in-block-mappings: true 29 | forbid-in-flow-mappings: true 30 | line-length: 31 | # Increase from default of `80` 32 | # Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`) 33 | max: 88 34 | octal-values: 35 | forbid-implicit-octal: true 36 | forbid-explicit-octal: true 37 | -------------------------------------------------------------------------------- /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 | * @codeboyQ2n5ha45 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: zookeeper 2 | os: Debian, Ubuntu, Raspbian, RedHat, Fedora, CentOS, Amazon, Oracle, 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.0.0 5 | release: 1 6 | minimum_version: 2019.2 7 | summary: zookeeper formula 8 | description: Formula to use as a template for other formulas 9 | top_level_dir: zookeeper 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 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GIT 2 | remote: https://gitlab.com/saltstack-formulas/infrastructure/inspec 3 | revision: aaef842906a5666f0fc0b4f186b4dd3498f5b28c 4 | branch: ssf 5 | specs: 6 | inspec (5.18.15) 7 | cookstyle 8 | faraday_middleware (>= 0.12.2, < 1.1) 9 | inspec-core (= 5.18.15) 10 | mongo (= 2.13.2) 11 | progress_bar (~> 1.3.3) 12 | rake 13 | train (~> 3.10) 14 | train-aws (~> 0.2) 15 | train-habitat (~> 0.1) 16 | train-winrm (~> 0.2) 17 | inspec-core (5.18.15) 18 | addressable (~> 2.4) 19 | chef-telemetry (~> 1.0, >= 1.0.8) 20 | faraday (>= 0.9.0, < 1.5) 21 | faraday_middleware (~> 1.0) 22 | hashie (>= 3.4, < 5.0) 23 | license-acceptance (>= 0.2.13, < 3.0) 24 | method_source (>= 0.8, < 2.0) 25 | mixlib-log (~> 3.0) 26 | multipart-post (~> 2.0) 27 | parallel (~> 1.9) 28 | parslet (>= 1.5, < 2.0) 29 | pry (~> 0.13) 30 | rspec (>= 3.9, <= 3.11) 31 | rspec-its (~> 1.2) 32 | rubyzip (>= 1.2.2, < 3.0) 33 | semverse (~> 3.0) 34 | sslshake (~> 1.2) 35 | thor (>= 0.20, < 2.0) 36 | tomlrb (>= 1.2, < 2.1) 37 | train-core (~> 3.10) 38 | tty-prompt (~> 0.17) 39 | tty-table (~> 0.10) 40 | 41 | GIT 42 | remote: https://gitlab.com/saltstack-formulas/infrastructure/kitchen-docker 43 | revision: 9a09bc1e571e25f3ccabf4725ca2048d970fff82 44 | branch: ssf 45 | specs: 46 | kitchen-docker (2.12.0) 47 | test-kitchen (>= 1.0.0) 48 | 49 | GEM 50 | remote: https://rubygems.org/ 51 | specs: 52 | activesupport (7.0.3.1) 53 | concurrent-ruby (~> 1.0, >= 1.0.2) 54 | i18n (>= 1.6, < 2) 55 | minitest (>= 5.1) 56 | tzinfo (~> 2.0) 57 | addressable (2.8.0) 58 | public_suffix (>= 2.0.2, < 5.0) 59 | ast (2.4.2) 60 | aws-eventstream (1.2.0) 61 | aws-partitions (1.607.0) 62 | aws-sdk-alexaforbusiness (1.56.0) 63 | aws-sdk-core (~> 3, >= 3.127.0) 64 | aws-sigv4 (~> 1.1) 65 | aws-sdk-amplify (1.32.0) 66 | aws-sdk-core (~> 3, >= 3.120.0) 67 | aws-sigv4 (~> 1.1) 68 | aws-sdk-apigateway (1.78.0) 69 | aws-sdk-core (~> 3, >= 3.127.0) 70 | aws-sigv4 (~> 1.1) 71 | aws-sdk-apigatewayv2 (1.42.0) 72 | aws-sdk-core (~> 3, >= 3.127.0) 73 | aws-sigv4 (~> 1.1) 74 | aws-sdk-applicationautoscaling (1.51.0) 75 | aws-sdk-core (~> 3, >= 3.112.0) 76 | aws-sigv4 (~> 1.1) 77 | aws-sdk-athena (1.55.0) 78 | aws-sdk-core (~> 3, >= 3.127.0) 79 | aws-sigv4 (~> 1.1) 80 | aws-sdk-autoscaling (1.63.0) 81 | aws-sdk-core (~> 3, >= 3.112.0) 82 | aws-sigv4 (~> 1.1) 83 | aws-sdk-batch (1.47.0) 84 | aws-sdk-core (~> 3, >= 3.112.0) 85 | aws-sigv4 (~> 1.1) 86 | aws-sdk-budgets (1.50.0) 87 | aws-sdk-core (~> 3, >= 3.127.0) 88 | aws-sigv4 (~> 1.1) 89 | aws-sdk-cloudformation (1.70.0) 90 | aws-sdk-core (~> 3, >= 3.127.0) 91 | aws-sigv4 (~> 1.1) 92 | aws-sdk-cloudfront (1.65.0) 93 | aws-sdk-core (~> 3, >= 3.127.0) 94 | aws-sigv4 (~> 1.1) 95 | aws-sdk-cloudhsm (1.39.0) 96 | aws-sdk-core (~> 3, >= 3.127.0) 97 | aws-sigv4 (~> 1.1) 98 | aws-sdk-cloudhsmv2 (1.42.0) 99 | aws-sdk-core (~> 3, >= 3.127.0) 100 | aws-sigv4 (~> 1.1) 101 | aws-sdk-cloudtrail (1.49.0) 102 | aws-sdk-core (~> 3, >= 3.127.0) 103 | aws-sigv4 (~> 1.1) 104 | aws-sdk-cloudwatch (1.64.0) 105 | aws-sdk-core (~> 3, >= 3.127.0) 106 | aws-sigv4 (~> 1.1) 107 | aws-sdk-cloudwatchevents (1.46.0) 108 | aws-sdk-core (~> 3, >= 3.112.0) 109 | aws-sigv4 (~> 1.1) 110 | aws-sdk-cloudwatchlogs (1.53.0) 111 | aws-sdk-core (~> 3, >= 3.127.0) 112 | aws-sigv4 (~> 1.1) 113 | aws-sdk-codecommit (1.51.0) 114 | aws-sdk-core (~> 3, >= 3.127.0) 115 | aws-sigv4 (~> 1.1) 116 | aws-sdk-codedeploy (1.49.0) 117 | aws-sdk-core (~> 3, >= 3.127.0) 118 | aws-sigv4 (~> 1.1) 119 | aws-sdk-codepipeline (1.53.0) 120 | aws-sdk-core (~> 3, >= 3.127.0) 121 | aws-sigv4 (~> 1.1) 122 | aws-sdk-cognitoidentity (1.31.0) 123 | aws-sdk-core (~> 3, >= 3.112.0) 124 | aws-sigv4 (~> 1.1) 125 | aws-sdk-cognitoidentityprovider (1.53.0) 126 | aws-sdk-core (~> 3, >= 3.112.0) 127 | aws-sigv4 (~> 1.1) 128 | aws-sdk-configservice (1.79.0) 129 | aws-sdk-core (~> 3, >= 3.127.0) 130 | aws-sigv4 (~> 1.1) 131 | aws-sdk-core (3.131.2) 132 | aws-eventstream (~> 1, >= 1.0.2) 133 | aws-partitions (~> 1, >= 1.525.0) 134 | aws-sigv4 (~> 1.1) 135 | jmespath (~> 1, >= 1.6.1) 136 | aws-sdk-costandusagereportservice (1.40.0) 137 | aws-sdk-core (~> 3, >= 3.127.0) 138 | aws-sigv4 (~> 1.1) 139 | aws-sdk-databasemigrationservice (1.53.0) 140 | aws-sdk-core (~> 3, >= 3.112.0) 141 | aws-sigv4 (~> 1.1) 142 | aws-sdk-dynamodb (1.75.0) 143 | aws-sdk-core (~> 3, >= 3.127.0) 144 | aws-sigv4 (~> 1.1) 145 | aws-sdk-ec2 (1.322.0) 146 | aws-sdk-core (~> 3, >= 3.127.0) 147 | aws-sigv4 (~> 1.1) 148 | aws-sdk-ecr (1.56.0) 149 | aws-sdk-core (~> 3, >= 3.127.0) 150 | aws-sigv4 (~> 1.1) 151 | aws-sdk-ecrpublic (1.12.0) 152 | aws-sdk-core (~> 3, >= 3.127.0) 153 | aws-sigv4 (~> 1.1) 154 | aws-sdk-ecs (1.100.0) 155 | aws-sdk-core (~> 3, >= 3.127.0) 156 | aws-sigv4 (~> 1.1) 157 | aws-sdk-efs (1.54.0) 158 | aws-sdk-core (~> 3, >= 3.127.0) 159 | aws-sigv4 (~> 1.1) 160 | aws-sdk-eks (1.75.0) 161 | aws-sdk-core (~> 3, >= 3.127.0) 162 | aws-sigv4 (~> 1.1) 163 | aws-sdk-elasticache (1.78.0) 164 | aws-sdk-core (~> 3, >= 3.127.0) 165 | aws-sigv4 (~> 1.1) 166 | aws-sdk-elasticbeanstalk (1.51.0) 167 | aws-sdk-core (~> 3, >= 3.127.0) 168 | aws-sigv4 (~> 1.1) 169 | aws-sdk-elasticloadbalancing (1.40.0) 170 | aws-sdk-core (~> 3, >= 3.127.0) 171 | aws-sigv4 (~> 1.1) 172 | aws-sdk-elasticloadbalancingv2 (1.78.0) 173 | aws-sdk-core (~> 3, >= 3.127.0) 174 | aws-sigv4 (~> 1.1) 175 | aws-sdk-elasticsearchservice (1.65.0) 176 | aws-sdk-core (~> 3, >= 3.127.0) 177 | aws-sigv4 (~> 1.1) 178 | aws-sdk-emr (1.53.0) 179 | aws-sdk-core (~> 3, >= 3.121.2) 180 | aws-sigv4 (~> 1.1) 181 | aws-sdk-eventbridge (1.24.0) 182 | aws-sdk-core (~> 3, >= 3.112.0) 183 | aws-sigv4 (~> 1.1) 184 | aws-sdk-firehose (1.48.0) 185 | aws-sdk-core (~> 3, >= 3.127.0) 186 | aws-sigv4 (~> 1.1) 187 | aws-sdk-glue (1.88.0) 188 | aws-sdk-core (~> 3, >= 3.112.0) 189 | aws-sigv4 (~> 1.1) 190 | aws-sdk-guardduty (1.58.0) 191 | aws-sdk-core (~> 3, >= 3.127.0) 192 | aws-sigv4 (~> 1.1) 193 | aws-sdk-iam (1.69.0) 194 | aws-sdk-core (~> 3, >= 3.127.0) 195 | aws-sigv4 (~> 1.1) 196 | aws-sdk-kafka (1.50.0) 197 | aws-sdk-core (~> 3, >= 3.127.0) 198 | aws-sigv4 (~> 1.1) 199 | aws-sdk-kinesis (1.41.0) 200 | aws-sdk-core (~> 3, >= 3.127.0) 201 | aws-sigv4 (~> 1.1) 202 | aws-sdk-kms (1.57.0) 203 | aws-sdk-core (~> 3, >= 3.127.0) 204 | aws-sigv4 (~> 1.1) 205 | aws-sdk-lambda (1.84.0) 206 | aws-sdk-core (~> 3, >= 3.127.0) 207 | aws-sigv4 (~> 1.1) 208 | aws-sdk-mq (1.40.0) 209 | aws-sdk-core (~> 3, >= 3.120.0) 210 | aws-sigv4 (~> 1.1) 211 | aws-sdk-networkfirewall (1.17.0) 212 | aws-sdk-core (~> 3, >= 3.127.0) 213 | aws-sigv4 (~> 1.1) 214 | aws-sdk-networkmanager (1.24.0) 215 | aws-sdk-core (~> 3, >= 3.127.0) 216 | aws-sigv4 (~> 1.1) 217 | aws-sdk-organizations (1.59.0) 218 | aws-sdk-core (~> 3, >= 3.112.0) 219 | aws-sigv4 (~> 1.1) 220 | aws-sdk-ram (1.26.0) 221 | aws-sdk-core (~> 3, >= 3.112.0) 222 | aws-sigv4 (~> 1.1) 223 | aws-sdk-rds (1.148.0) 224 | aws-sdk-core (~> 3, >= 3.127.0) 225 | aws-sigv4 (~> 1.1) 226 | aws-sdk-redshift (1.84.0) 227 | aws-sdk-core (~> 3, >= 3.127.0) 228 | aws-sigv4 (~> 1.1) 229 | aws-sdk-route53 (1.63.0) 230 | aws-sdk-core (~> 3, >= 3.127.0) 231 | aws-sigv4 (~> 1.1) 232 | aws-sdk-route53domains (1.40.0) 233 | aws-sdk-core (~> 3, >= 3.127.0) 234 | aws-sigv4 (~> 1.1) 235 | aws-sdk-route53resolver (1.37.0) 236 | aws-sdk-core (~> 3, >= 3.127.0) 237 | aws-sigv4 (~> 1.1) 238 | aws-sdk-s3 (1.114.0) 239 | aws-sdk-core (~> 3, >= 3.127.0) 240 | aws-sdk-kms (~> 1) 241 | aws-sigv4 (~> 1.4) 242 | aws-sdk-s3control (1.43.0) 243 | aws-sdk-core (~> 3, >= 3.122.0) 244 | aws-sigv4 (~> 1.1) 245 | aws-sdk-secretsmanager (1.46.0) 246 | aws-sdk-core (~> 3, >= 3.112.0) 247 | aws-sigv4 (~> 1.1) 248 | aws-sdk-securityhub (1.67.0) 249 | aws-sdk-core (~> 3, >= 3.127.0) 250 | aws-sigv4 (~> 1.1) 251 | aws-sdk-servicecatalog (1.60.0) 252 | aws-sdk-core (~> 3, >= 3.112.0) 253 | aws-sigv4 (~> 1.1) 254 | aws-sdk-ses (1.41.0) 255 | aws-sdk-core (~> 3, >= 3.120.0) 256 | aws-sigv4 (~> 1.1) 257 | aws-sdk-shield (1.48.0) 258 | aws-sdk-core (~> 3, >= 3.127.0) 259 | aws-sigv4 (~> 1.1) 260 | aws-sdk-signer (1.32.0) 261 | aws-sdk-core (~> 3, >= 3.120.0) 262 | aws-sigv4 (~> 1.1) 263 | aws-sdk-simpledb (1.29.0) 264 | aws-sdk-core (~> 3, >= 3.120.0) 265 | aws-sigv2 (~> 1.0) 266 | aws-sdk-sms (1.40.0) 267 | aws-sdk-core (~> 3, >= 3.127.0) 268 | aws-sigv4 (~> 1.1) 269 | aws-sdk-sns (1.53.0) 270 | aws-sdk-core (~> 3, >= 3.127.0) 271 | aws-sigv4 (~> 1.1) 272 | aws-sdk-sqs (1.51.1) 273 | aws-sdk-core (~> 3, >= 3.127.0) 274 | aws-sigv4 (~> 1.1) 275 | aws-sdk-ssm (1.137.0) 276 | aws-sdk-core (~> 3, >= 3.127.0) 277 | aws-sigv4 (~> 1.1) 278 | aws-sdk-states (1.39.0) 279 | aws-sdk-core (~> 3, >= 3.112.0) 280 | aws-sigv4 (~> 1.1) 281 | aws-sdk-synthetics (1.19.0) 282 | aws-sdk-core (~> 3, >= 3.121.2) 283 | aws-sigv4 (~> 1.1) 284 | aws-sdk-transfer (1.34.0) 285 | aws-sdk-core (~> 3, >= 3.112.0) 286 | aws-sigv4 (~> 1.1) 287 | aws-sdk-waf (1.43.0) 288 | aws-sdk-core (~> 3, >= 3.122.0) 289 | aws-sigv4 (~> 1.1) 290 | aws-sigv2 (1.1.0) 291 | aws-sigv4 (1.5.0) 292 | aws-eventstream (~> 1, >= 1.0.2) 293 | azure_graph_rbac (0.17.2) 294 | ms_rest_azure (~> 0.12.0) 295 | azure_mgmt_key_vault (0.17.7) 296 | ms_rest_azure (~> 0.12.0) 297 | azure_mgmt_resources (0.18.2) 298 | ms_rest_azure (~> 0.12.0) 299 | azure_mgmt_security (0.19.0) 300 | ms_rest_azure (~> 0.12.0) 301 | azure_mgmt_storage (0.23.0) 302 | ms_rest_azure (~> 0.12.0) 303 | bcrypt_pbkdf (1.1.0) 304 | bson (4.15.0) 305 | builder (3.2.4) 306 | chef-config (17.10.0) 307 | addressable 308 | chef-utils (= 17.10.0) 309 | fuzzyurl 310 | mixlib-config (>= 2.2.12, < 4.0) 311 | mixlib-shellout (>= 2.0, < 4.0) 312 | tomlrb (~> 1.2) 313 | chef-telemetry (1.1.1) 314 | chef-config 315 | concurrent-ruby (~> 1.0) 316 | chef-utils (17.10.0) 317 | concurrent-ruby 318 | coderay (1.1.3) 319 | concurrent-ruby (1.1.10) 320 | cookstyle (7.32.1) 321 | rubocop (= 1.25.1) 322 | declarative (0.0.20) 323 | diff-lcs (1.5.0) 324 | docker-api (2.2.0) 325 | excon (>= 0.47.0) 326 | multi_json 327 | domain_name (0.5.20190701) 328 | unf (>= 0.0.5, < 1.0.0) 329 | ed25519 (1.3.0) 330 | erubi (1.10.0) 331 | excon (0.92.3) 332 | faraday (1.4.3) 333 | faraday-em_http (~> 1.0) 334 | faraday-em_synchrony (~> 1.0) 335 | faraday-excon (~> 1.1) 336 | faraday-net_http (~> 1.0) 337 | faraday-net_http_persistent (~> 1.1) 338 | multipart-post (>= 1.2, < 3) 339 | ruby2_keywords (>= 0.0.4) 340 | faraday-cookie_jar (0.0.7) 341 | faraday (>= 0.8.0) 342 | http-cookie (~> 1.0.0) 343 | faraday-em_http (1.0.0) 344 | faraday-em_synchrony (1.0.0) 345 | faraday-excon (1.1.0) 346 | faraday-net_http (1.0.1) 347 | faraday-net_http_persistent (1.2.0) 348 | faraday_middleware (1.0.0) 349 | faraday (~> 1.0) 350 | ffi (1.15.5) 351 | fuzzyurl (0.9.0) 352 | google-api-client (0.52.0) 353 | addressable (~> 2.5, >= 2.5.1) 354 | googleauth (~> 0.9) 355 | httpclient (>= 2.8.1, < 3.0) 356 | mini_mime (~> 1.0) 357 | representable (~> 3.0) 358 | retriable (>= 2.0, < 4.0) 359 | rexml 360 | signet (~> 0.12) 361 | googleauth (0.14.0) 362 | faraday (>= 0.17.3, < 2.0) 363 | jwt (>= 1.4, < 3.0) 364 | memoist (~> 0.16) 365 | multi_json (~> 1.11) 366 | os (>= 0.9, < 2.0) 367 | signet (~> 0.14) 368 | gssapi (1.3.1) 369 | ffi (>= 1.0.1) 370 | gyoku (1.4.0) 371 | builder (>= 2.1.2) 372 | rexml (~> 3.0) 373 | hashie (4.1.0) 374 | highline (2.0.3) 375 | http-cookie (1.0.5) 376 | domain_name (~> 0.5) 377 | httpclient (2.8.3) 378 | i18n (1.12.0) 379 | concurrent-ruby (~> 1.0) 380 | inifile (3.0.0) 381 | jmespath (1.6.1) 382 | json (2.6.2) 383 | jwt (2.4.1) 384 | kitchen-inspec (2.6.1) 385 | hashie (>= 3.4, <= 5.0) 386 | inspec (>= 2.2.64, < 7.0) 387 | test-kitchen (>= 2.7, < 4) 388 | kitchen-salt (0.7.2) 389 | hashie (>= 3.5) 390 | test-kitchen (>= 1.4) 391 | license-acceptance (2.1.13) 392 | pastel (~> 0.7) 393 | tomlrb (>= 1.2, < 3.0) 394 | tty-box (~> 0.6) 395 | tty-prompt (~> 0.20) 396 | little-plugger (1.1.4) 397 | logging (2.3.1) 398 | little-plugger (~> 1.1) 399 | multi_json (~> 1.14) 400 | memoist (0.16.2) 401 | method_source (1.0.0) 402 | mini_mime (1.1.2) 403 | minitest (5.16.2) 404 | mixlib-config (3.0.27) 405 | tomlrb 406 | mixlib-install (3.12.19) 407 | mixlib-shellout 408 | mixlib-versioning 409 | thor 410 | mixlib-log (3.0.9) 411 | mixlib-shellout (3.2.7) 412 | chef-utils 413 | mixlib-versioning (1.2.12) 414 | mongo (2.13.2) 415 | bson (>= 4.8.2, < 5.0.0) 416 | ms_rest (0.7.6) 417 | concurrent-ruby (~> 1.0) 418 | faraday (>= 0.9, < 2.0.0) 419 | timeliness (~> 0.3.10) 420 | ms_rest_azure (0.12.0) 421 | concurrent-ruby (~> 1.0) 422 | faraday (>= 0.9, < 2.0.0) 423 | faraday-cookie_jar (~> 0.0.6) 424 | ms_rest (~> 0.7.6) 425 | multi_json (1.15.0) 426 | multipart-post (2.2.3) 427 | net-scp (3.0.0) 428 | net-ssh (>= 2.6.5, < 7.0.0) 429 | net-ssh (6.1.0) 430 | net-ssh-gateway (2.0.0) 431 | net-ssh (>= 4.0.0) 432 | nori (2.6.0) 433 | options (2.3.2) 434 | os (1.1.4) 435 | parallel (1.22.1) 436 | parser (3.1.2.0) 437 | ast (~> 2.4.1) 438 | parslet (1.8.2) 439 | pastel (0.8.0) 440 | tty-color (~> 0.5) 441 | progress_bar (1.3.3) 442 | highline (>= 1.6, < 3) 443 | options (~> 2.3.0) 444 | pry (0.14.1) 445 | coderay (~> 1.1) 446 | method_source (~> 1.0) 447 | public_suffix (4.0.7) 448 | rainbow (3.1.1) 449 | rake (13.0.6) 450 | regexp_parser (2.5.0) 451 | representable (3.2.0) 452 | declarative (< 0.1.0) 453 | trailblazer-option (>= 0.1.1, < 0.2.0) 454 | uber (< 0.2.0) 455 | retriable (3.1.2) 456 | rexml (3.2.5) 457 | rspec (3.11.0) 458 | rspec-core (~> 3.11.0) 459 | rspec-expectations (~> 3.11.0) 460 | rspec-mocks (~> 3.11.0) 461 | rspec-core (3.11.0) 462 | rspec-support (~> 3.11.0) 463 | rspec-expectations (3.11.0) 464 | diff-lcs (>= 1.2.0, < 2.0) 465 | rspec-support (~> 3.11.0) 466 | rspec-its (1.3.0) 467 | rspec-core (>= 3.0.0) 468 | rspec-expectations (>= 3.0.0) 469 | rspec-mocks (3.11.1) 470 | diff-lcs (>= 1.2.0, < 2.0) 471 | rspec-support (~> 3.11.0) 472 | rspec-support (3.11.0) 473 | rubocop (1.25.1) 474 | parallel (~> 1.10) 475 | parser (>= 3.1.0.0) 476 | rainbow (>= 2.2.2, < 4.0) 477 | regexp_parser (>= 1.8, < 3.0) 478 | rexml 479 | rubocop-ast (>= 1.15.1, < 2.0) 480 | ruby-progressbar (~> 1.7) 481 | unicode-display_width (>= 1.4.0, < 3.0) 482 | rubocop-ast (1.19.1) 483 | parser (>= 3.1.1.0) 484 | ruby-progressbar (1.11.0) 485 | ruby2_keywords (0.0.5) 486 | rubyntlm (0.6.3) 487 | rubyzip (2.3.2) 488 | semverse (3.0.2) 489 | signet (0.17.0) 490 | addressable (~> 2.8) 491 | faraday (>= 0.17.5, < 3.a) 492 | jwt (>= 1.5, < 3.0) 493 | multi_json (~> 1.10) 494 | sslshake (1.3.1) 495 | strings (0.2.1) 496 | strings-ansi (~> 0.2) 497 | unicode-display_width (>= 1.5, < 3.0) 498 | unicode_utils (~> 1.4) 499 | strings-ansi (0.2.0) 500 | test-kitchen (3.3.1) 501 | bcrypt_pbkdf (~> 1.0) 502 | chef-utils (>= 16.4.35) 503 | ed25519 (~> 1.2) 504 | license-acceptance (>= 1.0.11, < 3.0) 505 | mixlib-install (~> 3.6) 506 | mixlib-shellout (>= 1.2, < 4.0) 507 | net-scp (>= 1.1, < 4.0) 508 | net-ssh (>= 2.9, < 7.0) 509 | net-ssh-gateway (>= 1.2, < 3.0) 510 | thor (>= 0.19, < 2.0) 511 | winrm (~> 2.0) 512 | winrm-elevated (~> 1.0) 513 | winrm-fs (~> 1.1) 514 | thor (1.2.1) 515 | timeliness (0.3.10) 516 | tomlrb (1.3.0) 517 | trailblazer-option (0.1.2) 518 | train (3.10.1) 519 | activesupport (>= 6.0.3.1) 520 | azure_graph_rbac (~> 0.16) 521 | azure_mgmt_key_vault (~> 0.17) 522 | azure_mgmt_resources (~> 0.15) 523 | azure_mgmt_security (~> 0.18) 524 | azure_mgmt_storage (~> 0.18) 525 | docker-api (>= 1.26, < 3.0) 526 | google-api-client (>= 0.23.9, <= 0.52.0) 527 | googleauth (>= 0.6.6, <= 0.14.0) 528 | inifile (~> 3.0) 529 | train-core (= 3.10.1) 530 | train-winrm (~> 0.2) 531 | train-aws (0.2.24) 532 | aws-sdk-alexaforbusiness (~> 1.0) 533 | aws-sdk-amplify (~> 1.32.0) 534 | aws-sdk-apigateway (~> 1.0) 535 | aws-sdk-apigatewayv2 (~> 1.0) 536 | aws-sdk-applicationautoscaling (>= 1.46, < 1.52) 537 | aws-sdk-athena (~> 1.0) 538 | aws-sdk-autoscaling (>= 1.22, < 1.64) 539 | aws-sdk-batch (>= 1.36, < 1.48) 540 | aws-sdk-budgets (~> 1.0) 541 | aws-sdk-cloudformation (~> 1.0) 542 | aws-sdk-cloudfront (~> 1.0) 543 | aws-sdk-cloudhsm (~> 1.0) 544 | aws-sdk-cloudhsmv2 (~> 1.0) 545 | aws-sdk-cloudtrail (~> 1.8) 546 | aws-sdk-cloudwatch (~> 1.13) 547 | aws-sdk-cloudwatchevents (>= 1.36, < 1.47) 548 | aws-sdk-cloudwatchlogs (~> 1.13) 549 | aws-sdk-codecommit (~> 1.0) 550 | aws-sdk-codedeploy (~> 1.0) 551 | aws-sdk-codepipeline (~> 1.0) 552 | aws-sdk-cognitoidentity (>= 1.26, < 1.32) 553 | aws-sdk-cognitoidentityprovider (>= 1.46, < 1.54) 554 | aws-sdk-configservice (~> 1.21) 555 | aws-sdk-core (~> 3.0) 556 | aws-sdk-costandusagereportservice (~> 1.6) 557 | aws-sdk-databasemigrationservice (>= 1.42, < 1.54) 558 | aws-sdk-dynamodb (~> 1.31) 559 | aws-sdk-ec2 (~> 1.70) 560 | aws-sdk-ecr (~> 1.18) 561 | aws-sdk-ecrpublic (~> 1.3) 562 | aws-sdk-ecs (~> 1.30) 563 | aws-sdk-efs (~> 1.0) 564 | aws-sdk-eks (~> 1.9) 565 | aws-sdk-elasticache (~> 1.0) 566 | aws-sdk-elasticbeanstalk (~> 1.0) 567 | aws-sdk-elasticloadbalancing (~> 1.8) 568 | aws-sdk-elasticloadbalancingv2 (~> 1.0) 569 | aws-sdk-elasticsearchservice (~> 1.0) 570 | aws-sdk-emr (~> 1.53.0) 571 | aws-sdk-eventbridge (~> 1.24.0) 572 | aws-sdk-firehose (~> 1.0) 573 | aws-sdk-glue (>= 1.71, < 1.89) 574 | aws-sdk-guardduty (~> 1.31) 575 | aws-sdk-iam (~> 1.13) 576 | aws-sdk-kafka (~> 1.0) 577 | aws-sdk-kinesis (~> 1.0) 578 | aws-sdk-kms (~> 1.13) 579 | aws-sdk-lambda (~> 1.0) 580 | aws-sdk-mq (~> 1.40.0) 581 | aws-sdk-networkfirewall (>= 1.6.0) 582 | aws-sdk-networkmanager (>= 1.13.0) 583 | aws-sdk-organizations (>= 1.17, < 1.60) 584 | aws-sdk-ram (>= 1.21, < 1.27) 585 | aws-sdk-rds (~> 1.43) 586 | aws-sdk-redshift (~> 1.0) 587 | aws-sdk-route53 (~> 1.0) 588 | aws-sdk-route53domains (~> 1.0) 589 | aws-sdk-route53resolver (~> 1.0) 590 | aws-sdk-s3 (~> 1.30) 591 | aws-sdk-s3control (~> 1.43.0) 592 | aws-sdk-secretsmanager (>= 1.42, < 1.47) 593 | aws-sdk-securityhub (~> 1.0) 594 | aws-sdk-servicecatalog (>= 1.48, < 1.61) 595 | aws-sdk-ses (~> 1.41.0) 596 | aws-sdk-shield (~> 1.30) 597 | aws-sdk-signer (~> 1.32.0) 598 | aws-sdk-simpledb (~> 1.29.0) 599 | aws-sdk-sms (~> 1.0) 600 | aws-sdk-sns (~> 1.9) 601 | aws-sdk-sqs (~> 1.10) 602 | aws-sdk-ssm (~> 1.0) 603 | aws-sdk-states (>= 1.35, < 1.40) 604 | aws-sdk-synthetics (~> 1.19.0) 605 | aws-sdk-transfer (>= 1.26, < 1.35) 606 | aws-sdk-waf (~> 1.43.0) 607 | train-core (3.10.1) 608 | addressable (~> 2.5) 609 | ffi (!= 1.13.0) 610 | json (>= 1.8, < 3.0) 611 | mixlib-shellout (>= 2.0, < 4.0) 612 | net-scp (>= 1.2, < 4.0) 613 | net-ssh (>= 2.9, < 7.0) 614 | train-habitat (0.2.22) 615 | train-winrm (0.2.13) 616 | winrm (>= 2.3.6, < 3.0) 617 | winrm-elevated (~> 1.2.2) 618 | winrm-fs (~> 1.0) 619 | tty-box (0.7.0) 620 | pastel (~> 0.8) 621 | strings (~> 0.2.0) 622 | tty-cursor (~> 0.7) 623 | tty-color (0.6.0) 624 | tty-cursor (0.7.1) 625 | tty-prompt (0.23.1) 626 | pastel (~> 0.8) 627 | tty-reader (~> 0.8) 628 | tty-reader (0.9.0) 629 | tty-cursor (~> 0.7) 630 | tty-screen (~> 0.8) 631 | wisper (~> 2.0) 632 | tty-screen (0.8.1) 633 | tty-table (0.12.0) 634 | pastel (~> 0.8) 635 | strings (~> 0.2.0) 636 | tty-screen (~> 0.8) 637 | tzinfo (2.0.4) 638 | concurrent-ruby (~> 1.0) 639 | uber (0.1.0) 640 | unf (0.1.4) 641 | unf_ext 642 | unf_ext (0.0.8.2) 643 | unicode-display_width (2.2.0) 644 | unicode_utils (1.4.0) 645 | winrm (2.3.6) 646 | builder (>= 2.1.2) 647 | erubi (~> 1.8) 648 | gssapi (~> 1.2) 649 | gyoku (~> 1.0) 650 | httpclient (~> 2.2, >= 2.2.0.2) 651 | logging (>= 1.6.1, < 3.0) 652 | nori (~> 2.0) 653 | rubyntlm (~> 0.6.0, >= 0.6.3) 654 | winrm-elevated (1.2.3) 655 | erubi (~> 1.8) 656 | winrm (~> 2.0) 657 | winrm-fs (~> 1.0) 658 | winrm-fs (1.3.5) 659 | erubi (~> 1.8) 660 | logging (>= 1.6.1, < 3.0) 661 | rubyzip (~> 2.0) 662 | winrm (~> 2.0) 663 | wisper (2.0.1) 664 | 665 | PLATFORMS 666 | ruby 667 | 668 | DEPENDENCIES 669 | inspec! 670 | kitchen-docker! 671 | kitchen-inspec (>= 2.5.0) 672 | kitchen-salt (>= 0.7.2) 673 | 674 | BUNDLED WITH 675 | 2.1.2 676 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 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/README.rst: -------------------------------------------------------------------------------- 1 | .. _readme: 2 | 3 | zookeeper-formula 4 | ================= 5 | 6 | Installs and Configures Apache Zookeeper from from a tar file. 7 | 8 | |img_travis| |img_sr| |img_pc| 9 | 10 | .. |img_travis| image:: https://travis-ci.com/saltstack-formulas/zookeeper-formula.svg?branch=master 11 | :alt: Travis CI Build Status 12 | :scale: 100% 13 | :target: https://travis-ci.com/saltstack-formulas/zookeeper-formula 14 | .. |img_sr| image:: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg 15 | :alt: Semantic Release 16 | :scale: 100% 17 | :target: https://github.com/semantic-release/semantic-release 18 | .. |img_pc| image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white 19 | :alt: pre-commit 20 | :scale: 100% 21 | :target: https://github.com/pre-commit/pre-commit 22 | 23 | A SaltStack formula that is empty. It has dummy content to help with a quick 24 | start on a new formula and it serves as a style guide. 25 | 26 | .. contents:: **Table of Contents** 27 | :depth: 1 28 | 29 | General notes 30 | ------------- 31 | 32 | See the full `SaltStack Formulas installation and usage instructions 33 | `_. 34 | 35 | If you are interested in writing or contributing to formulas, please pay attention to the `Writing Formula Section 36 | `_. 37 | 38 | If you want to use this formula, please pay attention to the ``FORMULA`` file and/or ``git tag``, 39 | which contains the currently released version. This formula is versioned according to `Semantic Versioning `_. 40 | 41 | See `Formula Versioning Section `_ for more details. 42 | 43 | If you need (non-default) configuration, please pay attention to the ``pillar.example`` file and/or `Special notes`_ section. 44 | 45 | Contributing to this repo 46 | ------------------------- 47 | 48 | Commit messages 49 | ^^^^^^^^^^^^^^^ 50 | 51 | **Commit message formatting is significant!!** 52 | 53 | Please see `How to contribute `_ for more details. 54 | 55 | pre-commit 56 | ^^^^^^^^^^ 57 | 58 | `pre-commit `_ is configured for this formula, which you may optionally use to ease the steps involved in submitting your changes. 59 | First install the ``pre-commit`` package manager using the appropriate `method `_, then run ``bin/install-hooks`` and 60 | now ``pre-commit`` will run automatically on each ``git commit``. :: 61 | 62 | $ bin/install-hooks 63 | pre-commit installed at .git/hooks/pre-commit 64 | pre-commit installed at .git/hooks/commit-msg 65 | 66 | Special notes 67 | ------------- 68 | 69 | None 70 | 71 | Available states 72 | ---------------- 73 | 74 | .. contents:: 75 | :local: 76 | 77 | ``zookeeper`` 78 | ^^^^^^^^^^^^^ 79 | 80 | *Meta-state (This is a state that includes other states)*. 81 | 82 | This installs the zookeeper package, 83 | manages the zookeeper configuration file and then 84 | starts the associated zookeeper service. 85 | 86 | ``zookeeper.package`` 87 | ^^^^^^^^^^^^^^^^^^^^^ 88 | 89 | This state will install the zookeeper package only. 90 | 91 | ``zookeeper.config`` 92 | ^^^^^^^^^^^^^^^^^^^^ 93 | 94 | This state will configure the zookeeper service and has a dependency on ``zookeeper.install`` 95 | via include list. 96 | 97 | ``zookeeper.service`` 98 | ^^^^^^^^^^^^^^^^^^^^^ 99 | 100 | This state will start the zookeeper service and has a dependency on ``zookeeper.config`` 101 | via include list. 102 | 103 | ``zookeeper.clean`` 104 | ^^^^^^^^^^^^^^^^^^^ 105 | 106 | *Meta-state (This is a state that includes other states)*. 107 | 108 | this state will undo everything performed in the ``zookeeper`` meta-state in reverse order, i.e. 109 | stops the service, 110 | removes the configuration file and 111 | then uninstalls the package. 112 | 113 | ``zookeeper.service.clean`` 114 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 115 | 116 | This state will stop the zookeeper service and disable it at boot time. 117 | 118 | ``zookeeper.config.clean`` 119 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 120 | 121 | This state will remove the configuration of the zookeeper service and has a 122 | dependency on ``zookeeper.service.clean`` via include list. 123 | 124 | ``zookeeper.package.clean`` 125 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 126 | 127 | This state will remove the zookeeper package and has a depency on 128 | ``zookeeper.config.clean`` via include list. 129 | 130 | Testing 131 | ------- 132 | 133 | Linux testing is done with ``kitchen-salt``. 134 | 135 | Requirements 136 | ^^^^^^^^^^^^ 137 | 138 | * Ruby 139 | * Docker 140 | 141 | .. code-block:: bash 142 | 143 | $ gem install bundler 144 | $ bundle install 145 | $ bin/kitchen test [platform] 146 | 147 | Where ``[platform]`` is the platform name defined in ``kitchen.yml``, 148 | e.g. ``debian-9-2019-2-py3``. 149 | 150 | ``bin/kitchen converge`` 151 | ^^^^^^^^^^^^^^^^^^^^^^^^ 152 | 153 | Creates the docker instance and runs the ``zookeeper`` main state, ready for testing. 154 | 155 | ``bin/kitchen verify`` 156 | ^^^^^^^^^^^^^^^^^^^^^^ 157 | 158 | Runs the ``inspec`` tests on the actual instance. 159 | 160 | ``bin/kitchen destroy`` 161 | ^^^^^^^^^^^^^^^^^^^^^^^ 162 | 163 | Removes the docker instance. 164 | 165 | ``bin/kitchen test`` 166 | ^^^^^^^^^^^^^^^^^^^^ 167 | 168 | Runs all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``verify`` + ``destroy``. 169 | 170 | ``bin/kitchen login`` 171 | ^^^^^^^^^^^^^^^^^^^^^ 172 | 173 | Gives you SSH access to the instance for manual testing. 174 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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: /lib/systemd/systemd 10 | 11 | # Make sure the platforms listed below match up with 12 | # the `env.matrix` instances defined in `.travis.yml` 13 | platforms: 14 | ## SALT `tiamat` 15 | - name: debian-10-tiamat-py3 16 | driver: 17 | image: saltimages/salt-tiamat-py3:debian-10 18 | - name: debian-9-tiamat-py3 19 | driver: 20 | image: saltimages/salt-tiamat-py3:debian-9 21 | - name: ubuntu-2004-tiamat-py3 22 | driver: 23 | image: saltimages/salt-tiamat-py3:ubuntu-20.04 24 | - name: ubuntu-1804-tiamat-py3 25 | driver: 26 | image: saltimages/salt-tiamat-py3:ubuntu-18.04 27 | - name: ubuntu-1604-tiamat-py3 28 | driver: 29 | image: saltimages/salt-tiamat-py3:ubuntu-16.04 30 | - name: centos-8-tiamat-py3 31 | driver: 32 | image: saltimages/salt-tiamat-py3:centos-8 33 | - name: centos-7-tiamat-py3 34 | driver: 35 | image: saltimages/salt-tiamat-py3:centos-7 36 | - name: amazonlinux-2-tiamat-py3 37 | driver: 38 | image: saltimages/salt-tiamat-py3:amazonlinux-2 39 | - name: oraclelinux-8-tiamat-py3 40 | driver: 41 | image: saltimages/salt-tiamat-py3:oraclelinux-8 42 | - name: oraclelinux-7-tiamat-py3 43 | driver: 44 | image: saltimages/salt-tiamat-py3:oraclelinux-7 45 | 46 | ## SALT `master` 47 | - name: debian-10-master-py3 48 | driver: 49 | image: saltimages/salt-master-py3:debian-10 50 | - name: ubuntu-2004-master-py3 51 | driver: 52 | image: saltimages/salt-master-py3:ubuntu-20.04 53 | - name: ubuntu-1804-master-py3 54 | driver: 55 | image: saltimages/salt-master-py3:ubuntu-18.04 56 | - name: centos-8-master-py3 57 | driver: 58 | image: saltimages/salt-master-py3:centos-8 59 | - name: fedora-32-master-py3 60 | driver: 61 | image: saltimages/salt-master-py3:fedora-32 62 | - name: fedora-31-master-py3 63 | driver: 64 | image: saltimages/salt-master-py3:fedora-31 65 | - name: opensuse-leap-152-master-py3 66 | driver: 67 | image: saltimages/salt-master-py3:opensuse-leap-15.2 68 | run_command: /usr/lib/systemd/systemd 69 | # Workaround to avoid intermittent failures on `opensuse-leap-15.2`: 70 | # => SCP did not finish successfully (255): (Net::SCP::Error) 71 | transport: 72 | max_ssh_sessions: 1 73 | - name: amazonlinux-2-master-py3 74 | driver: 75 | image: saltimages/salt-master-py3:amazonlinux-2 76 | - name: gentoo-stage3-latest-master-py3 77 | driver: 78 | image: saltimages/salt-master-py3:gentoo-stage3-latest 79 | run_command: /sbin/init 80 | - name: gentoo-stage3-systemd-master-py3 81 | driver: 82 | image: saltimages/salt-master-py3:gentoo-stage3-systemd 83 | 84 | ## SALT `3001` 85 | - name: debian-10-3001-py3 86 | driver: 87 | image: saltimages/salt-3001-py3:debian-10 88 | - name: debian-9-3001-py3 89 | driver: 90 | image: saltimages/salt-3001-py3:debian-9 91 | - name: ubuntu-2004-3001-py3 92 | driver: 93 | image: saltimages/salt-3001-py3:ubuntu-20.04 94 | - name: ubuntu-1804-3001-py3 95 | driver: 96 | image: saltimages/salt-3001-py3:ubuntu-18.04 97 | - name: centos-8-3001-py3 98 | driver: 99 | image: saltimages/salt-3001-py3:centos-8 100 | - name: centos-7-3001-py3 101 | driver: 102 | image: saltimages/salt-3001-py3:centos-7 103 | - name: fedora-32-3001-py3 104 | driver: 105 | image: saltimages/salt-3001-py3:fedora-32 106 | - name: fedora-31-3001-py3 107 | driver: 108 | image: saltimages/salt-3001-py3:fedora-31 109 | - name: opensuse-leap-152-3001-py3 110 | driver: 111 | image: saltimages/salt-3001-py3:opensuse-leap-15.2 112 | run_command: /usr/lib/systemd/systemd 113 | # Workaround to avoid intermittent failures on `opensuse-leap-15.2`: 114 | # => SCP did not finish successfully (255): (Net::SCP::Error) 115 | transport: 116 | max_ssh_sessions: 1 117 | - name: amazonlinux-2-3001-py3 118 | driver: 119 | image: saltimages/salt-3001-py3:amazonlinux-2 120 | - name: oraclelinux-8-3001-py3 121 | driver: 122 | image: saltimages/salt-3001-py3:oraclelinux-8 123 | - name: oraclelinux-7-3001-py3 124 | driver: 125 | image: saltimages/salt-3001-py3:oraclelinux-7 126 | - name: gentoo-stage3-latest-3001-py3 127 | driver: 128 | image: saltimages/salt-3001-py3:gentoo-stage3-latest 129 | run_command: /sbin/init 130 | - name: gentoo-stage3-systemd-3001-py3 131 | driver: 132 | image: saltimages/salt-3001-py3:gentoo-stage3-systemd 133 | 134 | ## SALT `3000.3` 135 | - name: debian-10-3000-3-py3 136 | driver: 137 | image: saltimages/salt-3000.3-py3:debian-10 138 | - name: debian-9-3000-3-py3 139 | driver: 140 | image: saltimages/salt-3000.3-py3:debian-9 141 | - name: ubuntu-1804-3000-3-py3 142 | driver: 143 | image: saltimages/salt-3000.3-py3:ubuntu-18.04 144 | - name: centos-8-3000-3-py3 145 | driver: 146 | image: saltimages/salt-3000.3-py3:centos-8 147 | - name: centos-7-3000-3-py3 148 | driver: 149 | image: saltimages/salt-3000.3-py3:centos-7 150 | - name: fedora-31-3000-3-py3 151 | driver: 152 | image: saltimages/salt-3000.3-py3:fedora-31 153 | - name: opensuse-leap-152-3000-3-py3 154 | driver: 155 | image: saltimages/salt-3000.3-py3:opensuse-leap-15.2 156 | run_command: /usr/lib/systemd/systemd 157 | # Workaround to avoid intermittent failures on `opensuse-leap-15.2`: 158 | # => SCP did not finish successfully (255): (Net::SCP::Error) 159 | transport: 160 | max_ssh_sessions: 1 161 | - name: amazonlinux-2-3000-3-py3 162 | driver: 163 | image: saltimages/salt-3000.3-py3:amazonlinux-2 164 | - name: gentoo-stage3-latest-3000-3-py3 165 | driver: 166 | image: saltimages/salt-3000.3-py3:gentoo-stage3-latest 167 | run_command: /sbin/init 168 | - name: gentoo-stage3-systemd-3000-3-py3 169 | driver: 170 | image: saltimages/salt-3000.3-py3:gentoo-stage3-systemd 171 | - name: ubuntu-1804-3000-3-py2 172 | driver: 173 | image: saltimages/salt-3000.3-py2:ubuntu-18.04 174 | - name: ubuntu-1604-3000-3-py2 175 | driver: 176 | image: saltimages/salt-3000.3-py2:ubuntu-16.04 177 | - name: arch-base-latest-3000-3-py2 178 | driver: 179 | image: saltimages/salt-3000.3-py2:arch-base-latest 180 | run_command: /usr/lib/systemd/systemd 181 | 182 | ## SALT `2019.2` 183 | - name: centos-6-2019-2-py2 184 | driver: 185 | image: saltimages/salt-2019.2-py2:centos-6 186 | run_command: /sbin/init 187 | - name: amazonlinux-1-2019-2-py2 188 | driver: 189 | image: saltimages/salt-2019.2-py2:amazonlinux-1 190 | run_command: /sbin/init 191 | 192 | provisioner: 193 | name: salt_solo 194 | log_level: debug 195 | salt_install: none 196 | require_chef: false 197 | formula: zookeeper 198 | salt_copy_filter: 199 | - .kitchen 200 | - .git 201 | 202 | verifier: 203 | # https://www.inspec.io/ 204 | name: inspec 205 | sudo: true 206 | # cli, documentation, html, progress, json, json-min, json-rspec, junit 207 | reporter: 208 | - cli 209 | 210 | suites: 211 | - name: default 212 | excludes: 213 | - centos-6-2019-2-py2 214 | - amazonlinux-1-2019-2-py2 215 | - gentoo-stage3-latest-master-py3 216 | - gentoo-stage3-systemd-master-py3 217 | - gentoo-stage3-latest-3001-py3 218 | - gentoo-stage3-systemd-3001-py3 219 | - gentoo-stage3-latest-3000-3-py3 220 | - gentoo-stage3-systemd-3000-3-py3 221 | provisioner: 222 | state_top: 223 | base: 224 | '*': 225 | - zookeeper._mapdata 226 | - zookeeper 227 | pillars: 228 | top.sls: 229 | base: 230 | '*': 231 | - zookeeper 232 | - define_roles 233 | pillars_from_files: 234 | zookeeper.sls: pillar.example 235 | define_roles.sls: test/salt/pillar/define_roles.sls 236 | verifier: 237 | inspec_tests: 238 | - path: test/integration/default 239 | - name: upstart 240 | includes: 241 | - centos-6-2019-2-py2 242 | - amazonlinux-1-2019-2-py2 243 | provisioner: 244 | state_top: 245 | base: 246 | '*': 247 | - zookeeper._mapdata 248 | - zookeeper 249 | pillars: 250 | top.sls: 251 | base: 252 | '*': 253 | - zookeeper 254 | - define_roles 255 | pillars_from_files: 256 | zookeeper.sls: test/salt/pillar/upstart.sls 257 | define_roles.sls: test/salt/pillar/define_roles.sls 258 | verifier: 259 | inspec_tests: 260 | - path: test/integration/default 261 | - name: gentoo 262 | includes: 263 | - gentoo-stage3-latest-master-py3 264 | - gentoo-stage3-systemd-master-py3 265 | - gentoo-stage3-latest-3001-py3 266 | - gentoo-stage3-systemd-3001-py3 267 | - gentoo-stage3-latest-3000-3-py3 268 | - gentoo-stage3-systemd-3000-3-py3 269 | provisioner: 270 | state_top: 271 | base: 272 | '*': 273 | - zookeeper._mapdata 274 | - zookeeper 275 | pillars: 276 | top.sls: 277 | base: 278 | '*': 279 | - zookeeper 280 | - gentoo 281 | - define_roles 282 | pillars_from_files: 283 | zookeeper.sls: pillar.example 284 | gentoo.sls: test/salt/pillar/gentoo.sls 285 | define_roles.sls: test/salt/pillar/define_roles.sls 286 | verifier: 287 | inspec_tests: 288 | - path: test/integration/default 289 | -------------------------------------------------------------------------------- /pillar.example: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | zookeeper: 5 | pkg: 6 | name: zookeeper 7 | downloadurl: > 8 | https://mirror.csclub.uwaterloo.ca/apache/zookeeper/zookeeper-3.6.2/apache-zookeeper-3.6.2-bin.tar.gz 9 | version: 3.6.2 10 | installdir: /opt 11 | 12 | # OpenJDK package name on system; defaults to an empty string, which avoids 13 | # installing OpenJDK. Overridden in the `os*map.yaml` files. 14 | javajdk: '' 15 | 16 | systemdconfig: 17 | user: root 18 | group: root 19 | limitnofile: 50000 20 | limitnproc: 10000 21 | 22 | rootgroup: root 23 | config: 'zoo.cfg' 24 | service: 25 | name: zookeeper 26 | 27 | zookeeperproperties: 28 | tickTime: 2000 29 | dataDir: ./state/zookeeper 30 | clientPort: 2181 31 | initLimit: 5 32 | syncLimit: 2 33 | customservers: '' 34 | -------------------------------------------------------------------------------- /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 `m2r` to convert automatically produced `.md` docs to `.rst` 11 | ############################################################################### 12 | 13 | # Install `m2r` 14 | sudo -H pip install m2r 15 | 16 | # Copy and then convert the `.md` docs 17 | cp ./*.md docs/ 18 | cd docs/ || exit 19 | m2r --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 | plugins: [ 4 | ['@semantic-release/commit-analyzer', { 5 | preset: 'angular', 6 | releaseRules: './release-rules.js', 7 | }], 8 | '@semantic-release/release-notes-generator', 9 | ['@semantic-release/changelog', { 10 | changelogFile: 'CHANGELOG.md', 11 | changelogTitle: '# Changelog', 12 | }], 13 | ['@semantic-release/exec', { 14 | prepareCmd: 'sh ./pre-commit_semantic-release.sh ${nextRelease.version}', 15 | }], 16 | ['@semantic-release/git', { 17 | assets: ['*.md', 'docs/*.rst', 'FORMULA'], 18 | }], 19 | '@semantic-release/github', 20 | ], 21 | generateNotes: { 22 | preset: 'angular', 23 | writerOpts: { 24 | // Required due to upstream bug preventing all types being displayed. 25 | // Bug: https://github.com/conventional-changelog/conventional-changelog/issues/317 26 | // Fix: https://github.com/conventional-changelog/conventional-changelog/pull/410 27 | transform: (commit, context) => { 28 | const issues = [] 29 | 30 | commit.notes.forEach(note => { 31 | note.title = `BREAKING CHANGES` 32 | }) 33 | 34 | // NOTE: Any changes here must be reflected in `CONTRIBUTING.md`. 35 | if (commit.type === `feat`) { 36 | commit.type = `Features` 37 | } else if (commit.type === `fix`) { 38 | commit.type = `Bug Fixes` 39 | } else if (commit.type === `perf`) { 40 | commit.type = `Performance Improvements` 41 | } else if (commit.type === `revert`) { 42 | commit.type = `Reverts` 43 | } else if (commit.type === `docs`) { 44 | commit.type = `Documentation` 45 | } else if (commit.type === `style`) { 46 | commit.type = `Styles` 47 | } else if (commit.type === `refactor`) { 48 | commit.type = `Code Refactoring` 49 | } else if (commit.type === `test`) { 50 | commit.type = `Tests` 51 | } else if (commit.type === `build`) { 52 | commit.type = `Build System` 53 | // } else if (commit.type === `chore`) { 54 | // commit.type = `Maintenance` 55 | } else if (commit.type === `ci`) { 56 | commit.type = `Continuous Integration` 57 | } else { 58 | return 59 | } 60 | 61 | if (commit.scope === `*`) { 62 | commit.scope = `` 63 | } 64 | 65 | if (typeof commit.hash === `string`) { 66 | commit.shortHash = commit.hash.substring(0, 7) 67 | } 68 | 69 | if (typeof commit.subject === `string`) { 70 | let url = context.repository 71 | ? `${context.host}/${context.owner}/${context.repository}` 72 | : context.repoUrl 73 | if (url) { 74 | url = `${url}/issues/` 75 | // Issue URLs. 76 | commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => { 77 | issues.push(issue) 78 | return `[#${issue}](${url}${issue})` 79 | }) 80 | } 81 | if (context.host) { 82 | // User URLs. 83 | commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => { 84 | if (username.includes('/')) { 85 | return `@${username}` 86 | } 87 | 88 | return `[@${username}](${context.host}/${username})` 89 | }) 90 | } 91 | } 92 | 93 | // remove references that already appear in the subject 94 | commit.references = commit.references.filter(reference => { 95 | if (issues.indexOf(reference.issue) === -1) { 96 | return true 97 | } 98 | 99 | return false 100 | }) 101 | 102 | return commit 103 | }, 104 | }, 105 | }, 106 | }; 107 | -------------------------------------------------------------------------------- /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/_mapdata_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Keep only first 2 digits from Ubuntu finger 4 | mapdata_file = "_mapdata/#{system.platform[:finger].split('.').first}.yaml" 5 | 6 | # Load the mapdata from profile https://docs.chef.io/inspec/profiles/#profile-files 7 | mapdata_dump = inspec.profile.file(mapdata_file) 8 | 9 | control '`map.jinja` YAML dump' do 10 | title 'should contain the lines' 11 | 12 | describe file('/tmp/salt_mapdata_dump.yaml') do 13 | it { should exist } 14 | its('content') { should eq mapdata_dump } 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /test/integration/default/controls/config_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | control 'zookeeper configuration' do 4 | title 'should match desired lines' 5 | 6 | describe file('/etc/template-formula.conf') do 7 | it { should be_file } 8 | it { should be_owned_by 'root' } 9 | it { should be_grouped_into 'root' } 10 | its('mode') { should cmp '0644' } 11 | its('content') do 12 | should include( 13 | 'This is another example file from SaltStack template-formula.' 14 | ) 15 | end 16 | its('content') { should include '"added_in_pillar": "pillar_value"' } 17 | its('content') { should include '"added_in_defaults": "defaults_value"' } 18 | its('content') { should include '"added_in_lookup": "lookup_value"' } 19 | its('content') { should include '"config": "/etc/template-formula.conf"' } 20 | its('content') { should include '"lookup": {"added_in_lookup": "lookup_value",' } 21 | its('content') { should include '"pkg": {"name": "' } 22 | its('content') { should include '"service": {"name": "' } 23 | its('content') do 24 | # rubocop:disable Lint/RedundantCopDisableDirective 25 | # rubocop:disable Layout/LineLength 26 | should include( 27 | '"tofs": {"files_switch": ["any/path/can/be/used/here", "id", ' \ 28 | '"roles", "osfinger", "os", "os_family"], "source_files": ' \ 29 | '{"zookeeper-config-file-file-managed": ["example.tmpl.jinja"]}' 30 | ) 31 | # rubocop:enable Layout/LineLength 32 | # rubocop:enable Lint/RedundantCopDisableDirective 33 | end 34 | its('content') { should include '"arch": "amd64"' } 35 | its('content') { should include '"winner": "pillar"}' } 36 | its('content') { should include 'winner of the merge: pillar' } 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /test/integration/default/controls/packages_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Prepare platform "finger" 4 | platform_finger = system.platform[:finger].split('.').first.to_s 5 | 6 | control 'zookeeper package' do 7 | title 'should be installed' 8 | 9 | # Overide by `platform_finger` 10 | package_name = 11 | case platform_finger 12 | when 'centos-6', 'amazonlinux-1' 13 | 'cronie' 14 | else 15 | 'bash' 16 | end 17 | 18 | describe package(package_name) do 19 | it { should be_installed } 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /test/integration/default/controls/services_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Prepare platform "finger" 4 | platform_finger = system.platform[:finger].split('.').first.to_s 5 | 6 | control 'zookeeper service' do 7 | impact 0.5 8 | title 'should be running and enabled' 9 | 10 | # Overide by `platform_finger` 11 | service_name = 12 | case platform_finger 13 | when 'centos-6', 'amazonlinux-1' 14 | 'crond' 15 | else 16 | 'systemd-journald' 17 | end 18 | 19 | describe service(service_name) do 20 | it { should be_installed } 21 | it { should be_enabled } 22 | it { should be_running } 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /test/integration/default/files/_mapdata/amazonlinux-1.yaml: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:indentation rule:line-length 2 | # Amazon Linux AMI-2018 3 | --- 4 | added_in_defaults: defaults_value 5 | added_in_lookup: lookup_value 6 | added_in_pillar: pillar_value 7 | arch: amd64 8 | config: /etc/template-formula.conf 9 | lookup: 10 | added_in_lookup: lookup_value 11 | master: template-master 12 | winner: lookup 13 | master: template-master 14 | pkg: 15 | name: cronie 16 | rootgroup: root 17 | service: 18 | name: crond 19 | tofs: 20 | files_switch: 21 | - any/path/can/be/used/here 22 | - id 23 | - roles 24 | - osfinger 25 | - os 26 | - os_family 27 | source_files: 28 | zookeeper-config-file-file-managed: 29 | - example.tmpl.jinja 30 | winner: pillar 31 | -------------------------------------------------------------------------------- /test/integration/default/files/_mapdata/amazonlinux-2.yaml: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:indentation rule:line-length 2 | # Amazon Linux-2 3 | --- 4 | added_in_defaults: defaults_value 5 | added_in_lookup: lookup_value 6 | added_in_pillar: pillar_value 7 | arch: amd64 8 | config: /etc/template-formula.conf 9 | lookup: 10 | added_in_lookup: lookup_value 11 | master: template-master 12 | winner: lookup 13 | master: template-master 14 | pkg: 15 | name: bash 16 | rootgroup: root 17 | service: 18 | name: systemd-journald 19 | tofs: 20 | files_switch: 21 | - any/path/can/be/used/here 22 | - id 23 | - roles 24 | - osfinger 25 | - os 26 | - os_family 27 | source_files: 28 | zookeeper-config-file-file-managed: 29 | - example.tmpl.jinja 30 | winner: pillar 31 | -------------------------------------------------------------------------------- /test/integration/default/files/_mapdata/arch-base-latest.yaml: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:indentation rule:line-length 2 | # Arch 3 | --- 4 | added_in_defaults: defaults_value 5 | added_in_lookup: lookup_value 6 | added_in_pillar: pillar_value 7 | arch: amd64 8 | config: /etc/template-formula.conf 9 | lookup: 10 | added_in_lookup: lookup_value 11 | master: template-master 12 | winner: lookup 13 | master: template-master 14 | pkg: 15 | name: bash 16 | rootgroup: root 17 | service: 18 | name: systemd-journald 19 | tofs: 20 | files_switch: 21 | - any/path/can/be/used/here 22 | - id 23 | - roles 24 | - osfinger 25 | - os 26 | - os_family 27 | source_files: 28 | zookeeper-config-file-file-managed: 29 | - example.tmpl.jinja 30 | winner: pillar 31 | -------------------------------------------------------------------------------- /test/integration/default/files/_mapdata/centos-6.yaml: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:indentation rule:line-length 2 | # CentOS-6 3 | --- 4 | added_in_defaults: defaults_value 5 | added_in_lookup: lookup_value 6 | added_in_pillar: pillar_value 7 | arch: amd64 8 | config: /etc/template-formula.conf 9 | lookup: 10 | added_in_lookup: lookup_value 11 | master: template-master 12 | winner: lookup 13 | master: template-master 14 | pkg: 15 | name: cronie 16 | rootgroup: root 17 | service: 18 | name: crond 19 | tofs: 20 | files_switch: 21 | - any/path/can/be/used/here 22 | - id 23 | - roles 24 | - osfinger 25 | - os 26 | - os_family 27 | source_files: 28 | zookeeper-config-file-file-managed: 29 | - example.tmpl.jinja 30 | winner: pillar 31 | -------------------------------------------------------------------------------- /test/integration/default/files/_mapdata/centos-7.yaml: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:indentation rule:line-length 2 | # CentOS Linux-7 3 | --- 4 | added_in_defaults: defaults_value 5 | added_in_lookup: lookup_value 6 | added_in_pillar: pillar_value 7 | arch: amd64 8 | config: /etc/template-formula.conf 9 | lookup: 10 | added_in_lookup: lookup_value 11 | master: template-master 12 | winner: lookup 13 | master: template-master 14 | pkg: 15 | name: bash 16 | rootgroup: root 17 | service: 18 | name: systemd-journald 19 | tofs: 20 | files_switch: 21 | - any/path/can/be/used/here 22 | - id 23 | - roles 24 | - osfinger 25 | - os 26 | - os_family 27 | source_files: 28 | zookeeper-config-file-file-managed: 29 | - example.tmpl.jinja 30 | winner: pillar 31 | -------------------------------------------------------------------------------- /test/integration/default/files/_mapdata/centos-8.yaml: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:indentation rule:line-length 2 | # CentOS Linux-8 3 | --- 4 | added_in_defaults: defaults_value 5 | added_in_lookup: lookup_value 6 | added_in_pillar: pillar_value 7 | arch: amd64 8 | config: /etc/template-formula.conf 9 | lookup: 10 | added_in_lookup: lookup_value 11 | master: template-master 12 | winner: lookup 13 | master: template-master 14 | pkg: 15 | name: bash 16 | rootgroup: root 17 | service: 18 | name: systemd-journald 19 | tofs: 20 | files_switch: 21 | - any/path/can/be/used/here 22 | - id 23 | - roles 24 | - osfinger 25 | - os 26 | - os_family 27 | source_files: 28 | zookeeper-config-file-file-managed: 29 | - example.tmpl.jinja 30 | winner: pillar 31 | -------------------------------------------------------------------------------- /test/integration/default/files/_mapdata/debian-10.yaml: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:indentation rule:line-length 2 | # Debian-10 3 | --- 4 | added_in_defaults: defaults_value 5 | added_in_lookup: lookup_value 6 | added_in_pillar: pillar_value 7 | arch: amd64 8 | config: /etc/template-formula.conf 9 | lookup: 10 | added_in_lookup: lookup_value 11 | master: template-master 12 | winner: lookup 13 | master: template-master 14 | pkg: 15 | name: bash 16 | rootgroup: root 17 | service: 18 | name: systemd-journald 19 | tofs: 20 | files_switch: 21 | - any/path/can/be/used/here 22 | - id 23 | - roles 24 | - osfinger 25 | - os 26 | - os_family 27 | source_files: 28 | zookeeper-config-file-file-managed: 29 | - example.tmpl.jinja 30 | winner: pillar 31 | -------------------------------------------------------------------------------- /test/integration/default/files/_mapdata/debian-9.yaml: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:indentation rule:line-length 2 | # Debian-9 3 | --- 4 | added_in_defaults: defaults_value 5 | added_in_lookup: lookup_value 6 | added_in_pillar: pillar_value 7 | arch: amd64 8 | config: /etc/template-formula.conf 9 | lookup: 10 | added_in_lookup: lookup_value 11 | master: template-master 12 | winner: lookup 13 | master: template-master 14 | pkg: 15 | name: bash 16 | rootgroup: root 17 | service: 18 | name: systemd-journald 19 | tofs: 20 | files_switch: 21 | - any/path/can/be/used/here 22 | - id 23 | - roles 24 | - osfinger 25 | - os 26 | - os_family 27 | source_files: 28 | zookeeper-config-file-file-managed: 29 | - example.tmpl.jinja 30 | winner: pillar 31 | -------------------------------------------------------------------------------- /test/integration/default/files/_mapdata/fedora-31.yaml: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:indentation rule:line-length 2 | # Fedora-31 3 | --- 4 | added_in_defaults: defaults_value 5 | added_in_lookup: lookup_value 6 | added_in_pillar: pillar_value 7 | arch: amd64 8 | config: /etc/template-formula.conf 9 | lookup: 10 | added_in_lookup: lookup_value 11 | master: template-master 12 | winner: lookup 13 | master: template-master 14 | pkg: 15 | name: bash 16 | rootgroup: root 17 | service: 18 | name: systemd-journald 19 | tofs: 20 | files_switch: 21 | - any/path/can/be/used/here 22 | - id 23 | - roles 24 | - osfinger 25 | - os 26 | - os_family 27 | source_files: 28 | zookeeper-config-file-file-managed: 29 | - example.tmpl.jinja 30 | winner: pillar 31 | -------------------------------------------------------------------------------- /test/integration/default/files/_mapdata/fedora-32.yaml: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:indentation rule:line-length 2 | # Fedora-32 3 | --- 4 | added_in_defaults: defaults_value 5 | added_in_lookup: lookup_value 6 | added_in_pillar: pillar_value 7 | arch: amd64 8 | config: /etc/template-formula.conf 9 | lookup: 10 | added_in_lookup: lookup_value 11 | master: template-master 12 | winner: lookup 13 | master: template-master 14 | pkg: 15 | name: bash 16 | rootgroup: root 17 | service: 18 | name: systemd-journald 19 | tofs: 20 | files_switch: 21 | - any/path/can/be/used/here 22 | - id 23 | - roles 24 | - osfinger 25 | - os 26 | - os_family 27 | source_files: 28 | zookeeper-config-file-file-managed: 29 | - example.tmpl.jinja 30 | winner: pillar 31 | -------------------------------------------------------------------------------- /test/integration/default/files/_mapdata/gentoo-2-sysd.yaml: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:indentation rule:line-length 2 | # Gentoo-2 3 | --- 4 | added_in_defaults: defaults_value 5 | added_in_lookup: lookup_value 6 | added_in_pillar: pillar_value 7 | arch: amd64 8 | config: /etc/template-formula.conf 9 | lookup: 10 | added_in_lookup: lookup_value 11 | master: template-master 12 | winner: lookup 13 | master: template-master 14 | pkg: 15 | name: app-shells/bash 16 | rootgroup: root 17 | service: 18 | name: systemd-journald 19 | tofs: 20 | files_switch: 21 | - any/path/can/be/used/here 22 | - id 23 | - roles 24 | - osfinger 25 | - os 26 | - os_family 27 | source_files: 28 | zookeeper-config-file-file-managed: 29 | - example.tmpl.jinja 30 | winner: pillar 31 | -------------------------------------------------------------------------------- /test/integration/default/files/_mapdata/gentoo-2-sysv.yaml: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:indentation rule:line-length 2 | # Gentoo-2 3 | --- 4 | added_in_defaults: defaults_value 5 | added_in_lookup: lookup_value 6 | added_in_pillar: pillar_value 7 | arch: amd64 8 | config: /etc/template-formula.conf 9 | lookup: 10 | added_in_lookup: lookup_value 11 | master: template-master 12 | winner: lookup 13 | master: template-master 14 | pkg: 15 | name: app-shells/bash 16 | rootgroup: root 17 | service: 18 | name: mtab 19 | tofs: 20 | files_switch: 21 | - any/path/can/be/used/here 22 | - id 23 | - roles 24 | - osfinger 25 | - os 26 | - os_family 27 | source_files: 28 | zookeeper-config-file-file-managed: 29 | - example.tmpl.jinja 30 | winner: pillar 31 | -------------------------------------------------------------------------------- /test/integration/default/files/_mapdata/opensuse-15.yaml: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:indentation rule:line-length 2 | # Leap-15 3 | --- 4 | added_in_defaults: defaults_value 5 | added_in_lookup: lookup_value 6 | added_in_pillar: pillar_value 7 | arch: amd64 8 | config: /etc/template-formula.conf 9 | lookup: 10 | added_in_lookup: lookup_value 11 | master: template-master 12 | winner: lookup 13 | master: template-master 14 | pkg: 15 | name: bash 16 | rootgroup: root 17 | service: 18 | name: systemd-journald 19 | tofs: 20 | files_switch: 21 | - any/path/can/be/used/here 22 | - id 23 | - roles 24 | - osfinger 25 | - os 26 | - os_family 27 | source_files: 28 | zookeeper-config-file-file-managed: 29 | - example.tmpl.jinja 30 | winner: pillar 31 | -------------------------------------------------------------------------------- /test/integration/default/files/_mapdata/oracle-7.yaml: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:indentation rule:line-length 2 | # Oracle Linux Server-7 3 | --- 4 | added_in_defaults: defaults_value 5 | added_in_lookup: lookup_value 6 | added_in_pillar: pillar_value 7 | arch: amd64 8 | config: /etc/template-formula.conf 9 | lookup: 10 | added_in_lookup: lookup_value 11 | master: template-master 12 | winner: lookup 13 | master: template-master 14 | pkg: 15 | name: bash 16 | rootgroup: root 17 | service: 18 | name: systemd-journald 19 | tofs: 20 | files_switch: 21 | - any/path/can/be/used/here 22 | - id 23 | - roles 24 | - osfinger 25 | - os 26 | - os_family 27 | source_files: 28 | zookeeper-config-file-file-managed: 29 | - example.tmpl.jinja 30 | winner: pillar 31 | -------------------------------------------------------------------------------- /test/integration/default/files/_mapdata/oracle-8.yaml: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:indentation rule:line-length 2 | # Oracle Linux Server-8 3 | --- 4 | added_in_defaults: defaults_value 5 | added_in_lookup: lookup_value 6 | added_in_pillar: pillar_value 7 | arch: amd64 8 | config: /etc/template-formula.conf 9 | lookup: 10 | added_in_lookup: lookup_value 11 | master: template-master 12 | winner: lookup 13 | master: template-master 14 | pkg: 15 | name: bash 16 | rootgroup: root 17 | service: 18 | name: systemd-journald 19 | tofs: 20 | files_switch: 21 | - any/path/can/be/used/here 22 | - id 23 | - roles 24 | - osfinger 25 | - os 26 | - os_family 27 | source_files: 28 | zookeeper-config-file-file-managed: 29 | - example.tmpl.jinja 30 | winner: pillar 31 | -------------------------------------------------------------------------------- /test/integration/default/files/_mapdata/ubuntu-16.yaml: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:indentation rule:line-length 2 | # Ubuntu-16.04 3 | --- 4 | added_in_defaults: defaults_value 5 | added_in_lookup: lookup_value 6 | added_in_pillar: pillar_value 7 | arch: amd64 8 | config: /etc/template-formula.conf 9 | lookup: 10 | added_in_lookup: lookup_value 11 | master: template-master 12 | winner: lookup 13 | master: template-master 14 | pkg: 15 | name: bash 16 | rootgroup: root 17 | service: 18 | name: systemd-journald 19 | tofs: 20 | files_switch: 21 | - any/path/can/be/used/here 22 | - id 23 | - roles 24 | - osfinger 25 | - os 26 | - os_family 27 | source_files: 28 | zookeeper-config-file-file-managed: 29 | - example.tmpl.jinja 30 | winner: pillar 31 | -------------------------------------------------------------------------------- /test/integration/default/files/_mapdata/ubuntu-18.yaml: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:indentation rule:line-length 2 | # Ubuntu-18.04 3 | --- 4 | added_in_defaults: defaults_value 5 | added_in_lookup: lookup_value 6 | added_in_pillar: pillar_value 7 | arch: amd64 8 | config: /etc/template-formula.conf 9 | lookup: 10 | added_in_lookup: lookup_value 11 | master: template-master 12 | winner: lookup 13 | master: template-master 14 | pkg: 15 | name: bash 16 | rootgroup: root 17 | service: 18 | name: systemd-journald 19 | tofs: 20 | files_switch: 21 | - any/path/can/be/used/here 22 | - id 23 | - roles 24 | - osfinger 25 | - os 26 | - os_family 27 | source_files: 28 | zookeeper-config-file-file-managed: 29 | - example.tmpl.jinja 30 | winner: pillar 31 | -------------------------------------------------------------------------------- /test/integration/default/files/_mapdata/ubuntu-20.yaml: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:indentation rule:line-length 2 | # Ubuntu-20.04 3 | --- 4 | added_in_defaults: defaults_value 5 | added_in_lookup: lookup_value 6 | added_in_pillar: pillar_value 7 | arch: amd64 8 | config: /etc/template-formula.conf 9 | lookup: 10 | added_in_lookup: lookup_value 11 | master: template-master 12 | winner: lookup 13 | master: template-master 14 | pkg: 15 | name: bash 16 | rootgroup: root 17 | service: 18 | name: systemd-journald 19 | tofs: 20 | files_switch: 21 | - any/path/can/be/used/here 22 | - id 23 | - roles 24 | - osfinger 25 | - os 26 | - os_family 27 | source_files: 28 | zookeeper-config-file-file-managed: 29 | - example.tmpl.jinja 30 | winner: pillar 31 | -------------------------------------------------------------------------------- /test/integration/default/inspec.yml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | name: default 5 | title: zookeeper formula 6 | maintainer: SaltStack Formulas 7 | license: Apache-2.0 8 | # yamllint disable-line rule:line-length 9 | summary: Verify that the zookeeper formula is setup and configured correctly 10 | depends: 11 | - name: share 12 | path: test/integration/share 13 | supports: 14 | - platform-name: debian 15 | - platform-name: ubuntu 16 | - platform-name: centos 17 | - platform-name: fedora 18 | - platform-name: opensuse 19 | - platform-name: suse 20 | - platform-name: freebsd 21 | - platform-name: amazon 22 | - platform-name: oracle 23 | - platform-name: arch 24 | - platform-name: gentoo 25 | -------------------------------------------------------------------------------- /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 15 | - `system.platform[:name]` modify `amazon` to `amazonlinux` 16 | - `system.platform[:release]` tweak Arch and Amazon Linux: 17 | - `Arch` is always `base-latest` 18 | - `Amazon Linux` release `2018` is resolved as `1` 19 | - `system.platform[:finger]` is the concatenation of the name and the major release number (except for Ubuntu, which gives `ubuntu-20.04` for example) 20 | -------------------------------------------------------------------------------- /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: amazon 18 | - platform-name: oracle 19 | - platform-name: arch 20 | - platform-name: gentoo 21 | -------------------------------------------------------------------------------- /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 | class SystemResource < Inspec.resource(1) 8 | name 'system' 9 | 10 | attr_reader :platform 11 | 12 | def initialize 13 | super 14 | @platform = build_platform 15 | end 16 | 17 | private 18 | 19 | def build_platform 20 | { 21 | family: build_platform_family, 22 | name: build_platform_name, 23 | release: build_platform_release, 24 | finger: build_platform_finger 25 | } 26 | end 27 | 28 | def build_platform_family 29 | case inspec.platform[:name] 30 | when 'arch' 31 | 'arch' 32 | else 33 | inspec.platform[:family] 34 | end 35 | end 36 | 37 | def build_platform_name 38 | case inspec.platform[:name] 39 | when 'amazon' 40 | 'amazonlinux' 41 | else 42 | inspec.platform[:name] 43 | end 44 | end 45 | 46 | def build_platform_release 47 | case inspec.platform[:name] 48 | when 'amazon' 49 | # `2018` relase is named `1` in kitchen.yaml 50 | inspec.platform[:release].gsub(/2018.*/, '1') 51 | when 'arch' 52 | 'base-latest' 53 | when 'gentoo' 54 | "#{inspec.platform[:release].split('.')[0]}-#{derive_gentoo_init_system}" 55 | else 56 | inspec.platform[:release] 57 | end 58 | end 59 | 60 | def derive_gentoo_init_system 61 | case inspec.command('systemctl').exist? 62 | when true 63 | 'sysd' 64 | else 65 | 'sysv' 66 | end 67 | end 68 | 69 | def build_platform_finger 70 | "#{build_platform_name}-#{build_finger_release}" 71 | end 72 | 73 | def build_finger_release 74 | case inspec.platform[:name] 75 | when 'ubuntu' 76 | build_platform_release.split('.').slice(0, 2).join('.') 77 | else 78 | build_platform_release.split('.')[0] 79 | end 80 | end 81 | end 82 | -------------------------------------------------------------------------------- /test/salt/pillar/define_roles.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | # libtofs.jinja must work with tofs.files_switch looked up list 5 | roles: 6 | - foo 7 | - bar 8 | -------------------------------------------------------------------------------- /test/salt/pillar/gentoo.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | portage: 5 | sync_wait_one_day: true 6 | zookeeper: 7 | pkg: 8 | name: 'app-shells/bash' 9 | service: 10 | name: "{{ 'systemd-journald' if grains.init == 'systemd' else 'mtab' }}" 11 | -------------------------------------------------------------------------------- /test/salt/pillar/upstart.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | zookeeper: 5 | lookup: 6 | master: template-master 7 | # Just for testing purposes 8 | winner: lookup 9 | added_in_lookup: lookup_value 10 | 11 | # Using bash package and udev service as an example. This allows us to 12 | # test the template formula itself. You should set these parameters to 13 | # examples that make sense in the contexto of the formula you're writing. 14 | pkg: 15 | name: cronie 16 | service: 17 | name: crond 18 | config: /etc/template-formula.conf 19 | 20 | tofs: 21 | # The files_switch key serves as a selector for alternative 22 | # directories under the formula files directory. See TOFS pattern 23 | # doc for more info. 24 | # Note: Any value not evaluated by `config.get` will be used literally. 25 | # This can be used to set custom paths, as many levels deep as required. 26 | files_switch: 27 | - any/path/can/be/used/here 28 | - id 29 | - roles 30 | - osfinger 31 | - os 32 | - os_family 33 | # All aspects of path/file resolution are customisable using the options below. 34 | # This is unnecessary in most cases; there are sensible defaults. 35 | # path_prefix: template_alt 36 | # dirs: 37 | # files: files_alt 38 | # default: default_alt 39 | # The entries under `source_files` are prepended to the default source files 40 | # given for the state 41 | # source_files: 42 | # template-config-file-file-managed: 43 | # - 'example_alt.tmpl' 44 | # - 'example_alt.tmpl.jinja' 45 | 46 | # For testing purposes 47 | source_files: 48 | zookeeper-config-file-file-managed: 49 | - 'example.tmpl.jinja' 50 | 51 | # Just for testing purposes 52 | winner: pillar 53 | added_in_pillar: pillar_value 54 | -------------------------------------------------------------------------------- /zookeeper/_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 | -------------------------------------------------------------------------------- /zookeeper/_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 zookeeper as mapdata with context %} 7 | 8 | {%- do salt['log.debug']('### MAP.JINJA DUMP ###\n' ~ mapdata | yaml(False)) %} 9 | 10 | {%- set output_file = '/tmp/salt_mapdata_dump.yaml' %} 11 | 12 | {{ tplroot }}-mapdata-dump: 13 | file.managed: 14 | - name: {{ output_file }} 15 | - source: salt://{{ tplroot }}/_mapdata/_mapdata.jinja 16 | - template: jinja 17 | - context: 18 | map: {{ mapdata | yaml }} 19 | -------------------------------------------------------------------------------- /zookeeper/archive/clean.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | {#- Get the `tplroot` from `tpldir` #} 5 | {%- set tplroot = tpldir.split('/')[0] %} 6 | {%- set sls_config_clean = tplroot ~ '.config.clean' %} 7 | {%- from tplroot ~ "/map.jinja" import zookeeper with context %} 8 | 9 | include: 10 | - {{ sls_config_clean }} 11 | 12 | zookeeper-archive-clean-pkg-removed: 13 | pkg.removed: 14 | - name: {{ zookeeper.pkg.name }} 15 | - require: 16 | - sls: {{ sls_config_clean }} 17 | -------------------------------------------------------------------------------- /zookeeper/archive/init.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | include: 5 | - .javajdk 6 | - .install 7 | -------------------------------------------------------------------------------- /zookeeper/archive/install.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 zookeeper with context %} 7 | 8 | zookeeper-dependency-install-pkg-installed: 9 | pkg.installed: 10 | - name: tar 11 | 12 | zookeeper-archive-install-pkg-installed: 13 | archive.extracted: 14 | - name: {{ zookeeper.pkg.installdir }}/zookeeper-{{ zookeeper.pkg.version }} 15 | - source: {{ zookeeper.pkg.downloadurl }} 16 | - user: {{ zookeeper.systemdconfig.user }} 17 | - group: {{ zookeeper.systemdconfig.group }} 18 | - if_missing: {{ zookeeper.pkg.installdir }}/zookeeper-{{ zookeeper.pkg.version }} 19 | - skip_verify: True 20 | - keep_source: False 21 | - options: "--strip-components=1" 22 | - enforce_toplevel: False 23 | - require: 24 | - pkg: zookeeper-dependency-install-pkg-installed 25 | -------------------------------------------------------------------------------- /zookeeper/archive/javajdk.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 zookeeper with context %} 7 | {%- if zookeeper.pkg.javajdk %} 8 | zookeeper-archive-install-dependency-javajdk: 9 | pkg.installed: 10 | - name: {{ zookeeper.pkg.javajdk }} 11 | {%- endif %} 12 | -------------------------------------------------------------------------------- /zookeeper/clean.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | include: 5 | - .service.clean 6 | - .config.clean 7 | - .archive.clean 8 | -------------------------------------------------------------------------------- /zookeeper/config/clean.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | {#- Get the `tplroot` from `tpldir` #} 5 | {%- set tplroot = tpldir.split('/')[0] %} 6 | {%- set sls_service_clean = tplroot ~ '.service.clean' %} 7 | {%- from tplroot ~ "/map.jinja" import zookeeper with context %} 8 | 9 | include: 10 | - {{ sls_service_clean }} 11 | 12 | zookeeper-config-clean-file-absent: 13 | file.absent: 14 | - name: {{ zookeeper.config }} 15 | - require: 16 | - sls: {{ sls_service_clean }} 17 | -------------------------------------------------------------------------------- /zookeeper/config/file.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | {#- Get the `tplroot` from `tpldir` #} 5 | {%- set tplroot = tpldir.split('/')[0] %} 6 | {%- set sls_archive_install = tplroot ~ '.archive.install' %} 7 | {%- from tplroot ~ "/map.jinja" import zookeeper with context %} 8 | {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} 9 | 10 | include: 11 | - {{ sls_archive_install }} 12 | 13 | zookeeper-config-file-file-managed: 14 | file.managed: 15 | - name: {{ zookeeper.pkg.installdir }}/zookeeper-{{ zookeeper.pkg.version }}/conf/zoo.cfg 16 | - source: {{ files_switch(['zoo.tmpl.jinja'], 17 | lookup='zookeeper-config-file-file-managed' 18 | ) 19 | }} 20 | - mode: 644 21 | - user: root 22 | - group: {{ zookeeper.rootgroup }} 23 | - makedirs: True 24 | - template: jinja 25 | - require: 26 | - sls: {{ sls_archive_install }} 27 | - context: 28 | zookeeper: {{ zookeeper | json }} 29 | 30 | {% if zookeeper.zookeeperproperties['customservers'] %} 31 | zookeeper-zookeepermyid-file-file-managed: 32 | file.managed: 33 | - name: {{ zookeeper.pkg.installdir }}/zookeeper-{{ zookeeper.pkg.version }}/{{ zookeeper.zookeeperproperties.dataDir | regex_replace('[(.*?)]','') }}/myid 34 | - source: {{ files_switch(['zookeepermyid.tmpl.jinja'], 35 | lookup='zookeeper-zookeepermyid-file-file-managed' 36 | ) 37 | }} 38 | - mode: 644 39 | - user: {{ zookeeper.systemdconfig.user }} 40 | - group: {{ zookeeper.systemdconfig.group }} 41 | - makedirs: True 42 | - template: jinja 43 | - require: 44 | - sls: {{ sls_archive_install }} 45 | - context: 46 | zookeeper: {{ zookeeper | json }} 47 | 48 | {% endif %} 49 | -------------------------------------------------------------------------------- /zookeeper/config/init.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | include: 5 | - .file 6 | -------------------------------------------------------------------------------- /zookeeper/defaults.yaml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | zookeeper: 5 | pkg: 6 | name: zookeeper 7 | downloadurl: > 8 | https://mirror.csclub.uwaterloo.ca/apache/zookeeper/zookeeper-3.6.2/apache-zookeeper-3.6.2-bin.tar.gz 9 | version: 3.6.2 10 | installdir: /opt 11 | 12 | # OpenJDK package name on system; defaults to an empty string, which avoids 13 | # installing OpenJDK. Overridden in the `os*map.yaml` files. 14 | javajdk: '' 15 | 16 | systemdconfig: 17 | user: root 18 | group: root 19 | limitnofile: 50000 20 | limitnproc: 10000 21 | 22 | rootgroup: root 23 | config: 'zoo.cfg' 24 | service: 25 | name: zookeeper 26 | 27 | zookeeperproperties: 28 | tickTime: 2000 29 | dataDir: ./state/zookeeper 30 | clientPort: 2181 31 | initLimit: 5 32 | syncLimit: 2 33 | customservers: '' 34 | -------------------------------------------------------------------------------- /zookeeper/files/default/example.tmpl: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | # File managed by Salt at <{{ source }}>. 3 | # Your changes will be overwritten. 4 | ######################################################################## 5 | 6 | This is an example file from SaltStack zookeeper-formula. 7 | -------------------------------------------------------------------------------- /zookeeper/files/default/example.tmpl.jinja: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | # File managed by Salt at <{{ source }}>. 3 | # Your changes will be overwritten. 4 | ######################################################################## 5 | 6 | This is another example file from SaltStack zookeeper-formula. 7 | 8 | # This is here for testing purposes 9 | {{ zookeeper | json }} 10 | 11 | winner of the merge: {{ zookeeper['winner'] }} 12 | -------------------------------------------------------------------------------- /zookeeper/files/default/systemd.tmpl.jinja: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Zookeeper Daemon 3 | Documentation=http://zookeeper.apache.org 4 | Requires=network.target 5 | After=network.target 6 | 7 | [Service] 8 | Type=forking 9 | WorkingDirectory={{ zookeeper.pkg.installdir }}/zookeeper-{{ zookeeper.pkg.version }} 10 | User={{ zookeeper.systemdconfig.user }} 11 | Group={{ zookeeper.systemdconfig.group }} 12 | ExecStart={{ zookeeper.pkg.installdir }}/zookeeper-{{ zookeeper.pkg.version }}/bin/zkServer.sh start {{ zookeeper.pkg.installdir }}/zookeeper-{{ zookeeper.pkg.version }}/conf/zoo.cfg 13 | ExecStop={{ zookeeper.pkg.installdir }}/zookeeper-{{ zookeeper.pkg.version }}/bin/zkServer.sh stop {{ zookeeper.pkg.installdir }}/zookeeper-{{ zookeeper.pkg.version }}/conf/zoo.cfg 14 | ExecReload={{ zookeeper.pkg.installdir }}/zookeeper-{{ zookeeper.pkg.version }}/bin/zkServer.sh restart {{ zookeeper.pkg.installdir }}/zookeeper-{{ zookeeper.pkg.version }}/conf/zoo.cfg 15 | TimeoutSec=30 16 | Restart=on-failure 17 | 18 | [Install] 19 | WantedBy=default.target 20 | 21 | -------------------------------------------------------------------------------- /zookeeper/files/default/zoo.tmpl.jinja: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | # File managed by Salt at <{{ source }}>. 3 | # Your changes will be overwritten. 4 | ######################################################################## 5 | tickTime={{ zookeeper.zookeeperproperties.tickTime }} 6 | dataDir={{ zookeeper.zookeeperproperties.dataDir }} 7 | initLimit={{ zookeeper.zookeeperproperties.initLimit }} 8 | syncLimit={{ zookeeper.zookeeperproperties.syncLimit }} 9 | {%- if ['zookeeper.zookeeperproperties.clientPort'] %} 10 | clientPort={{ zookeeper.zookeeperproperties.clientPort }} 11 | {%- endif %} 12 | {%- if ['zookeeper.zookeeperproperties.customservers'] %} 13 | {%- for nodes, args in zookeeper.zookeeperproperties['customservers'].items() %} 14 | server.{{ args.zookeeper_myid }}={{ args.hostname }}:{{ args.zookeeper_peerPorts }} 15 | {%- endfor %} 16 | {% endif %} 17 | 18 | -------------------------------------------------------------------------------- /zookeeper/files/default/zookeepermyid.tmpl.jinja: -------------------------------------------------------------------------------- 1 | {% set hostname = grains['fqdn'] %} 2 | {%- for nodes, args in zookeeper.zookeeperproperties['customservers'].items() %} 3 | {%- if hostname == args.hostname -%} 4 | {{ args.zookeeper_myid }} 5 | {%- endif -%} 6 | {%- endfor %} 7 | -------------------------------------------------------------------------------- /zookeeper/init.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | include: 5 | - .archive 6 | - .config 7 | - .service 8 | -------------------------------------------------------------------------------- /zookeeper/libsaltcli.jinja: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=jinja 3 | 4 | {#- Get the relevant values from the `opts` dict #} 5 | {%- set opts_cli = opts.get('__cli', '') %} 6 | {%- set opts_masteropts_cli = opts | traverse('__master_opts__:__cli', '') %} 7 | 8 | {#- Determine the type of salt command being run #} 9 | {%- if opts_cli == 'salt-minion' %} 10 | {%- set cli = 'minion' %} 11 | {%- elif opts_cli == 'salt-call' %} 12 | {%- set cli = 'ssh' if opts_masteropts_cli in ('salt-ssh', 'salt-master') else 'local' %} 13 | {%- else %} 14 | {%- set cli = 'unknown' %} 15 | {%- endif %} 16 | {%- do salt['log.debug']('[libsaltcli] the salt command type has been identified to be: ' ~ cli) %} 17 | -------------------------------------------------------------------------------- /zookeeper/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 | -------------------------------------------------------------------------------- /zookeeper/map.jinja: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=jinja 3 | 4 | {#- Get the `tplroot` from `tpldir` #} 5 | {%- set tplroot = tpldir.split('/')[0] %} 6 | {#- Start imports as #} 7 | {%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %} 8 | {%- import_yaml tplroot ~ "/osarchmap.yaml" as osarchmap %} 9 | {%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %} 10 | {%- import_yaml tplroot ~ "/osmap.yaml" as osmap %} 11 | {%- import_yaml tplroot ~ "/osfingermap.yaml" as osfingermap %} 12 | 13 | {#- Retrieve the config dict only once #} 14 | {%- set _config = salt['config.get'](tplroot, default={}) %} 15 | 16 | {%- set defaults = salt['grains.filter_by']( 17 | default_settings, 18 | default=tplroot, 19 | merge=salt['grains.filter_by']( 20 | osarchmap, 21 | grain='osarch', 22 | merge=salt['grains.filter_by']( 23 | osfamilymap, 24 | grain='os_family', 25 | merge=salt['grains.filter_by']( 26 | osmap, 27 | grain='os', 28 | merge=salt['grains.filter_by']( 29 | osfingermap, 30 | grain='osfinger', 31 | merge=salt['grains.filter_by']( 32 | _config, 33 | default='lookup' 34 | ) 35 | ) 36 | ) 37 | ) 38 | ) 39 | ) 40 | %} 41 | 42 | {%- set config = salt['grains.filter_by']( 43 | {'defaults': defaults}, 44 | default='defaults', 45 | merge=_config 46 | ) 47 | %} 48 | 49 | {%- set zookeeper = config %} 50 | 51 | {#- Post-processing for specific non-YAML customisations #} 52 | {%- if grains.os == 'MacOS' %} 53 | {%- set macos_group = salt['cmd.run']("stat -f '%Sg' /dev/console") %} 54 | {%- do zookeeper.update({'rootgroup': macos_group}) %} 55 | {%- endif %} 56 | -------------------------------------------------------------------------------- /zookeeper/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`. 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: amd64 15 | 16 | x86_64: 17 | arch: amd64 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 | -------------------------------------------------------------------------------- /zookeeper/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` + `osarch.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 | Debian: 14 | pkg: 15 | javajdk: 'openjdk-11-jdk' 16 | 17 | RedHat: 18 | pkg: 19 | javajdk: 'java-11-openjdk' 20 | 21 | Suse: 22 | pkg: 23 | name: zookeeper-suse 24 | 25 | Gentoo: 26 | pkg: 27 | name: zookeeper-gentoo 28 | 29 | Arch: 30 | pkg: 31 | name: zookeeper-arch 32 | service: 33 | name: service-arch 34 | 35 | Alpine: {} 36 | 37 | FreeBSD: 38 | rootgroup: wheel 39 | 40 | OpenBSD: 41 | rootgroup: wheel 42 | 43 | Solaris: {} 44 | 45 | Windows: {} 46 | 47 | MacOS: {} 48 | -------------------------------------------------------------------------------- /zookeeper/osfingermap.yaml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | # 4 | # Setup variables using grains['osfinger'] based logic. 5 | # You just need to add the key:values for an `osfinger` that differ 6 | # from `defaults.yaml` + `osarch.yaml` + `os_family.yaml` + `osmap.yaml`. 7 | # Only add an `osfinger` which is/will be supported by the formula. 8 | # 9 | # If you do not need to provide defaults via the `os_finger` grain, 10 | # you will need to provide at least an empty dict in this file, e.g. 11 | # osfingermap: {} 12 | --- 13 | # os: Debian 14 | Debian-10: {} 15 | Debian-9: {} 16 | Debian-8: {} 17 | 18 | # os: Ubuntu 19 | Ubuntu-18.04: {} 20 | Ubuntu-16.04: {} 21 | 22 | # os: Fedora 23 | Fedora-31: {} 24 | Fedora-30: {} 25 | 26 | # os: CentOS 27 | CentOS Linux-8: {} 28 | CentOS Linux-7: {} 29 | CentOS-6: {} 30 | 31 | # os: Amazon 32 | Amazon Linux-2: {} 33 | Amazon Linux AMI-2018: {} 34 | 35 | # os: SUSE 36 | Leap-15: {} 37 | 38 | # os: FreeBSD 39 | FreeBSD-12: {} 40 | 41 | # os: Windows 42 | Windows-8.1: {} 43 | 44 | # os: Gentoo 45 | Gentoo-2: {} 46 | -------------------------------------------------------------------------------- /zookeeper/osmap.yaml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | # 4 | # Setup variables using grains['os'] based logic. 5 | # You just need to add the key:values for an `os` that differ 6 | # from `defaults.yaml` + `osarch.yaml` + `os_family.yaml`. 7 | # Only add an `os` which is/will be supported by the formula. 8 | # 9 | # If you do not need to provide defaults via the `os` grain, 10 | # you will need to provide at least an empty dict in this file, e.g. 11 | # osmap: {} 12 | --- 13 | # os_family: Debian 14 | Ubuntu: 15 | pkg: 16 | name: zookeeper 17 | Raspbian: {} 18 | 19 | # os_family: RedHat 20 | Fedora: 21 | pkg: 22 | name: zookeeper 23 | CentOS: {} 24 | Amazon: {} 25 | 26 | # os_family: Suse 27 | SUSE: {} 28 | openSUSE: {} 29 | 30 | # os_family: Gentoo 31 | Funtoo: {} 32 | 33 | # os_family: Arch 34 | Manjaro: {} 35 | 36 | # os_family: Solaris 37 | SmartOS: {} 38 | -------------------------------------------------------------------------------- /zookeeper/service/clean.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 zookeeper with context %} 7 | 8 | zookeeper-service-clean-service-dead: 9 | service.dead: 10 | - name: {{ zookeeper.service.name }} 11 | - enable: False 12 | -------------------------------------------------------------------------------- /zookeeper/service/init.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | include: 5 | - .running 6 | -------------------------------------------------------------------------------- /zookeeper/service/running.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | {#- Get the `tplroot` from `tpldir` #} 5 | {%- set tplroot = tpldir.split('/')[0] %} 6 | {%- set sls_config_file = tplroot ~ '.config.file' %} 7 | {%- from tplroot ~ "/map.jinja" import zookeeper with context %} 8 | {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} 9 | 10 | include: 11 | - {{ sls_config_file }} 12 | 13 | zookeeper-systemd-file-file-managed: 14 | file.managed: 15 | - name: /etc/systemd/system/zookeeper.service 16 | - source: {{ files_switch(['systemd.tmpl.jinja'], 17 | lookup='zookeeper-systemd-file-file-managed' 18 | ) 19 | }} 20 | - mode: 644 21 | - user: root 22 | - group: root 23 | - makedirs: True 24 | - template: jinja 25 | - require: 26 | - sls: {{ sls_config_file }} 27 | - context: 28 | zookeeper: {{ zookeeper | json }} 29 | 30 | zookeeper-service-running-service-running: 31 | service.running: 32 | - name: {{ zookeeper.service.name }} 33 | - enable: True 34 | - watch: 35 | - sls: {{ sls_config_file }} 36 | 37 | 38 | --------------------------------------------------------------------------------