├── .github └── workflows │ ├── commitlint.yml │ └── kitchen.vagrant.yml ├── .gitignore ├── .gitlab-ci.yml ├── .pre-commit-config.yaml ├── .rstcheck.cfg ├── .rubocop.yml ├── .salt-lint ├── .travis.yml ├── .yamllint ├── AUTHORS.md ├── CHANGELOG.md ├── CODEOWNERS ├── FORMULA ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── bin ├── install-hooks └── kitchen ├── commitlint.config.js ├── consul-template ├── config.sls ├── defaults.yaml ├── files │ ├── config.json │ ├── consul-template-upstart.service │ ├── consul-template.service │ └── example.ctmpl ├── init.sls ├── install.sls ├── map.jinja └── service.sls ├── consul ├── _mapdata │ ├── _mapdata.jinja │ └── init.sls ├── config.sls ├── files │ ├── FreeBSD │ │ └── consul_service_unit.jinja │ ├── config.json │ ├── systemd │ │ └── consul_service_unit.jinja │ ├── sysvinit │ │ └── consul_service_unit.jinja │ └── upstart │ │ └── consul_service_unit.jinja ├── init.sls ├── install.sls ├── libmapstack.jinja ├── libmatchers.jinja ├── libsaltcli.jinja ├── libtofs.jinja ├── map.jinja ├── parameters │ ├── cpuarch │ │ ├── amd64.yaml │ │ ├── arm64.yaml │ │ ├── armv6l.yaml │ │ ├── armv7l.yaml │ │ └── x86_64.yaml │ ├── defaults.yaml │ ├── init │ │ ├── sysvinit.yaml │ │ └── upstart.yaml │ ├── map_jinja.yaml │ └── os_family │ │ ├── Debian.yaml │ │ └── FreeBSD.yaml ├── post-map.jinja └── service.sls ├── docs ├── AUTHORS.rst ├── CHANGELOG.rst ├── README.rst └── TOFS_pattern.rst ├── kitchen.vagrant.yml ├── kitchen.yml ├── pillar.example ├── pre-commit_semantic-release.sh ├── release-rules.js ├── release.config.js └── test ├── integration ├── default │ ├── README.md │ ├── controls │ │ ├── _mapdata.rb │ │ └── service_spec.rb │ ├── files │ │ └── _mapdata │ │ │ ├── almalinux-8.yaml │ │ │ ├── amazonlinux-2.yaml │ │ │ ├── arch-base-latest.yaml │ │ │ ├── centos-7.yaml │ │ │ ├── centos-8.yaml │ │ │ ├── debian-10.yaml │ │ │ ├── debian-11.yaml │ │ │ ├── debian-9.yaml │ │ │ ├── fedora-34.yaml │ │ │ ├── fedora-35.yaml │ │ │ ├── fedora-36.yaml │ │ │ ├── freebsd-12.yaml │ │ │ ├── freebsd-13.yaml │ │ │ ├── gentoo-2-sysd.yaml │ │ │ ├── gentoo-2-sysv.yaml │ │ │ ├── opensuse-15.yaml │ │ │ ├── opensuse-tumbleweed.yaml │ │ │ ├── oraclelinux-7.yaml │ │ │ ├── oraclelinux-8.yaml │ │ │ ├── rockylinux-8.yaml │ │ │ ├── ubuntu-18.yaml │ │ │ ├── ubuntu-20.yaml │ │ │ └── ubuntu-22.yaml │ └── inspec.yml └── share │ ├── README.md │ ├── inspec.yml │ └── libraries │ └── system.rb └── salt └── pillar └── default.sls /.github/workflows/commitlint.yml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | name: Commitlint 5 | 'on': [pull_request] 6 | 7 | jobs: 8 | lint: 9 | runs-on: ubuntu-latest 10 | env: 11 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 12 | steps: 13 | - uses: actions/checkout@v2 14 | with: 15 | fetch-depth: 0 16 | - uses: wagoid/commitlint-github-action@v1 17 | -------------------------------------------------------------------------------- /.github/workflows/kitchen.vagrant.yml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | name: 'Kitchen Vagrant (FreeBSD)' 5 | 'on': ['push', 'pull_request'] 6 | 7 | env: 8 | KITCHEN_LOCAL_YAML: 'kitchen.vagrant.yml' 9 | 10 | jobs: 11 | test: 12 | runs-on: 'macos-10.15' 13 | strategy: 14 | fail-fast: false 15 | matrix: 16 | instance: 17 | - default-freebsd-130-master-py3 18 | - default-freebsd-123-master-py3 19 | # - default-freebsd-130-3004-0-py3 20 | # - default-freebsd-123-3004-0-py3 21 | steps: 22 | - name: 'Check out code' 23 | uses: 'actions/checkout@v2' 24 | - name: 'Set up Bundler cache' 25 | uses: 'actions/cache@v1' 26 | with: 27 | path: 'vendor/bundle' 28 | key: "${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}" 29 | restore-keys: "${{ runner.os }}-gems-" 30 | - name: 'Run Bundler' 31 | run: | 32 | ruby --version 33 | bundle config path vendor/bundle 34 | bundle install --jobs 4 --retry 3 35 | - name: 'Run Test Kitchen' 36 | run: 'bundle exec kitchen verify ${{ matrix.instance }}' 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a packager 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .kitchen 49 | .kitchen.local.yml 50 | kitchen.local.yml 51 | junit-*.xml 52 | 53 | # Translations 54 | *.mo 55 | *.pot 56 | 57 | # Django stuff: 58 | *.log 59 | local_settings.py 60 | 61 | # Flask stuff: 62 | instance/ 63 | .webassets-cache 64 | 65 | # Scrapy stuff: 66 | .scrapy 67 | 68 | # Sphinx documentation 69 | docs/_build/ 70 | 71 | # PyBuilder 72 | target/ 73 | 74 | # Jupyter Notebook 75 | .ipynb_checkpoints 76 | 77 | # pyenv 78 | .python-version 79 | 80 | # celery beat schedule file 81 | celerybeat-schedule 82 | 83 | # SageMath parsed files 84 | *.sage.py 85 | 86 | # dotenv 87 | .env 88 | 89 | # virtualenv 90 | .venv 91 | venv/ 92 | ENV/ 93 | 94 | # visual studio 95 | .vs/ 96 | 97 | # Spyder project settings 98 | .spyderproject 99 | .spyproject 100 | 101 | # Rope project settings 102 | .ropeproject 103 | 104 | # mkdocs documentation 105 | /site 106 | 107 | # mypy 108 | .mypy_cache/ 109 | 110 | # Bundler 111 | .bundle/ 112 | 113 | # copied `.md` files used for conversion to `.rst` using `m2r` 114 | docs/*.md 115 | 116 | # Vim 117 | *.sw? 118 | 119 | ## Collected when centralising formulas (check and sort) 120 | # `collectd-formula` 121 | .pytest_cache/ 122 | /.idea/ 123 | Dockerfile.*_* 124 | ignore/ 125 | tmp/ 126 | 127 | # `salt-formula` -- Vagrant Specific files 128 | .vagrant 129 | top.sls 130 | !test/salt/pillar/top.sls 131 | 132 | # `suricata-formula` -- Platform binaries 133 | *.rpm 134 | *.deb 135 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | ############################################################################### 5 | # Define all YAML node anchors 6 | ############################################################################### 7 | .node_anchors: 8 | # `only` (also used for `except` where applicable) 9 | only_branch_master_parent_repo: &only_branch_master_parent_repo 10 | - 'master@saltstack-formulas/consul-formula' 11 | # `stage` 12 | stage_lint: &stage_lint 'lint' 13 | stage_release: &stage_release 'release' 14 | stage_test: &stage_test 'test' 15 | # `image` 16 | image_commitlint: &image_commitlint 'myii/ssf-commitlint:11' 17 | image_dindruby: &image_dindruby 'myii/ssf-dind-ruby:2.7.1-r3' 18 | image_precommit: &image_precommit 19 | name: 'myii/ssf-pre-commit:2.9.2' 20 | entrypoint: ['/bin/bash', '-c'] 21 | image_rubocop: &image_rubocop 'pipelinecomponents/rubocop:latest' 22 | image_semantic-release: &image_semanticrelease 'myii/ssf-semantic-release:15.14' 23 | # `services` 24 | services_docker_dind: &services_docker_dind 25 | - 'docker:dind' 26 | # `variables` 27 | # https://forum.gitlab.com/t/gitlab-com-ci-caching-rubygems/5627/3 28 | # https://bundler.io/v1.16/bundle_config.html 29 | variables_bundler: &variables_bundler 30 | BUNDLE_CACHE_PATH: '${CI_PROJECT_DIR}/.cache/bundler' 31 | BUNDLE_WITHOUT: 'production' 32 | # `cache` 33 | cache_bundler: &cache_bundler 34 | key: '${CI_JOB_STAGE}' 35 | paths: 36 | - '${BUNDLE_CACHE_PATH}' 37 | 38 | ############################################################################### 39 | # Define stages and global variables 40 | ############################################################################### 41 | stages: 42 | - *stage_lint 43 | - *stage_test 44 | - *stage_release 45 | variables: 46 | DOCKER_DRIVER: 'overlay2' 47 | 48 | ############################################################################### 49 | # `lint` stage: `commitlint`, `pre-commit` & `rubocop` (latest, failure allowed) 50 | ############################################################################### 51 | commitlint: 52 | stage: *stage_lint 53 | image: *image_commitlint 54 | script: 55 | # Add `upstream` remote to get access to `upstream/master` 56 | - 'git remote add upstream 57 | https://gitlab.com/saltstack-formulas/consul-formula.git' 58 | - 'git fetch --all' 59 | # Set default commit hashes for `--from` and `--to` 60 | - 'export COMMITLINT_FROM="$(git merge-base upstream/master HEAD)"' 61 | - 'export COMMITLINT_TO="${CI_COMMIT_SHA}"' 62 | # `coqbot` adds a merge commit to test PRs on top of the latest commit in 63 | # the repo; amend this merge commit message to avoid failure 64 | - | 65 | if [ "${GITLAB_USER_LOGIN}" = "coqbot" ] \ 66 | && [ "${CI_COMMIT_BRANCH}" != "master" ]; then 67 | git commit --amend -m \ 68 | 'chore: reword coqbot merge commit message for commitlint' 69 | export COMMITLINT_TO=HEAD 70 | fi 71 | # Run `commitlint` 72 | - 'commitlint --from "${COMMITLINT_FROM}" 73 | --to "${COMMITLINT_TO}" 74 | --verbose' 75 | 76 | pre-commit: 77 | stage: *stage_lint 78 | image: *image_precommit 79 | # https://pre-commit.com/#gitlab-ci-example 80 | variables: 81 | PRE_COMMIT_HOME: '${CI_PROJECT_DIR}/.cache/pre-commit' 82 | cache: 83 | key: '${CI_JOB_NAME}' 84 | paths: 85 | - '${PRE_COMMIT_HOME}' 86 | script: 87 | - 'pre-commit run --all-files --color always --verbose' 88 | 89 | # Use a separate job for `rubocop` other than the one potentially run by `pre-commit` 90 | # - The `pre-commit` check will only be available for formulas that pass the default 91 | # `rubocop` check -- and must continue to do so 92 | # - This job is allowed to fail, so can be used for all formulas 93 | # - Furthermore, this job uses all of the latest `rubocop` features & cops, 94 | # which will help when upgrading the `rubocop` linter used in `pre-commit` 95 | rubocop: 96 | allow_failure: true 97 | stage: *stage_lint 98 | image: *image_rubocop 99 | script: 100 | - 'rubocop -d -P -S --enable-pending-cops' 101 | 102 | ############################################################################### 103 | # Define `test` template 104 | ############################################################################### 105 | .test_instance: &test_instance 106 | stage: *stage_test 107 | image: *image_dindruby 108 | services: *services_docker_dind 109 | variables: *variables_bundler 110 | cache: *cache_bundler 111 | before_script: 112 | # TODO: This should work from the env vars above automatically 113 | - 'bundle config set path "${BUNDLE_CACHE_PATH}"' 114 | - 'bundle config set without "${BUNDLE_WITHOUT}"' 115 | - 'bundle install' 116 | script: 117 | # Alternative value to consider: `${CI_JOB_NAME}` 118 | - 'bin/kitchen verify "${DOCKER_ENV_CI_JOB_NAME}"' 119 | 120 | ############################################################################### 121 | # Define `test` template (`allow_failure: true`) 122 | ############################################################################### 123 | .test_instance_failure_permitted: 124 | <<: *test_instance 125 | allow_failure: true 126 | 127 | ############################################################################### 128 | # `test` stage: each instance below uses the `test` template above 129 | ############################################################################### 130 | ## Define the rest of the matrix based on Kitchen testing 131 | # Make sure the instances listed below match up with 132 | # the `platforms` defined in `kitchen.yml` 133 | # yamllint disable rule:line-length 134 | # default-debian-11-tiamat-py3: {extends: '.test_instance'} 135 | # default-debian-10-tiamat-py3: {extends: '.test_instance'} 136 | # default-debian-9-tiamat-py3: {extends: '.test_instance'} 137 | # default-ubuntu-2204-tiamat-py3: {extends: '.test_instance_failure_permitted'} 138 | # default-ubuntu-2004-tiamat-py3: {extends: '.test_instance'} 139 | # default-ubuntu-1804-tiamat-py3: {extends: '.test_instance'} 140 | # default-centos-stream8-tiamat-py3: {extends: '.test_instance_failure_permitted'} 141 | # default-centos-7-tiamat-py3: {extends: '.test_instance'} 142 | # default-amazonlinux-2-tiamat-py3: {extends: '.test_instance'} 143 | # default-oraclelinux-8-tiamat-py3: {extends: '.test_instance'} 144 | # default-oraclelinux-7-tiamat-py3: {extends: '.test_instance'} 145 | # default-almalinux-8-tiamat-py3: {extends: '.test_instance'} 146 | # default-rockylinux-8-tiamat-py3: {extends: '.test_instance'} 147 | default-debian-11-master-py3: {extends: '.test_instance'} 148 | default-debian-10-master-py3: {extends: '.test_instance'} 149 | default-debian-9-master-py3: {extends: '.test_instance'} 150 | default-ubuntu-2204-master-py3: {extends: '.test_instance_failure_permitted'} 151 | default-ubuntu-2004-master-py3: {extends: '.test_instance'} 152 | default-ubuntu-1804-master-py3: {extends: '.test_instance'} 153 | default-centos-stream8-master-py3: {extends: '.test_instance_failure_permitted'} 154 | default-centos-7-master-py3: {extends: '.test_instance'} 155 | default-fedora-36-master-py3: {extends: '.test_instance_failure_permitted'} 156 | default-fedora-35-master-py3: {extends: '.test_instance'} 157 | default-opensuse-leap-153-master-py3: {extends: '.test_instance'} 158 | default-opensuse-tmbl-latest-master-py3: {extends: '.test_instance_failure_permitted'} 159 | default-amazonlinux-2-master-py3: {extends: '.test_instance'} 160 | default-oraclelinux-8-master-py3: {extends: '.test_instance'} 161 | default-oraclelinux-7-master-py3: {extends: '.test_instance'} 162 | default-arch-base-latest-master-py3: {extends: '.test_instance'} 163 | # default-gentoo-stage3-latest-master-py3: {extends: '.test_instance'} 164 | default-gentoo-stage3-systemd-master-py3: {extends: '.test_instance'} 165 | default-almalinux-8-master-py3: {extends: '.test_instance'} 166 | default-rockylinux-8-master-py3: {extends: '.test_instance'} 167 | # default-debian-11-3004-1-py3: {extends: '.test_instance'} 168 | # default-debian-10-3004-1-py3: {extends: '.test_instance'} 169 | # default-debian-9-3004-1-py3: {extends: '.test_instance'} 170 | # default-ubuntu-2204-3004-1-py3: {extends: '.test_instance_failure_permitted'} 171 | # default-ubuntu-2004-3004-1-py3: {extends: '.test_instance'} 172 | # default-ubuntu-1804-3004-1-py3: {extends: '.test_instance'} 173 | # default-centos-stream8-3004-1-py3: {extends: '.test_instance_failure_permitted'} 174 | # default-centos-7-3004-1-py3: {extends: '.test_instance'} 175 | # default-fedora-36-3004-1-py3: {extends: '.test_instance_failure_permitted'} 176 | # default-fedora-35-3004-1-py3: {extends: '.test_instance'} 177 | # default-amazonlinux-2-3004-1-py3: {extends: '.test_instance'} 178 | # default-oraclelinux-8-3004-1-py3: {extends: '.test_instance'} 179 | # default-oraclelinux-7-3004-1-py3: {extends: '.test_instance'} 180 | # default-arch-base-latest-3004-1-py3: {extends: '.test_instance'} 181 | # default-gentoo-stage3-latest-3004-1-py3: {extends: '.test_instance'} 182 | # default-gentoo-stage3-systemd-3004-1-py3: {extends: '.test_instance'} 183 | # default-almalinux-8-3004-1-py3: {extends: '.test_instance'} 184 | # default-rockylinux-8-3004-1-py3: {extends: '.test_instance'} 185 | # default-opensuse-leap-153-3004-0-py3: {extends: '.test_instance'} 186 | # default-opensuse-tmbl-latest-3004-0-py3: {extends: '.test_instance_failure_permitted'} 187 | # default-debian-10-3003-4-py3: {extends: '.test_instance'} 188 | # default-debian-9-3003-4-py3: {extends: '.test_instance'} 189 | # default-ubuntu-2004-3003-4-py3: {extends: '.test_instance'} 190 | # default-ubuntu-1804-3003-4-py3: {extends: '.test_instance'} 191 | # default-centos-stream8-3003-4-py3: {extends: '.test_instance_failure_permitted'} 192 | # default-centos-7-3003-4-py3: {extends: '.test_instance'} 193 | # default-amazonlinux-2-3003-4-py3: {extends: '.test_instance'} 194 | # default-oraclelinux-8-3003-4-py3: {extends: '.test_instance'} 195 | # default-oraclelinux-7-3003-4-py3: {extends: '.test_instance'} 196 | # default-almalinux-8-3003-4-py3: {extends: '.test_instance'} 197 | # yamllint enable rule:line-length 198 | 199 | ############################################################################### 200 | # `release` stage: `semantic-release` 201 | ############################################################################### 202 | semantic-release: 203 | only: *only_branch_master_parent_repo 204 | stage: *stage_release 205 | image: *image_semanticrelease 206 | variables: 207 | MAINTAINER_TOKEN: '${GH_TOKEN}' 208 | script: 209 | # Update `AUTHORS.md` 210 | - '${HOME}/go/bin/maintainer contributor' 211 | # Run `semantic-release` 212 | - 'semantic-release' 213 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | # See https://pre-commit.com for more information 5 | # See https://pre-commit.com/hooks.html for more hooks 6 | ci: 7 | autofix_commit_msg: | 8 | ci(pre-commit.ci): apply auto fixes from pre-commit.com hooks 9 | 10 | For more information, see https://pre-commit.ci 11 | autofix_prs: true 12 | autoupdate_branch: '' 13 | autoupdate_commit_msg: | 14 | ci(pre-commit.ci): perform `pre-commit` autoupdate 15 | autoupdate_schedule: quarterly 16 | skip: [] 17 | submodules: false 18 | default_stages: [commit] 19 | repos: 20 | - repo: https://github.com/dafyddj/commitlint-pre-commit-hook 21 | rev: v2.3.0 22 | hooks: 23 | - id: commitlint 24 | name: Check commit message using commitlint 25 | description: Lint commit message against @commitlint/config-conventional rules 26 | stages: [commit-msg] 27 | additional_dependencies: ['@commitlint/config-conventional@8.3.4'] 28 | - id: commitlint-travis 29 | stages: [manual] 30 | additional_dependencies: ['@commitlint/config-conventional@8.3.4'] 31 | always_run: true 32 | - repo: https://github.com/rubocop-hq/rubocop 33 | rev: v1.30.1 34 | hooks: 35 | - id: rubocop 36 | name: Check Ruby files with rubocop 37 | args: [--debug] 38 | always_run: true 39 | pass_filenames: false 40 | - repo: https://github.com/shellcheck-py/shellcheck-py 41 | rev: v0.8.0.4 42 | hooks: 43 | - id: shellcheck 44 | name: Check shell scripts with shellcheck 45 | files: ^.*\.(sh|bash|ksh)$ 46 | types: [] 47 | - repo: https://github.com/adrienverge/yamllint 48 | rev: v1.26.3 49 | hooks: 50 | - id: yamllint 51 | name: Check YAML syntax with yamllint 52 | args: [--strict, '.'] 53 | always_run: true 54 | pass_filenames: false 55 | - repo: https://github.com/warpnet/salt-lint 56 | rev: v0.8.0 57 | hooks: 58 | - id: salt-lint 59 | name: Check Salt files using salt-lint 60 | files: ^.*\.(sls|jinja|j2|tmpl|tst)$ 61 | - repo: https://github.com/myint/rstcheck 62 | rev: 3f929574 63 | hooks: 64 | - id: rstcheck 65 | name: Check reST files using rstcheck 66 | exclude: 'docs/CHANGELOG.rst' 67 | - repo: https://github.com/saltstack-formulas/mirrors-rst-lint 68 | rev: v1.3.2 69 | hooks: 70 | - id: rst-lint 71 | name: Check reST files using rst-lint 72 | exclude: | 73 | (?x)^( 74 | docs/CHANGELOG.rst| 75 | docs/TOFS_pattern.rst| 76 | )$ 77 | additional_dependencies: [pygments==2.9.0] 78 | -------------------------------------------------------------------------------- /.rstcheck.cfg: -------------------------------------------------------------------------------- 1 | [rstcheck] 2 | report=info 3 | ignore_language=rst 4 | ignore_messages=(Duplicate (ex|im)plicit target.*|Hyperlink target ".*" is not referenced\.$) 5 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | # General overrides used across formulas in the org 5 | Layout/LineLength: 6 | # Increase from default of `80` 7 | # Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`) 8 | Max: 88 9 | Metrics/BlockLength: 10 | IgnoredMethods: 11 | - control 12 | - describe 13 | # Increase from default of `25` 14 | Max: 30 15 | Security/YAMLLoad: 16 | Exclude: 17 | - test/integration/**/_mapdata.rb 18 | 19 | # General settings across all cops in this formula 20 | AllCops: 21 | NewCops: enable 22 | 23 | # Any offenses that should be fixed, e.g. collected via. `rubocop --auto-gen-config` 24 | -------------------------------------------------------------------------------- /.salt-lint: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | exclude_paths: [] 5 | rules: {} 6 | skip_list: 7 | # Using `salt-lint` for linting other files as well, such as Jinja macros/templates 8 | - 205 # Use ".sls" as a Salt State file extension 9 | # Skipping `207` and `208` because `210` is sufficient, at least for the time-being 10 | # I.e. Allows 3-digit unquoted codes to still be used, such as `644` and `755` 11 | - 207 # File modes should always be encapsulated in quotation marks 12 | - 208 # File modes should always contain a leading zero 13 | tags: [] 14 | verbosity: 1 15 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | ################################################################################ 5 | # NOTE: This file is UNMAINTAINED; it is provided for references purposes only. 6 | # No guarantees are tendered that this structure will work after 2020. 7 | ################################################################################ 8 | # * https://en.wikipedia.org/wiki/Travis_CI: 9 | # - "... free open-source plans were removed in [sic] the end of 2020" 10 | # - https://blog.travis-ci.com/2020-11-02-travis-ci-new-billing 11 | # - https://ropensci.org/technotes/2020/11/19/moving-away-travis/ 12 | ################################################################################ 13 | ## Machine config 14 | os: 'linux' 15 | arch: 'amd64' 16 | dist: 'bionic' 17 | version: '~> 1.0' 18 | 19 | ## Language and cache config 20 | language: 'ruby' 21 | cache: 'bundler' 22 | 23 | ## Services config 24 | services: 25 | - docker 26 | 27 | ## Script to run for the test stage 28 | script: 29 | - bin/kitchen verify "${INSTANCE}" 30 | 31 | ## Stages and jobs matrix 32 | stages: 33 | - test 34 | # # As part of the switch away from Travis CI, ensure that the `release` stage 35 | # # is not run inadvertently 36 | # - name: 'release' 37 | # if: 'branch = master AND type != pull_request' 38 | jobs: 39 | include: 40 | ## Define the test stage that runs the linters (and testing matrix, if applicable) 41 | 42 | # Run all of the linters in a single job 43 | - language: 'node_js' 44 | node_js: 'lts/*' 45 | env: 'Lint' 46 | name: 'Lint: salt-lint, yamllint, rubocop, shellcheck & commitlint' 47 | before_install: 'skip' 48 | script: 49 | # Install and run `salt-lint` 50 | - pip install --user salt-lint 51 | - git ls-files -- '*.sls' '*.jinja' '*.j2' '*.tmpl' '*.tst' 52 | | xargs salt-lint 53 | # Install and run `yamllint` 54 | # Need at least `v1.17.0` for the `yaml-files` setting 55 | - pip install --user yamllint>=1.17.0 56 | - yamllint -s . 57 | # Install and run `rubocop` 58 | - gem install rubocop 59 | - rubocop -d 60 | # Run `shellcheck` (already pre-installed in Travis) 61 | - shellcheck --version 62 | - git ls-files -- '*.sh' '*.bash' '*.ksh' 63 | | xargs shellcheck 64 | # Install and run `commitlint` 65 | - npm i -D @commitlint/config-conventional 66 | @commitlint/travis-cli 67 | - commitlint-travis 68 | 69 | # Run `pre-commit` linters in a single job 70 | - language: 'python' 71 | env: 'Lint_pre-commit' 72 | name: 'Lint: pre-commit' 73 | before_install: 'skip' 74 | cache: 75 | directories: 76 | - $HOME/.cache/pre-commit 77 | script: 78 | # Install and run `pre-commit` 79 | - pip install pre-commit==2.7.1 80 | - pre-commit run --all-files --color always --verbose 81 | - pre-commit run --color always --hook-stage manual --verbose commitlint-travis 82 | 83 | ## Define the rest of the matrix based on Kitchen testing 84 | # Make sure the instances listed below match up with 85 | # the `platforms` defined in `kitchen.yml` 86 | # - env: INSTANCE=default-debian-11-tiamat-py3 87 | # - env: INSTANCE=default-debian-10-tiamat-py3 88 | # - env: INSTANCE=default-debian-9-tiamat-py3 89 | # - env: INSTANCE=default-ubuntu-2204-tiamat-py3 90 | # - env: INSTANCE=default-ubuntu-2004-tiamat-py3 91 | # - env: INSTANCE=default-ubuntu-1804-tiamat-py3 92 | # - env: INSTANCE=default-centos-stream8-tiamat-py3 93 | # - env: INSTANCE=default-centos-7-tiamat-py3 94 | # - env: INSTANCE=default-amazonlinux-2-tiamat-py3 95 | # - env: INSTANCE=default-oraclelinux-8-tiamat-py3 96 | # - env: INSTANCE=default-oraclelinux-7-tiamat-py3 97 | # - env: INSTANCE=default-almalinux-8-tiamat-py3 98 | # - env: INSTANCE=default-rockylinux-8-tiamat-py3 99 | - env: INSTANCE=default-debian-11-master-py3 100 | - env: INSTANCE=default-debian-10-master-py3 101 | - env: INSTANCE=default-debian-9-master-py3 102 | - env: INSTANCE=default-ubuntu-2204-master-py3 103 | - env: INSTANCE=default-ubuntu-2004-master-py3 104 | - env: INSTANCE=default-ubuntu-1804-master-py3 105 | - env: INSTANCE=default-centos-stream8-master-py3 106 | - env: INSTANCE=default-centos-7-master-py3 107 | - env: INSTANCE=default-fedora-36-master-py3 108 | - env: INSTANCE=default-fedora-35-master-py3 109 | - env: INSTANCE=default-opensuse-leap-153-master-py3 110 | - env: INSTANCE=default-opensuse-tmbl-latest-master-py3 111 | - env: INSTANCE=default-amazonlinux-2-master-py3 112 | - env: INSTANCE=default-oraclelinux-8-master-py3 113 | - env: INSTANCE=default-oraclelinux-7-master-py3 114 | - env: INSTANCE=default-arch-base-latest-master-py3 115 | # - env: INSTANCE=default-gentoo-stage3-latest-master-py3 116 | - env: INSTANCE=default-gentoo-stage3-systemd-master-py3 117 | - env: INSTANCE=default-almalinux-8-master-py3 118 | - env: INSTANCE=default-rockylinux-8-master-py3 119 | # - env: INSTANCE=default-debian-11-3004-1-py3 120 | # - env: INSTANCE=default-debian-10-3004-1-py3 121 | # - env: INSTANCE=default-debian-9-3004-1-py3 122 | # - env: INSTANCE=default-ubuntu-2204-3004-1-py3 123 | # - env: INSTANCE=default-ubuntu-2004-3004-1-py3 124 | # - env: INSTANCE=default-ubuntu-1804-3004-1-py3 125 | # - env: INSTANCE=default-centos-stream8-3004-1-py3 126 | # - env: INSTANCE=default-centos-7-3004-1-py3 127 | # - env: INSTANCE=default-fedora-36-3004-1-py3 128 | # - env: INSTANCE=default-fedora-35-3004-1-py3 129 | # - env: INSTANCE=default-amazonlinux-2-3004-1-py3 130 | # - env: INSTANCE=default-oraclelinux-8-3004-1-py3 131 | # - env: INSTANCE=default-oraclelinux-7-3004-1-py3 132 | # - env: INSTANCE=default-arch-base-latest-3004-1-py3 133 | # - env: INSTANCE=default-gentoo-stage3-latest-3004-1-py3 134 | # - env: INSTANCE=default-gentoo-stage3-systemd-3004-1-py3 135 | # - env: INSTANCE=default-almalinux-8-3004-1-py3 136 | # - env: INSTANCE=default-rockylinux-8-3004-1-py3 137 | # - env: INSTANCE=default-opensuse-leap-153-3004-0-py3 138 | # - env: INSTANCE=default-opensuse-tmbl-latest-3004-0-py3 139 | # - env: INSTANCE=default-debian-10-3003-4-py3 140 | # - env: INSTANCE=default-debian-9-3003-4-py3 141 | # - env: INSTANCE=default-ubuntu-2004-3003-4-py3 142 | # - env: INSTANCE=default-ubuntu-1804-3003-4-py3 143 | # - env: INSTANCE=default-centos-stream8-3003-4-py3 144 | # - env: INSTANCE=default-centos-7-3003-4-py3 145 | # - env: INSTANCE=default-amazonlinux-2-3003-4-py3 146 | # - env: INSTANCE=default-oraclelinux-8-3003-4-py3 147 | # - env: INSTANCE=default-oraclelinux-7-3003-4-py3 148 | # - env: INSTANCE=default-almalinux-8-3003-4-py3 149 | 150 | ## Define the release stage that runs `semantic-release` 151 | - stage: 'release' 152 | language: 'node_js' 153 | node_js: 'lts/*' 154 | env: 'Release' 155 | name: 'Run semantic-release inc. file updates to AUTHORS, CHANGELOG & FORMULA' 156 | before_install: 'skip' 157 | script: 158 | # Update `AUTHORS.md` 159 | - export MAINTAINER_TOKEN=${GH_TOKEN} 160 | - go get github.com/myii/maintainer 161 | - maintainer contributor 162 | 163 | # Install all dependencies required for `semantic-release` 164 | - npm i -D @semantic-release/changelog@3 165 | @semantic-release/exec@3 166 | @semantic-release/git@7 167 | deploy: 168 | provider: 'script' 169 | # Opt-in to `dpl v2` to complete the Travis build config validation (beta) 170 | # * https://docs.travis-ci.com/user/build-config-validation 171 | # Deprecated `skip_cleanup` can now be avoided, `cleanup: false` is by default 172 | edge: true 173 | # Run `semantic-release` 174 | script: 'npx semantic-release@15.14' 175 | 176 | # Notification options: `always`, `never` or `change` 177 | notifications: 178 | webhooks: 179 | if: 'repo = saltstack-formulas/consul-formula' 180 | urls: 181 | - https://saltstack-formulas.zulipchat.com/api/v1/external/travis?api_key=HsIq3o5QmLxdnVCKF9is0FUIpkpAY79P&stream=CI&topic=saltstack-formulas%2Fconsul-formula&ignore_pull_requests=true 182 | on_success: always # default: always 183 | on_failure: always # default: always 184 | on_start: always # default: never 185 | on_cancel: always # default: always 186 | on_error: always # default: always 187 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | # Extend the `default` configuration provided by `yamllint` 5 | extends: 'default' 6 | 7 | # Files to ignore completely 8 | # 1. All YAML files under directory `.bundle/`, introduced if gems are installed locally 9 | # 2. All YAML files under directory `.cache/`, introduced during the CI run 10 | # 3. All YAML files under directory `.git/` 11 | # 4. All YAML files under directory `node_modules/`, introduced during the CI run 12 | # 5. Any SLS files under directory `test/`, which are actually state files 13 | # 6. Any YAML files under directory `.kitchen/`, introduced during local testing 14 | # 7. `kitchen.vagrant.yml`, which contains Embedded Ruby (ERB) template syntax 15 | ignore: | 16 | .bundle/ 17 | .cache/ 18 | .git/ 19 | node_modules/ 20 | test/**/states/**/*.sls 21 | .kitchen/ 22 | kitchen.vagrant.yml 23 | 24 | yaml-files: 25 | # Default settings 26 | - '*.yaml' 27 | - '*.yml' 28 | - .salt-lint 29 | - .yamllint 30 | # SaltStack Formulas additional settings 31 | - '*.example' 32 | - test/**/*.sls 33 | 34 | rules: 35 | empty-values: 36 | forbid-in-block-mappings: true 37 | forbid-in-flow-mappings: true 38 | line-length: 39 | # Increase from default of `80` 40 | # Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`) 41 | max: 88 42 | octal-values: 43 | forbid-implicit-octal: true 44 | forbid-explicit-octal: true 45 | -------------------------------------------------------------------------------- /AUTHORS.md: -------------------------------------------------------------------------------- 1 | # Authors 2 | 3 | This list is sorted by the number of commits per contributor in _descending_ order. 4 | 5 | Avatar|Contributor|Contributions 6 | :-:|---|:-: 7 | @myii|[@myii](https://github.com/myii)|104 8 | @bahadir|[@bahadir](https://github.com/bahadir)|30 9 | @aabouzaid|[@aabouzaid](https://github.com/aabouzaid)|14 10 | @aboe76|[@aboe76](https://github.com/aboe76)|9 11 | @babilen|[@babilen](https://github.com/babilen)|7 12 | @javierbertoli|[@javierbertoli](https://github.com/javierbertoli)|6 13 | @rbjorklin|[@rbjorklin](https://github.com/rbjorklin)|6 14 | @vutny|[@vutny](https://github.com/vutny)|4 15 | @dafyddj|[@dafyddj](https://github.com/dafyddj)|3 16 | @hugochinchilla|[@hugochinchilla](https://github.com/hugochinchilla)|3 17 | @phoerious|[@phoerious](https://github.com/phoerious)|3 18 | @nickgarber|[@nickgarber](https://github.com/nickgarber)|2 19 | @ExaneServerTeam|[@ExaneServerTeam](https://github.com/ExaneServerTeam)|2 20 | @pierluca|[@pierluca](https://github.com/pierluca)|2 21 | @sticky-note|[@sticky-note](https://github.com/sticky-note)|2 22 | @mostafahussein|[@mostafahussein](https://github.com/mostafahussein)|1 23 | @flyinprogrammer|[@flyinprogrammer](https://github.com/flyinprogrammer)|1 24 | @cmclaughlin|[@cmclaughlin](https://github.com/cmclaughlin)|1 25 | @clsung|[@clsung](https://github.com/clsung)|1 26 | @ChrisLundquist|[@ChrisLundquist](https://github.com/ChrisLundquist)|1 27 | @baby-gnu|[@baby-gnu](https://github.com/baby-gnu)|1 28 | @jeduardo|[@jeduardo](https://github.com/jeduardo)|1 29 | @jcftang|[@jcftang](https://github.com/jcftang)|1 30 | @kevinschmidt|[@kevinschmidt](https://github.com/kevinschmidt)|1 31 | @teeuwes|[@teeuwes](https://github.com/teeuwes)|1 32 | @jle35|[@jle35](https://github.com/jle35)|1 33 | @noelmcloughlin|[@noelmcloughlin](https://github.com/noelmcloughlin)|1 34 | @puneetk|[@puneetk](https://github.com/puneetk)|1 35 | 36 | --- 37 | 38 | Auto-generated by a [forked version](https://github.com/myii/maintainer) of [gaocegege/maintainer](https://github.com/gaocegege/maintainer) on 2022-05-06. 39 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | # [1.2.0](https://github.com/saltstack-formulas/consul-formula/compare/v1.1.1...v1.2.0) (2022-05-06) 4 | 5 | 6 | ### Continuous Integration 7 | 8 | * **gemfile.lock:** fix erroneous indentation ([84e5f14](https://github.com/saltstack-formulas/consul-formula/commit/84e5f1416bf8b2861824f8cd3bb1b49b2cd228dc)) 9 | 10 | 11 | ### Features 12 | 13 | * **freebsd:** add `FreeBSD` support ([c49d33b](https://github.com/saltstack-formulas/consul-formula/commit/c49d33b921275297d101f9fbaf1e79de6c029842)) 14 | 15 | 16 | ### Tests 17 | 18 | * **freebsd:** add `kitchen` `FreeBSD` recipes and `github` workflow ([09f60fd](https://github.com/saltstack-formulas/consul-formula/commit/09f60fd11c8a8cd300bdc7e47311ddcb4e165fed)) 19 | 20 | ## [1.1.1](https://github.com/saltstack-formulas/consul-formula/compare/v1.1.0...v1.1.1) (2022-05-05) 21 | 22 | 23 | ### Code Refactoring 24 | 25 | * use of `mapdata` and `libtofs` ([c287bdc](https://github.com/saltstack-formulas/consul-formula/commit/c287bdcf77a409426b4e44a1e5d47611fceb6622)) 26 | 27 | # [1.1.0](https://github.com/saltstack-formulas/consul-formula/compare/v1.0.2...v1.1.0) (2022-04-27) 28 | 29 | 30 | ### Features 31 | 32 | * **map:** update to v5 `map.jinja` ([2968032](https://github.com/saltstack-formulas/consul-formula/commit/296803292e6f20e276ae0bddf679a17d541f8c18)) 33 | 34 | 35 | ### Tests 36 | 37 | * **_mapdata:** fix `CentOS 8` name in integration file [skip ci] ([a8fe75a](https://github.com/saltstack-formulas/consul-formula/commit/a8fe75a9d8c61be612df1ba21b2ad8a5e8d4e3c6)) 38 | 39 | ## [1.0.2](https://github.com/saltstack-formulas/consul-formula/compare/v1.0.1...v1.0.2) (2022-04-25) 40 | 41 | 42 | ### Continuous Integration 43 | 44 | * **kitchen+gitlab:** update for new pre-salted images [skip ci] ([897ba26](https://github.com/saltstack-formulas/consul-formula/commit/897ba268a1afb35b1cdee8e5703b068a8ae9dd86)) 45 | 46 | 47 | ### Documentation 48 | 49 | * **readme:** add correct description [skip ci] ([5563e25](https://github.com/saltstack-formulas/consul-formula/commit/5563e25b9d9a81f09f755c80a537bb970ffceef5)) 50 | 51 | 52 | ### Tests 53 | 54 | * **map:** verify `map.jinja` dump using `_mapdata` state ([2043908](https://github.com/saltstack-formulas/consul-formula/commit/204390868fe20e60db95021bb331ddfdb68dc758)) 55 | * **system:** add `build_platform_codename` [skip ci] ([2d97668](https://github.com/saltstack-formulas/consul-formula/commit/2d976680c1840093cbe8dead04886415f53230e6)) 56 | 57 | ## [1.0.1](https://github.com/saltstack-formulas/consul-formula/compare/v1.0.0...v1.0.1) (2022-02-12) 58 | 59 | 60 | ### Bug Fixes 61 | 62 | * **install:** use correct `unzip` package name for `Gentoo` ([a8ee3ae](https://github.com/saltstack-formulas/consul-formula/commit/a8ee3aed313f65d7a03c4112c6f4f75709830727)) 63 | 64 | 65 | ### Code Refactoring 66 | 67 | * **salt-lint:** fix violations ([bf73fca](https://github.com/saltstack-formulas/consul-formula/commit/bf73fca44b41f00c86d3151a74c36e8040103930)) 68 | 69 | 70 | ### Continuous Integration 71 | 72 | * update linters to latest versions [skip ci] ([53f6d33](https://github.com/saltstack-formulas/consul-formula/commit/53f6d33c06e31e14daf6e3be314e497a6709c8f4)) 73 | * **3003.1:** update inc. AlmaLinux, Rocky & `rst-lint` [skip ci] ([100f869](https://github.com/saltstack-formulas/consul-formula/commit/100f869279a779bcc8879f96598e619a7456c01b)) 74 | * **commitlint:** ensure `upstream/master` uses main repo URL [skip ci] ([c0fc41f](https://github.com/saltstack-formulas/consul-formula/commit/c0fc41f79bcb9d808e9256b847380d99b83e2ba0)) 75 | * **gemfile:** allow rubygems proxy to be provided as an env var [skip ci] ([ae4f178](https://github.com/saltstack-formulas/consul-formula/commit/ae4f17808ae8e2deb4e931c74b6f02d18613c994)) 76 | * **gemfile+lock:** use `ssf` customised `inspec` repo [skip ci] ([4538659](https://github.com/saltstack-formulas/consul-formula/commit/4538659d97351dba8f3f1e59895aaaca083af47c)) 77 | * **gemfile+lock:** use `ssf` customised `kitchen-docker` repo [skip ci] ([1b8393c](https://github.com/saltstack-formulas/consul-formula/commit/1b8393cfb53c6a3598dee1e0b40c56506abab1cd)) 78 | * **gitlab-ci:** add `rubocop` linter (with `allow_failure`) [skip ci] ([fddea73](https://github.com/saltstack-formulas/consul-formula/commit/fddea731fee9cea4d5fcc9343467156c74b468ed)) 79 | * **gitlab-ci:** use GitLab CI as Travis CI replacement ([f58d76f](https://github.com/saltstack-formulas/consul-formula/commit/f58d76f5565be12433d078e26080c0e209dc70a8)) 80 | * **kitchen:** move `provisioner` block & update `run_command` [skip ci] ([ae1833c](https://github.com/saltstack-formulas/consul-formula/commit/ae1833c43c61928fc4e13d5d73279b2cb7f4833e)) 81 | * **kitchen+ci:** update with `3004` pre-salted images/boxes [skip ci] ([f9bc278](https://github.com/saltstack-formulas/consul-formula/commit/f9bc278ea1fb415b54477f0ff3dd0db0cc212652)) 82 | * **kitchen+ci:** update with latest `3003.2` pre-salted images [skip ci] ([fc1ed54](https://github.com/saltstack-formulas/consul-formula/commit/fc1ed5464beac4245fd453c555a5962bcfc96d17)) 83 | * **kitchen+ci:** update with latest CVE pre-salted images [skip ci] ([6988c3f](https://github.com/saltstack-formulas/consul-formula/commit/6988c3f0304c55ea50ba24f1592627f6e5a1faec)) 84 | * **kitchen+ci:** use latest pre-salted images (after CVE) [skip ci] ([1b036c3](https://github.com/saltstack-formulas/consul-formula/commit/1b036c349cd621828c656f1add3e2d8998ff390a)) 85 | * **kitchen+gitlab:** adjust matrix to add `3003` [skip ci] ([80037f8](https://github.com/saltstack-formulas/consul-formula/commit/80037f87cfdea32c62e3c50c60c3825f17358de1)) 86 | * **kitchen+gitlab:** remove Ubuntu 16.04 & Fedora 32 (EOL) [skip ci] ([33bfe13](https://github.com/saltstack-formulas/consul-formula/commit/33bfe1392547b49e0b55dedef3d0c099a64c43ea)) 87 | * **kitchen+gitlab:** update for new pre-salted images [skip ci] ([0ab6348](https://github.com/saltstack-formulas/consul-formula/commit/0ab6348571235fcf65ad3c922d948848905628ba)) 88 | * add `arch-master` to matrix and update `.travis.yml` [skip ci] ([d7f0250](https://github.com/saltstack-formulas/consul-formula/commit/d7f02505f3f4d172fcc4c78d825f10cfc8edbb28)) 89 | * add Debian 11 Bullseye & update `yamllint` configuration [skip ci] ([6790314](https://github.com/saltstack-formulas/consul-formula/commit/67903143f6daa76622faaa8d024ee42c87656a09)) 90 | * **kitchen+gitlab-ci:** use latest pre-salted images [skip ci] ([95978ee](https://github.com/saltstack-formulas/consul-formula/commit/95978ee1954a8212ef3c7985e6b49f7c038c112d)) 91 | * **pre-commit:** update hook for `rubocop` [skip ci] ([c518638](https://github.com/saltstack-formulas/consul-formula/commit/c51863804186f5a9019918a31175a2f1a1ba6d42)) 92 | 93 | 94 | ### Tests 95 | 96 | * standardise use of `share` suite & `_mapdata` state [skip ci] ([13db8f4](https://github.com/saltstack-formulas/consul-formula/commit/13db8f4f61147c427a0761838cec9f7aa7257731)) 97 | 98 | # [1.0.0](https://github.com/saltstack-formulas/consul-formula/compare/v0.13.0...v1.0.0) (2020-12-13) 99 | 100 | 101 | ### Bug Fixes 102 | 103 | * replace deprecated ui option with ui_config ([3830ade](https://github.com/saltstack-formulas/consul-formula/commit/3830ade3398b42c0053f5b094497d461eed836e2)) 104 | 105 | 106 | ### BREAKING CHANGES 107 | 108 | * This cannot be updated in a non-breaking fashion, but 109 | the least disruptive route was chosen. 110 | * If both `ui` and `ui_config.enabled` are set, 111 | `ui_config` takes precedence. Hence, the change may enable the UI on 112 | machines which had previously set `ui` to false. This is arguably better 113 | than defaulting to `false`, which would disable the UI where it is 114 | supposed to be enabled. 115 | * Removing the option entirely breaks similarly if users 116 | rely on the formula defaults, since Consul's default is `false` and the 117 | formula's default used to be `true`. 118 | * The only other way to break less would be to set both 119 | options, but then users would also have override both (which is not 120 | obvious and very annoying) and there would still be no way forward to 121 | when Consul actually removes the deprecated option. 122 | 123 | # [0.13.0](https://github.com/saltstack-formulas/consul-formula/compare/v0.12.0...v0.13.0) (2020-12-13) 124 | 125 | 126 | ### Continuous Integration 127 | 128 | * **gemfile.lock:** add to repo with updated `Gemfile` [skip ci] ([cdf1565](https://github.com/saltstack-formulas/consul-formula/commit/cdf15658c1a8068a72f2110ede5219c4b4953677)) 129 | * **kitchen:** use `saltimages` Docker Hub where available [skip ci] ([0525720](https://github.com/saltstack-formulas/consul-formula/commit/0525720080bfd4fe89e1a84729e31e4055e92b95)) 130 | * **kitchen+travis:** add new platforms [skip ci] ([e0e19d5](https://github.com/saltstack-formulas/consul-formula/commit/e0e19d5ea05a029627b0f3aa3516bf9e9b480de3)) 131 | * **kitchen+travis:** adjust matrix to add `3000.2` & remove `2018.3` [skip ci] ([5379660](https://github.com/saltstack-formulas/consul-formula/commit/537966061de97cd2ea875fa3986b22e78ac17109)) 132 | * **kitchen+travis:** adjust matrix to add `3000.3` [skip ci] ([2d02fdf](https://github.com/saltstack-formulas/consul-formula/commit/2d02fdfdc1725d3f8ef04e2228b8f5965254e69c)) 133 | * **kitchen+travis:** adjust matrix to update `3000` to `3000.1` ([d36521c](https://github.com/saltstack-formulas/consul-formula/commit/d36521c262801a6e292b86e783d0d415090e3fa2)) 134 | * **kitchen+travis:** remove `master-py2-arch-base-latest` [skip ci] ([f61fd0f](https://github.com/saltstack-formulas/consul-formula/commit/f61fd0f0893d9a0e5cf3ef55155d464c0c40a9bd)) 135 | * **pre-commit:** add to formula [skip ci] ([b587c20](https://github.com/saltstack-formulas/consul-formula/commit/b587c20dc91dd5fab36bfe06df27db5812b86288)) 136 | * **pre-commit:** enable/disable `rstcheck` as relevant [skip ci] ([1911fa8](https://github.com/saltstack-formulas/consul-formula/commit/1911fa869a3943a33bfa06519e3844cd99b38936)) 137 | * **pre-commit:** finalise `rstcheck` configuration [skip ci] ([3bd7a05](https://github.com/saltstack-formulas/consul-formula/commit/3bd7a05d0b4e0b75af82115be2d1789e3c1887f1)) 138 | * **travis:** add notifications => zulip [skip ci] ([785955c](https://github.com/saltstack-formulas/consul-formula/commit/785955c10b5e2945ef0aba10742d7a498b5467c3)) 139 | * **workflows/commitlint:** add to repo [skip ci] ([2a7adf5](https://github.com/saltstack-formulas/consul-formula/commit/2a7adf5847dcbb227edf2fb20997755190aa10cf)) 140 | 141 | 142 | ### Features 143 | 144 | * **gitlab-ci:** use GitLab CI as Travis CI replacement ([99639ee](https://github.com/saltstack-formulas/consul-formula/commit/99639ee6027efd02c77bc3e170acf29dadbe08e8)) 145 | 146 | # [0.12.0](https://github.com/saltstack-formulas/consul-formula/compare/v0.11.2...v0.12.0) (2020-03-26) 147 | 148 | 149 | ### Features 150 | 151 | * **semantic-release:** implement for this formula ([ec8f6c9](https://github.com/saltstack-formulas/consul-formula/commit/ec8f6c92aa91d2714287b640f5210ff62e063ade)) 152 | -------------------------------------------------------------------------------- /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 | # ************************************************************************** 5 | # *** NO GLOBAL OWNER(S) SPECIFIED *** 6 | # *** Ideally this will be defined for a healthy, well-maintained repo *** 7 | # ************************************************************************** 8 | # FILE PATTERN OWNER(S) 9 | * @NONE 10 | 11 | # SECTION: Owner(s) for specific directories 12 | # FILE PATTERN OWNER(S) 13 | 14 | # SECTION: Owner(s) for files/directories related to `semantic-release` 15 | # FILE PATTERN OWNER(S) 16 | /.github/workflows/ @saltstack-formulas/ssf 17 | /bin/install-hooks @saltstack-formulas/ssf 18 | /bin/kitchen @saltstack-formulas/ssf 19 | /docs/AUTHORS.rst @saltstack-formulas/ssf 20 | /docs/CHANGELOG.rst @saltstack-formulas/ssf 21 | /docs/TOFS_pattern.rst @saltstack-formulas/ssf 22 | /*/_mapdata/ @saltstack-formulas/ssf 23 | /*/libmapstack.jinja @saltstack-formulas/ssf 24 | /*/libmatchers.jinja @saltstack-formulas/ssf 25 | /*/libsaltcli.jinja @saltstack-formulas/ssf 26 | /*/libtofs.jinja @saltstack-formulas/ssf 27 | /*/map.jinja @saltstack-formulas/ssf 28 | /test/integration/**/_mapdata.rb @saltstack-formulas/ssf 29 | /test/integration/**/libraries/system.rb @saltstack-formulas/ssf 30 | /test/integration/**/inspec.yml @saltstack-formulas/ssf 31 | /test/integration/**/README.md @saltstack-formulas/ssf 32 | /test/salt/pillar/top.sls @saltstack-formulas/ssf 33 | /.gitignore @saltstack-formulas/ssf 34 | /.cirrus.yml @saltstack-formulas/ssf 35 | /.gitlab-ci.yml @saltstack-formulas/ssf 36 | /.pre-commit-config.yaml @saltstack-formulas/ssf 37 | /.rstcheck.cfg @saltstack-formulas/ssf 38 | /.rubocop.yml @saltstack-formulas/ssf 39 | /.salt-lint @saltstack-formulas/ssf 40 | /.travis.yml @saltstack-formulas/ssf 41 | /.yamllint @saltstack-formulas/ssf 42 | /AUTHORS.md @saltstack-formulas/ssf 43 | /CHANGELOG.md @saltstack-formulas/ssf 44 | /CODEOWNERS @saltstack-formulas/ssf 45 | /commitlint.config.js @saltstack-formulas/ssf 46 | /FORMULA @saltstack-formulas/ssf 47 | /Gemfile @saltstack-formulas/ssf 48 | /Gemfile.lock @saltstack-formulas/ssf 49 | /kitchen.yml @saltstack-formulas/ssf 50 | /kitchen.vagrant.yml @saltstack-formulas/ssf 51 | /kitchen.windows.yml @saltstack-formulas/ssf 52 | /pre-commit_semantic-release.sh @saltstack-formulas/ssf 53 | /release-rules.js @saltstack-formulas/ssf 54 | /release.config.js @saltstack-formulas/ssf 55 | 56 | # SECTION: Owner(s) for specific files 57 | # FILE PATTERN OWNER(S) 58 | -------------------------------------------------------------------------------- /FORMULA: -------------------------------------------------------------------------------- 1 | name: consul 2 | os: Debian, Ubuntu, Raspbian, RedHat, Fedora, CentOS, Amazon, Suse, openSUSE, Gentoo, Funtoo, Arch, Manjaro, Alpine, FreeBSD, OpenBSD, Solaris, SmartOS, Windows, MacOS 3 | os_family: Debian, RedHat, Suse, Gentoo, Arch, Alpine, FreeBSD, OpenBSD, Solaris, Windows, MacOS 4 | version: 1.2.0 5 | release: 1 6 | minimum_version: 2017.7 7 | summary: Consul formula 8 | description: Formula to install and configure Hashicorp Consul 9 | top_level_dir: consul 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 | 21 | group :vagrant do 22 | gem 'kitchen-vagrant' 23 | end 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2015 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 | -------------------------------------------------------------------------------- /consul-template/config.sls: -------------------------------------------------------------------------------- 1 | {% from "consul-template/map.jinja" import consul_template with context %} 2 | 3 | consul-template-config: 4 | file.managed: 5 | - source: salt://consul-template/files/config.json 6 | - template: jinja 7 | - name: /etc/consul-template.d/config.json 8 | 9 | {% if consul_template.tmpl %} 10 | {% for tmpl in consul_template.tmpl %} 11 | consul-template-tmpl-file-{{ loop.index }}: 12 | file.managed: 13 | - source: {{ tmpl.source }} 14 | - name: /etc/consul-template/tmpl-source/{{ tmpl.name }}.ctmpl 15 | - template: {{ tmpl.template_engine }} 16 | 17 | consul-template.d-tmpl-{{ loop.index }}: 18 | file.serialize: 19 | - name: /etc/consul-template.d/{{ tmpl.name }}.json 20 | - dataset: {{ tmpl.config }} 21 | - formatter: json 22 | {% endfor %} 23 | {% endif %} 24 | -------------------------------------------------------------------------------- /consul-template/defaults.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | consul_template: 3 | version: 0.20.0 4 | hash: 500fe023c89517f959175eb79e21c33df0acf7733d3f3681ec8c5238863caf86 5 | 6 | service: false 7 | config: 8 | consul: 127.0.0.1:8500 9 | log_level: info 10 | tmpl: 11 | - name: example 12 | source: salt://consul-template/files/example.ctmpl 13 | template_engine: null # None in Python 14 | config: 15 | template: 16 | source: /etc/consul-template/tmpl-source/example.ctmpl 17 | destination: /etc/consul-template/example 18 | -------------------------------------------------------------------------------- /consul-template/files/config.json: -------------------------------------------------------------------------------- 1 | {% from "consul-template/map.jinja" import consul_template with context %} 2 | {{ consul_template.config | json }} 3 | -------------------------------------------------------------------------------- /consul-template/files/consul-template-upstart.service: -------------------------------------------------------------------------------- 1 | description "Consul Template" 2 | start on (local-filesystems and net-device-up IFACE!=lo) 3 | stop on runlevel [06] 4 | 5 | exec /usr/local/bin/consul-template -config /etc/consul-template.d 6 | 7 | respawn 8 | respawn limit 10 10 9 | kill timeout 10 10 | -------------------------------------------------------------------------------- /consul-template/files/consul-template.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=consul-template 3 | Documentation=https://github.com/hashicorp/consul-template 4 | Wants=network-online.target 5 | After=network-online.target 6 | 7 | [Service] 8 | ExecStart=/usr/local/bin/consul-template -config /etc/consul-template.d 9 | ExecReload=/bin/kill -HUP $MAINPID 10 | KillMode=process 11 | KillSignal=SIGTERM 12 | Restart=on-failure 13 | RestartSec=42s 14 | 15 | [Install] 16 | WantedBy=multi-user.target 17 | -------------------------------------------------------------------------------- /consul-template/files/example.ctmpl: -------------------------------------------------------------------------------- 1 | {{with node}}{{.Node.Node}}{{end}} 2 | -------------------------------------------------------------------------------- /consul-template/init.sls: -------------------------------------------------------------------------------- 1 | {% from "consul-template/map.jinja" import consul with context %} 2 | 3 | include: 4 | - consul 5 | - consul-template.install 6 | - consul-template.config 7 | - consul-template.service 8 | -------------------------------------------------------------------------------- /consul-template/install.sls: -------------------------------------------------------------------------------- 1 | {% from "consul-template/map.jinja" import consul_template with context %} 2 | 3 | consul-template-config-dir: 4 | file.directory: 5 | - name: /etc/consul-template.d 6 | 7 | consul-template-template-dir: 8 | file.directory: 9 | - name: /etc/consul-template/tmpl-source 10 | - makedirs: True 11 | 12 | # Install template renderer 13 | consul-template-download: 14 | file.managed: 15 | - name: /tmp/consul_template_{{ consul_template.version }}_linux_amd64.zip 16 | - source: https://releases.hashicorp.com/consul-template/{{ consul_template.version }}/consul-template_{{ consul_template.version }}_linux_amd64.zip 17 | - source_hash: sha256={{ consul_template.hash }} 18 | - unless: test -f /usr/local/bin/consul-template-{{ consul_template.version }} 19 | 20 | consul-template-extract: 21 | cmd.run: 22 | - name: unzip /tmp/consul_template_{{ consul_template.version }}_linux_amd64.zip -d /tmp 23 | - onchanges: 24 | - file: consul-template-download 25 | 26 | consul-template-install: 27 | file.rename: 28 | - name: /usr/local/bin/consul-template-{{ consul_template.version }} 29 | - source: /tmp/consul-template 30 | - require: 31 | - file: /usr/local/bin 32 | - watch: 33 | - cmd: consul-template-extract 34 | 35 | consul-template-clean: 36 | file.absent: 37 | - name: /tmp/consul_template_{{ consul_template.version }}_linux_amd64.zip 38 | - watch: 39 | - file: consul-template-install 40 | 41 | consul-template-link: 42 | file.symlink: 43 | - target: consul-template-{{ consul_template.version }} 44 | - name: /usr/local/bin/consul-template 45 | - watch: 46 | - file: consul-template-install 47 | -------------------------------------------------------------------------------- /consul-template/map.jinja: -------------------------------------------------------------------------------- 1 | {% import_yaml "consul-template/defaults.yaml" as defaults %} 2 | 3 | {% set consul_template = salt['pillar.get']('consul_template', default=defaults.consul_template, merge=True) %} 4 | -------------------------------------------------------------------------------- /consul-template/service.sls: -------------------------------------------------------------------------------- 1 | {% from "consul-template/map.jinja" import consul_template with context %} 2 | 3 | consul-template-init-script: 4 | file.managed: 5 | {% if salt['test.provider']('service').startswith('systemd') %} 6 | - source: salt://consul-template/files/consul-template.service 7 | - name: /etc/systemd/system/consul-template.service 8 | - mode: '0644' 9 | {% elif salt['test.provider']('service') == 'upstart' %} 10 | - source: salt://consul-template/files/consul-template-upstart.service 11 | - name: /etc/init/consul-template.conf 12 | - mode: '0644' 13 | {% endif %} 14 | {% if consul_template.service != False %} 15 | - watch_in: 16 | - service: consul 17 | {% endif %} 18 | 19 | {% if consul_template.service != False %} 20 | consul-template-service: 21 | service.running: 22 | - name: consul-template 23 | - enable: True 24 | - watch: 25 | - file: /etc/consul-template.d/* 26 | {% endif %} 27 | -------------------------------------------------------------------------------- /consul/_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 | -------------------------------------------------------------------------------- /consul/_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 mapdata with context %} 7 | 8 | {%- set _mapdata = { 9 | "values": mapdata, 10 | } %} 11 | {%- do salt["log.debug"]("### MAP.JINJA DUMP ###\n" ~ _mapdata | yaml(False)) %} 12 | 13 | {%- set output_dir = "/temp" if grains.os_family == "Windows" else "/tmp" %} 14 | {%- set output_file = output_dir ~ "/salt_mapdata_dump.yaml" %} 15 | 16 | {{ tplroot }}-mapdata-dump: 17 | file.managed: 18 | - name: {{ output_file }} 19 | - source: salt://{{ tplroot }}/_mapdata/_mapdata.jinja 20 | - template: jinja 21 | - context: 22 | map: {{ _mapdata | yaml }} 23 | -------------------------------------------------------------------------------- /consul/config.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 mapdata as consul with context %} 7 | 8 | consul-config: 9 | file.serialize: 10 | - name: {{ consul.config_dir ~ 'config.json' }} 11 | - encoding: utf-8 12 | - formatter: json 13 | - dataset: {{ consul.config | json }} 14 | - user: {{ consul.user }} 15 | - group: {{ consul.group }} 16 | - mode: '0640' 17 | - require: 18 | - user: consul-user 19 | {%- if consul.service %} 20 | - watch_in: 21 | - service: consul 22 | {%- endif %} 23 | 24 | {% for script in consul.scripts %} 25 | consul-script-install-{{ loop.index }}: 26 | file.managed: 27 | - source: {{ script.source }} 28 | - name: {{ script.name }} 29 | - template: jinja 30 | - context: {{ script.get('context', {}) | yaml }} 31 | - user: {{ consul.user }} 32 | - group: {{ consul.group }} 33 | - mode: '0755' 34 | {% endfor %} 35 | 36 | consul-script-config: 37 | file.serialize: 38 | - name: {{ consul.config_dir ~ 'services.json' }} 39 | {% if consul.service != False %} 40 | - watch_in: 41 | - service: consul 42 | {% endif %} 43 | - user: {{ consul.user }} 44 | - group: {{ consul.group }} 45 | - require: 46 | - user: consul-user 47 | - formatter: json 48 | - dataset: 49 | services: {{ consul.register | json }} 50 | -------------------------------------------------------------------------------- /consul/files/FreeBSD/consul_service_unit.jinja: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # PROVIDE: consul 4 | # REQUIRE: NETWORKING FILESYSTEMS defaultroute netwait resolv 5 | # KEYWORD: shutdown 6 | # 7 | # Add consul_enable="YES" to /etc/rc.conf to enable Consul 8 | # 9 | # Additional variables you can define are: 10 | # 11 | # consul_user (string): Set user to run consul. 12 | # Default is "consul". 13 | # consul_group (string): Set group to run consul. 14 | # Default is "consul". 15 | # consul_pidfile (string): Set full path to pid file 16 | # Default is "/var/run/consul.pid" 17 | # consul_datadir (dir): Set dir to run consul in. 18 | # Default is "/var/db/consul" 19 | # consul_syslog_output_enable (bool): Set to YES to enable syslog output 20 | # Default is "NO". See daemon(8). 21 | # consul_syslog_output_tag (str): Set syslog tag if syslog enabled. 22 | # Default is "consul". See daemon(8). 23 | # consul_syslog_output_priority (str): Set syslog priority if syslog enabled. 24 | # Default is "info". See daemon(8). 25 | # consul_syslog_output_facility (str): Set to YES to enable syslog output 26 | # Default is "daemon". See daemon(8). 27 | # 28 | # see rc.subr(8) for additional variables and options 29 | # 30 | 31 | . /etc/rc.subr 32 | 33 | name=consul 34 | rcvar=consul_enable 35 | 36 | load_rc_config $name 37 | 38 | : ${consul_enable:="NO"} 39 | : ${consul_syslog_output_enable:="NO"} 40 | : ${consul_user:="{{ user }}"} 41 | : ${consul_group:="{{ group }}"} 42 | : ${consul_pidfile:="/var/run/${name}.pid"} 43 | : ${consul_datadir:="{{ data_dir }}"} 44 | 45 | start_precmd="consul_start_precmd" 46 | extra_commands="reload" 47 | 48 | # backwards compatibility 49 | if [ -n "${consul_dir}" ]; then 50 | consul_datadir=${consul_dir} 51 | fi 52 | 53 | if checkyesno consul_syslog_output_enable; then 54 | if [ -n "${consul_syslog_output_tag}" ]; then 55 | consul_syslog_output_flags="-T ${consul_syslog_output_tag}" 56 | else 57 | consul_syslog_output_flags="-T ${name}" 58 | fi 59 | if [ -n "${consul_syslog_output_priority}" ]; then 60 | consul_syslog_output_flags="${consul_syslog_output_flags} -s ${consul_syslog_output_priority}" 61 | fi 62 | 63 | if [ -n "${consul_syslog_output_facility}" ]; then 64 | consul_syslog_output_flags="${consul_syslog_output_flags} -l ${consul_syslog_output_facility}" 65 | fi 66 | fi 67 | 68 | pidfile=${consul_pidfile} 69 | procname="{{ bin_dir }}consul" 70 | command="/usr/sbin/daemon" 71 | command_args="-f -t ${name} ${consul_syslog_output_flags} -p ${pidfile} \ 72 | /usr/bin/env ${consul_env} ${procname} agent -data-dir=${consul_datadir} -config-dir={{ config_dir }} ${consul_args}" 73 | 74 | consul_start_precmd() 75 | { 76 | if [ ! -e ${pidfile} ]; then 77 | install -o ${consul_user} -g ${consul_group} /dev/null ${pidfile} 78 | fi 79 | 80 | if [ ! -d ${consul_datadir} ]; then 81 | install -d -m 0750 -o ${consul_user} -g ${consul_group} ${consul_datadir} 82 | fi 83 | 84 | if [ ! -d {{ config_dir }} ]; then 85 | install -d -m 0750 -o ${consul_user} -g ${consul_group} {{ config_dir }} 86 | fi 87 | } 88 | 89 | run_rc_command "$1" 90 | -------------------------------------------------------------------------------- /consul/files/config.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saltstack-formulas/consul-formula/4d4528273f0be8209f5bdc186ac6da860e1015a4/consul/files/config.json -------------------------------------------------------------------------------- /consul/files/systemd/consul_service_unit.jinja: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description="HashiCorp Consul - A service mesh solution" 3 | Documentation=https://www.consul.io/ 4 | Requires=network-online.target 5 | After=network-online.target 6 | ConditionFileNotEmpty={{ config_dir }}config.json 7 | 8 | [Service] 9 | User={{ user }} 10 | Group={{ group }} 11 | ExecStart={{ bin_dir }}consul agent -config-dir={{ config_dir }} 12 | ExecReload={{ bin_dir }}consul reload 13 | KillMode=process 14 | Restart=on-failure 15 | RestartSec=42s 16 | LimitNOFILE=65536 17 | 18 | [Install] 19 | WantedBy=multi-user.target 20 | -------------------------------------------------------------------------------- /consul/files/sysvinit/consul_service_unit.jinja: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # consul Manage the consul agent 4 | # 5 | # chkconfig: 2345 95 95 6 | # description: Consul is a tool for service discovery and configuration 7 | # processname: consul 8 | # config: /etc/consul.conf 9 | # pidfile: /var/run/consul.pid 10 | 11 | ### BEGIN INIT INFO 12 | # Provides: consul 13 | # Required-Start: $local_fs $network 14 | # Required-Stop: 15 | # Should-Start: 16 | # Should-Stop: 17 | # Default-Start: 2 3 4 5 18 | # Default-Stop: 0 1 6 19 | # Short-Description: Manage the consul agent 20 | # Description: Consul is a tool for service discovery and configuration 21 | ### END INIT INFO 22 | 23 | # source function library 24 | . /etc/rc.d/init.d/functions 25 | 26 | prog="consul" 27 | exec="{{ bin_dir }}$prog" 28 | pidfile="/var/run/$prog.pid" 29 | lockfile="/var/lock/subsys/$prog" 30 | logfile="/var/log/$prog" 31 | confdir="{{ config_dir }}" 32 | 33 | # pull in sysconfig settings 34 | [ -e {{ service_env_path }} ] && . {{ service_env_path }} 35 | 36 | user=${CONSUL_USER:-{{ user ~ '}' }} 37 | group=${CONSUL_GROUP:-{{ group ~ '}' }} 38 | 39 | export GOMAXPROCS=${GOMAXPROCS:-2} 40 | 41 | start() { 42 | [ -x $exec ] || exit 5 43 | 44 | [ -d $confdir ] || exit 6 45 | 46 | umask 077 47 | 48 | touch $logfile $pidfile 49 | chown "$user:$group" $logfile $pidfile 50 | 51 | echo -n $"Starting $prog: " 52 | 53 | ## holy shell shenanigans, batman! 54 | ## daemon can't be backgrounded. we need the pid of the spawned process, 55 | ## which is actually done via runuser thanks to --user. 56 | ## you can't do "cmd &; action" but you can do "{cmd &}; action". 57 | ## consul 0.2.1 added -pid-file; although the following creates $pidfile 58 | ## owned by consul:consul, using -pid-file results in a permission error. 59 | daemon \ 60 | --pidfile=$pidfile \ 61 | --user="$user" \ 62 | " { $exec agent -config-dir=$confdir &>> $logfile & } ; echo \$! >| $pidfile " 63 | 64 | RETVAL=$? 65 | echo 66 | 67 | [ $RETVAL -eq 0 ] && touch $lockfile 68 | 69 | echo -n $"Waiting for Consul ready: " 70 | 71 | ## wait up to 60s for the rpc port to become listened-upon 72 | ## consul 0.2.1 got much slower to start! 73 | count=0 74 | ready=0 75 | pid=$( cat ${pidfile} ) 76 | while checkpid ${pid} && [ $count -lt 60 ] && [ $ready -ne 1 ]; do 77 | count=$(( count + 1 )) 78 | 79 | if netstat -lptn | egrep -q ":8400.*LISTEN +${pid}/" ; then 80 | ready=1 81 | else 82 | sleep 1 83 | fi 84 | done 85 | 86 | if [ $ready -eq 1 ]; then 87 | RETVAL=0 88 | success 89 | else 90 | RETVAL=1 91 | failure 92 | fi 93 | 94 | echo 95 | return $RETVAL 96 | } 97 | 98 | stop() { 99 | echo -n $"Shutting down $prog: " 100 | 101 | ## graceful shutdown with leave 102 | $exec leave &> /dev/null 103 | RETVAL=$? 104 | 105 | ## wait up to 10s for the daemon to exit 106 | if [ $RETVAL -eq 0 ]; then 107 | count=0 108 | stopped=0 109 | pid=$( cat ${pidfile} ) 110 | while [ $count -lt 10 ] && [ $stopped -ne 1 ]; do 111 | count=$(( count + 1 )) 112 | 113 | if ! checkpid ${pid} ; then 114 | stopped=1 115 | else 116 | sleep 1 117 | fi 118 | done 119 | 120 | if [ $stopped -ne 1 ]; then 121 | RETVAL=125 122 | fi 123 | fi 124 | 125 | if [ $RETVAL -eq 0 ]; then 126 | success 127 | rm -f $lockfile $pidfile 128 | else 129 | failure 130 | fi 131 | 132 | echo 133 | return $RETVAL 134 | } 135 | 136 | restart() { 137 | stop 138 | start 139 | } 140 | 141 | reload() { 142 | echo -n $"Reloading $prog: " 143 | killproc -p $pidfile $exec -HUP 144 | echo 145 | } 146 | 147 | force_reload() { 148 | restart 149 | } 150 | 151 | rh_status() { 152 | status -p "$pidfile" -l $prog $exec 153 | 154 | RETVAL=$? 155 | 156 | [ $RETVAL -eq 0 ] && $exec members 157 | 158 | return $RETVAL 159 | } 160 | 161 | rh_status_q() { 162 | rh_status >/dev/null 2>&1 163 | } 164 | 165 | case "$1" in 166 | start) 167 | rh_status_q && exit 0 168 | $1 169 | ;; 170 | stop) 171 | rh_status_q || exit 0 172 | $1 173 | ;; 174 | restart) 175 | $1 176 | ;; 177 | reload) 178 | rh_status_q || exit 7 179 | $1 180 | ;; 181 | force-reload) 182 | force_reload 183 | ;; 184 | status) 185 | rh_status 186 | ;; 187 | condrestart|try-restart) 188 | rh_status_q || exit 0 189 | restart 190 | ;; 191 | *) 192 | echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" 193 | exit 2 194 | esac 195 | 196 | exit $? 197 | -------------------------------------------------------------------------------- /consul/files/upstart/consul_service_unit.jinja: -------------------------------------------------------------------------------- 1 | description "Consul agent" 2 | 3 | start on runlevel [2345] 4 | stop on runlevel [!2345] 5 | 6 | respawn 7 | 8 | script 9 | if [ -f {{ service_env_path }} ]; then 10 | . {{ service_env_path }} 11 | fi 12 | 13 | # Make sure to use all our CPUs, because Consul can block a scheduler thread 14 | export GOMAXPROCS=`nproc` 15 | 16 | # Get the public IP 17 | BIND=`ifconfig eth0 | grep "inet addr" | awk '{ print substr($2,6) }'` 18 | 19 | exec start-stop-daemon --start \ 20 | --chuid ${CONSUL_USER:-{{ user ~ '}' }}:${CONSUL_GROUP:-{{ group ~ '}' }} \ 21 | --exec {{ bin_dir }}consul agent -- \ 22 | -config-dir="{{ config_dir }}" \ 23 | ${CONSUL_FLAGS} \ 24 | >> /var/log/consul.log 2>&1 25 | end script 26 | -------------------------------------------------------------------------------- /consul/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 mapdata as consul with context %} 7 | 8 | {%- if consul.get('enabled', True) %} 9 | include: 10 | - {{ tplroot }}.install 11 | - {{ tplroot }}.config 12 | - {{ tplroot }}.service 13 | {%- endif %} 14 | -------------------------------------------------------------------------------- /consul/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 mapdata as consul with context %} 7 | 8 | consul-dep-unzip: 9 | pkg.installed: 10 | - name: {{ 'app-arch/unzip' if grains.os_family == 'Gentoo' else 'unzip' }} 11 | 12 | consul-bin-dir: 13 | file.directory: 14 | - name: {{ consul.bin_dir }} 15 | - makedirs: True 16 | 17 | # Create consul user 18 | consul-group: 19 | group.present: 20 | - name: {{ consul.group }} 21 | {% if consul.get('group_gid', None) != None -%} 22 | - gid: {{ consul.group_gid }} 23 | {%- endif %} 24 | 25 | consul-user: 26 | user.present: 27 | - name: {{ consul.user }} 28 | {% if consul.get('user_uid', None) != None -%} 29 | - uid: {{ consul.user_uid }} 30 | {% endif -%} 31 | - groups: 32 | - {{ consul.group }} 33 | - home: {{ salt['user.info'](consul.user)['home']|default(consul.config.data_dir) }} 34 | - createhome: False 35 | - system: True 36 | - require: 37 | - group: consul-group 38 | 39 | # Create directories 40 | consul-config-dir: 41 | file.directory: 42 | - name: {{ consul.config_dir }} 43 | - user: {{ consul.user }} 44 | - group: {{ consul.group }} 45 | - mode: '0750' 46 | 47 | consul-data-dir: 48 | file.directory: 49 | - name: {{ consul.config.data_dir }} 50 | - makedirs: True 51 | - user: {{ consul.user }} 52 | - group: {{ consul.group }} 53 | - mode: '0750' 54 | 55 | # Install agent 56 | consul-download: 57 | file.managed: 58 | - name: /tmp/consul_{{ consul.version }}_{{ grains.kernel | lower }}_{{ consul.arch }}.zip 59 | - source: https://{{ consul.download_host }}/consul/{{ consul.version }}/consul_{{ consul.version }}_{{ grains.kernel | lower }}_{{ consul.arch }}.zip 60 | - source_hash: https://releases.hashicorp.com/consul/{{ consul.version }}/consul_{{ consul.version }}_SHA256SUMS 61 | - unless: test -f {{ consul.bin_dir ~ 'consul-' ~ consul.version }} 62 | 63 | consul-extract: 64 | cmd.run: 65 | - name: unzip /tmp/consul_{{ consul.version }}_{{ grains.kernel | lower }}_{{ consul.arch }}.zip -d /tmp 66 | - onchanges: 67 | - file: consul-download 68 | 69 | consul-install: 70 | file.rename: 71 | - name: {{ consul.bin_dir ~ 'consul-' ~ consul.version }} 72 | - source: /tmp/consul 73 | - require: 74 | - file: {{ consul.bin_dir }} 75 | - watch: 76 | - cmd: consul-extract 77 | 78 | consul-clean: 79 | file.absent: 80 | - name: /tmp/consul_{{ consul.version }}_{{ grains.kernel | lower }}_{{ consul.arch }}.zip 81 | - watch: 82 | - file: consul-install 83 | 84 | consul-link: 85 | file.symlink: 86 | - target: consul-{{ consul.version }} 87 | - name: {{ consul.bin_dir ~ 'consul' }} 88 | - watch: 89 | - file: consul-install 90 | -------------------------------------------------------------------------------- /consul/libmapstack.jinja: -------------------------------------------------------------------------------- 1 | {#- -*- coding: utf-8 -*- #} 2 | {#- vim: ft=jinja #} 3 | 4 | {#- Get the `tplroot` from `tpldir` #} 5 | {%- set tplroot = tpldir.split("/")[0] %} 6 | {%- from tplroot ~ "/libmatchers.jinja" import parse_matchers, query_map with context %} 7 | 8 | {%- set _default_config_dirs = [ 9 | "parameters/", 10 | tplroot ~ "/parameters" 11 | ] %} 12 | 13 | {%- macro mapstack( 14 | matchers, 15 | defaults=None, 16 | dirs=_default_config_dirs, 17 | log_prefix="libmapstack: " 18 | ) %} 19 | {#- 20 | Load configuration in the order of `matchers` and merge 21 | successively the values with `defaults`. 22 | 23 | The `matchers` are processed using `libmatchers.jinja` to select 24 | the configuration sources from where the values are loaded. 25 | 26 | Parameters: 27 | 28 | - `matchers`: list of matchers in the form 29 | `[[: