├── .github └── workflows │ └── commitlint.yml ├── .gitignore ├── .gitlab-ci.yml ├── .pre-commit-config.yaml ├── .rstcheck.cfg ├── .rubocop.yml ├── .salt-lint ├── .travis.yml ├── .yamllint ├── AUTHORS.md ├── CHANGELOG.md ├── CODEOWNERS ├── FORMULA ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── bin ├── install-hooks └── kitchen ├── commitlint.config.js ├── docs ├── AUTHORS.rst ├── CHANGELOG.rst ├── README.rst ├── TOFS_pattern.rst ├── _static │ └── css │ │ └── custom.css └── map.jinja.rst ├── kitchen.yml ├── pillar.example ├── pre-commit_semantic-release.sh ├── rabbitmq ├── _mapdata │ ├── _mapdata.jinja │ └── init.sls ├── clean.sls ├── config │ ├── bindings │ │ ├── clean.sls │ │ ├── init.sls │ │ └── install.sls │ ├── clean.sls │ ├── clusters │ │ ├── clean.sls │ │ ├── init.sls │ │ └── install.sls │ ├── exchanges │ │ ├── clean.sls │ │ ├── init.sls │ │ └── install.sls │ ├── files │ │ ├── clean.sls │ │ ├── init.sls │ │ └── install.sls │ ├── init.sls │ ├── parameters │ │ ├── clean.sls │ │ ├── init.sls │ │ └── install.sls │ ├── plugins │ │ ├── clean.sls │ │ ├── init.sls │ │ └── install.sls │ ├── policies │ │ ├── clean.sls │ │ ├── init.sls │ │ └── install.sls │ ├── queues │ │ ├── clean.sls │ │ ├── init.sls │ │ └── install.sls │ ├── users │ │ ├── clean.sls │ │ ├── init.sls │ │ └── install.sls │ └── vhosts │ │ ├── clean.sls │ │ ├── init.sls │ │ └── install.sls ├── files │ └── default │ │ ├── config.tmpl │ │ └── systemd.ini.jinja ├── init.sls ├── libmapstack.jinja ├── libmatchers.jinja ├── libsaltcli.jinja ├── libtofs.jinja ├── map.jinja ├── package │ ├── clean.sls │ ├── init.sls │ ├── install.sls │ └── repo │ │ ├── clean.sls │ │ ├── init.sls │ │ └── install.sls ├── parameters │ ├── defaults.yaml │ ├── os │ │ ├── Fedora.yaml │ │ ├── MacOS.yaml.jinja │ │ └── Ubuntu.yaml │ ├── os_family │ │ ├── Arch.yaml │ │ ├── Debian.yaml │ │ ├── FreeBSD.yaml │ │ ├── Gentoo.yaml │ │ ├── OpenBSD.yaml │ │ ├── RedHat.yaml │ │ └── Suse.yaml │ ├── osarch │ │ ├── 386.yaml │ │ ├── amd64.yaml │ │ ├── arm64.yaml │ │ ├── armv6l.yaml │ │ ├── armv7l.yaml │ │ ├── ppc64le.yaml │ │ ├── s390x.yaml │ │ └── x86_64.yaml │ └── osfinger │ │ ├── CentOS-6.yaml │ │ ├── CentOS-7.yaml │ │ └── Ubuntu-18.04.yaml └── service │ ├── clean.sls │ ├── init.sls │ └── running.sls ├── release-rules.js ├── release.config.js └── test ├── integration ├── default │ ├── README.md │ ├── controls │ │ ├── _mapdata.rb │ │ ├── config.rb │ │ ├── packages.rb │ │ ├── rabbitmq_users_spec.rb │ │ └── services.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-32.yaml │ │ │ ├── fedora-33.yaml │ │ │ ├── fedora-34.yaml │ │ │ ├── fedora-35.yaml │ │ │ ├── fedora-36.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-16.yaml │ │ │ ├── ubuntu-18.yaml │ │ │ ├── ubuntu-20.yaml │ │ │ └── ubuntu-22.yaml │ └── inspec.yml ├── nopillars │ ├── README.md │ ├── controls │ │ ├── _mapdata.rb │ │ ├── config.rb │ │ ├── packages.rb │ │ ├── rabbitmq_users_spec.rb │ │ └── services.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-32.yaml │ │ │ ├── fedora-33.yaml │ │ │ ├── fedora-34.yaml │ │ │ ├── fedora-35.yaml │ │ │ ├── fedora-36.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-16.yaml │ │ │ ├── ubuntu-18.yaml │ │ │ ├── ubuntu-20.yaml │ │ │ └── ubuntu-22.yaml │ └── inspec.yml └── share │ ├── README.md │ ├── inspec.yml │ └── libraries │ └── system.rb └── salt ├── files └── rabbitmq │ └── rabbitmq.conf ├── pillar └── nopillars.sls └── states └── files └── init.sls /.github/workflows/commitlint.yml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | name: Commitlint 5 | 'on': [pull_request] 6 | 7 | jobs: 8 | lint: 9 | runs-on: ubuntu-latest 10 | env: 11 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 12 | steps: 13 | - uses: actions/checkout@v2 14 | with: 15 | fetch-depth: 0 16 | - uses: wagoid/commitlint-github-action@v1 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a packager 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .kitchen 49 | .kitchen.local.yml 50 | kitchen.local.yml 51 | junit-*.xml 52 | 53 | # Translations 54 | *.mo 55 | *.pot 56 | 57 | # Django stuff: 58 | *.log 59 | local_settings.py 60 | 61 | # Flask stuff: 62 | instance/ 63 | .webassets-cache 64 | 65 | # Scrapy stuff: 66 | .scrapy 67 | 68 | # Sphinx documentation 69 | docs/_build/ 70 | 71 | # PyBuilder 72 | target/ 73 | 74 | # Jupyter Notebook 75 | .ipynb_checkpoints 76 | 77 | # pyenv 78 | .python-version 79 | 80 | # celery beat schedule file 81 | celerybeat-schedule 82 | 83 | # SageMath parsed files 84 | *.sage.py 85 | 86 | # dotenv 87 | .env 88 | 89 | # virtualenv 90 | .venv 91 | venv/ 92 | ENV/ 93 | 94 | # visual studio 95 | .vs/ 96 | 97 | # Spyder project settings 98 | .spyderproject 99 | .spyproject 100 | 101 | # Rope project settings 102 | .ropeproject 103 | 104 | # mkdocs documentation 105 | /site 106 | 107 | # mypy 108 | .mypy_cache/ 109 | 110 | # Bundler 111 | .bundle/ 112 | 113 | # copied `.md` files used for conversion to `.rst` using `m2r` 114 | docs/*.md 115 | 116 | # Vim 117 | *.sw? 118 | 119 | ## Collected when centralising formulas (check and sort) 120 | # `collectd-formula` 121 | .pytest_cache/ 122 | /.idea/ 123 | Dockerfile.*_* 124 | ignore/ 125 | tmp/ 126 | 127 | # `salt-formula` -- Vagrant Specific files 128 | .vagrant 129 | top.sls 130 | !test/salt/pillar/top.sls 131 | 132 | # `suricata-formula` -- Platform binaries 133 | *.rpm 134 | *.deb 135 | -------------------------------------------------------------------------------- /.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.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=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 | 206: # Jinja variables should have spaces before and after: '{{ var_name }}' 7 | ignore: | 8 | rabbitmq/files/default/systemd.ini.jinja 9 | skip_list: 10 | # Using `salt-lint` for linting other files as well, such as Jinja macros/templates 11 | - 205 # Use ".sls" as a Salt State file extension 12 | # Skipping `207` and `208` because `210` is sufficient, at least for the time-being 13 | # I.e. Allows 3-digit unquoted codes to still be used, such as `644` and `755` 14 | - 207 # File modes should always be encapsulated in quotation marks 15 | - 208 # File modes should always contain a leading zero 16 | tags: [] 17 | verbosity: 1 18 | -------------------------------------------------------------------------------- /.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)|159 8 | @noelmcloughlin|[@noelmcloughlin](https://github.com/noelmcloughlin)|106 9 | @gravyboat|[@gravyboat](https://github.com/gravyboat)|11 10 | @daks|[@daks](https://github.com/daks)|9 11 | @dafyddj|[@dafyddj](https://github.com/dafyddj)|7 12 | @nmadhok|[@nmadhok](https://github.com/nmadhok)|6 13 | @sylvainfaivre|[@sylvainfaivre](https://github.com/sylvainfaivre)|5 14 | @jeff350|[@jeff350](https://github.com/jeff350)|4 15 | @thatch45|[@thatch45](https://github.com/thatch45)|4 16 | @baby-gnu|[@baby-gnu](https://github.com/baby-gnu)|3 17 | @stp-ip|[@stp-ip](https://github.com/stp-ip)|3 18 | @aboe76|[@aboe76](https://github.com/aboe76)|3 19 | @PredatorVI|[@PredatorVI](https://github.com/PredatorVI)|3 20 | @tiger-seo|[@tiger-seo](https://github.com/tiger-seo)|3 21 | @david-thorman|[@david-thorman](https://github.com/david-thorman)|2 22 | @jmdcal|[@jmdcal](https://github.com/jmdcal)|2 23 | @techhat|[@techhat](https://github.com/techhat)|2 24 | @mdschmitt|[@mdschmitt](https://github.com/mdschmitt)|2 25 | @stasjok|[@stasjok](https://github.com/stasjok)|2 26 | @puneetk|[@puneetk](https://github.com/puneetk)|2 27 | @tonyo|[@tonyo](https://github.com/tonyo)|1 28 | @syphernl|[@syphernl](https://github.com/syphernl)|1 29 | @Frots|[@Frots](https://github.com/Frots)|1 30 | @gustavobgama|[@gustavobgama](https://github.com/gustavobgama)|1 31 | @jaygorrell|[@jaygorrell](https://github.com/jaygorrell)|1 32 | @johnkeates|[@johnkeates](https://github.com/johnkeates)|1 33 | @jeffrey4l|[@jeffrey4l](https://github.com/jeffrey4l)|1 34 | @martinhoefling|[@martinhoefling](https://github.com/martinhoefling)|1 35 | @mgar|[@mgar](https://github.com/mgar)|1 36 | @whiteinge|[@whiteinge](https://github.com/whiteinge)|1 37 | @soniah|[@soniah](https://github.com/soniah)|1 38 | @wwentland|[@wwentland](https://github.com/wwentland)|1 39 | @abednarik|[@abednarik](https://github.com/abednarik)|1 40 | @dnABic|[@dnABic](https://github.com/dnABic)|1 41 | @necabo|[@necabo](https://github.com/necabo)|1 42 | 43 | --- 44 | 45 | Auto-generated by a [forked version](https://github.com/myii/maintainer) of [gaocegege/maintainer](https://github.com/gaocegege/maintainer) on 2023-12-06. 46 | -------------------------------------------------------------------------------- /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: rabbitmq 2 | os: Debian, Ubuntu 3 | os_family: Debian 4 | version: 2.2.5 5 | release: 1 6 | minimum_version: 2017.7 7 | summary: rabbitmq formula 8 | description: Formula to install and configure RabbitMQ 9 | top_level_dir: rabbitmq 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 | # Avoid the error 'pkeys are immutable on OpenSSL 3.0' 22 | gem 'net-ssh', '>= 7.0.0' 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021 Salt Stack Formulas 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /bin/install-hooks: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | set -o nounset # Treat unset variables as an error and immediately exit 3 | set -o errexit # If a command fails exit the whole script 4 | 5 | if [ "${DEBUG:-false}" = "true" ]; then 6 | set -x # Run the entire script in debug mode 7 | fi 8 | 9 | if ! command -v pre-commit >/dev/null 2>&1; then 10 | echo "pre-commit not found: please install or check your PATH" >&2 11 | echo "See https://pre-commit.com/#installation" >&2 12 | exit 1 13 | fi 14 | 15 | pre-commit install --install-hooks 16 | pre-commit install --hook-type commit-msg --install-hooks 17 | -------------------------------------------------------------------------------- /bin/kitchen: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'kitchen' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | require 'pathname' 12 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', 13 | Pathname.new(__FILE__).realpath) 14 | 15 | bundle_binstub = File.expand_path('bundle', __dir__) 16 | 17 | if File.file?(bundle_binstub) 18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ 19 | load(bundle_binstub) 20 | else 21 | abort( 22 | 'Your `bin/bundle` was not generated by Bundler, ' \ 23 | 'so this binstub cannot run. Replace `bin/bundle` by running ' \ 24 | '`bundle binstubs bundler --force`, then run this command again.' 25 | ) 26 | end 27 | end 28 | 29 | require 'rubygems' 30 | require 'bundler/setup' 31 | 32 | load Gem.bin_path('test-kitchen', 'kitchen') 33 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@commitlint/config-conventional'], 3 | rules: { 4 | 'body-max-line-length': [2, 'always', 120], 5 | 'footer-max-line-length': [2, 'always', 120], 6 | 'header-max-length': [2, 'always', 72], 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /docs/AUTHORS.rst: -------------------------------------------------------------------------------- 1 | .. role:: raw-html-m2r(raw) 2 | :format: html 3 | 4 | 5 | Authors 6 | ======= 7 | 8 | This list is sorted by the number of commits per contributor in *descending* order. 9 | 10 | .. list-table:: 11 | :header-rows: 1 12 | 13 | * - Avatar 14 | - Contributor 15 | - Contributions 16 | * - :raw-html-m2r:`@myii` 17 | - `@myii `_ 18 | - 159 19 | * - :raw-html-m2r:`@noelmcloughlin` 20 | - `@noelmcloughlin `_ 21 | - 106 22 | * - :raw-html-m2r:`@gravyboat` 23 | - `@gravyboat `_ 24 | - 11 25 | * - :raw-html-m2r:`@daks` 26 | - `@daks `_ 27 | - 9 28 | * - :raw-html-m2r:`@dafyddj` 29 | - `@dafyddj `_ 30 | - 7 31 | * - :raw-html-m2r:`@nmadhok` 32 | - `@nmadhok `_ 33 | - 6 34 | * - :raw-html-m2r:`@sylvainfaivre` 35 | - `@sylvainfaivre `_ 36 | - 5 37 | * - :raw-html-m2r:`@jeff350` 38 | - `@jeff350 `_ 39 | - 4 40 | * - :raw-html-m2r:`@thatch45` 41 | - `@thatch45 `_ 42 | - 4 43 | * - :raw-html-m2r:`@baby-gnu` 44 | - `@baby-gnu `_ 45 | - 3 46 | * - :raw-html-m2r:`@stp-ip` 47 | - `@stp-ip `_ 48 | - 3 49 | * - :raw-html-m2r:`@aboe76` 50 | - `@aboe76 `_ 51 | - 3 52 | * - :raw-html-m2r:`@PredatorVI` 53 | - `@PredatorVI `_ 54 | - 3 55 | * - :raw-html-m2r:`@tiger-seo` 56 | - `@tiger-seo `_ 57 | - 3 58 | * - :raw-html-m2r:`@david-thorman` 59 | - `@david-thorman `_ 60 | - 2 61 | * - :raw-html-m2r:`@jmdcal` 62 | - `@jmdcal `_ 63 | - 2 64 | * - :raw-html-m2r:`@techhat` 65 | - `@techhat `_ 66 | - 2 67 | * - :raw-html-m2r:`@mdschmitt` 68 | - `@mdschmitt `_ 69 | - 2 70 | * - :raw-html-m2r:`@stasjok` 71 | - `@stasjok `_ 72 | - 2 73 | * - :raw-html-m2r:`@puneetk` 74 | - `@puneetk `_ 75 | - 2 76 | * - :raw-html-m2r:`@tonyo` 77 | - `@tonyo `_ 78 | - 1 79 | * - :raw-html-m2r:`@syphernl` 80 | - `@syphernl `_ 81 | - 1 82 | * - :raw-html-m2r:`@Frots` 83 | - `@Frots `_ 84 | - 1 85 | * - :raw-html-m2r:`@gustavobgama` 86 | - `@gustavobgama `_ 87 | - 1 88 | * - :raw-html-m2r:`@jaygorrell` 89 | - `@jaygorrell `_ 90 | - 1 91 | * - :raw-html-m2r:`@johnkeates` 92 | - `@johnkeates `_ 93 | - 1 94 | * - :raw-html-m2r:`@jeffrey4l` 95 | - `@jeffrey4l `_ 96 | - 1 97 | * - :raw-html-m2r:`@martinhoefling` 98 | - `@martinhoefling `_ 99 | - 1 100 | * - :raw-html-m2r:`@mgar` 101 | - `@mgar `_ 102 | - 1 103 | * - :raw-html-m2r:`@whiteinge` 104 | - `@whiteinge `_ 105 | - 1 106 | * - :raw-html-m2r:`@soniah` 107 | - `@soniah `_ 108 | - 1 109 | * - :raw-html-m2r:`@wwentland` 110 | - `@wwentland `_ 111 | - 1 112 | * - :raw-html-m2r:`@abednarik` 113 | - `@abednarik `_ 114 | - 1 115 | * - :raw-html-m2r:`@dnABic` 116 | - `@dnABic `_ 117 | - 1 118 | * - :raw-html-m2r:`@necabo` 119 | - `@necabo `_ 120 | - 1 121 | 122 | 123 | ---- 124 | 125 | Auto-generated by a `forked version `_ of `gaocegege/maintainer `_ on 2023-12-06. 126 | -------------------------------------------------------------------------------- /docs/README.rst: -------------------------------------------------------------------------------- 1 | .. _readme: 2 | 3 | rabbitmq-formula 4 | ================ 5 | 6 | |img_travis| |img_sr| |img_pc| 7 | 8 | .. |img_travis| image:: https://travis-ci.com/saltstack-formulas/rabbitmq-formula.svg?branch=master 9 | :alt: Travis CI Build Status 10 | :scale: 100% 11 | :target: https://travis-ci.com/saltstack-formulas/rabbitmq-formula 12 | .. |img_sr| image:: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg 13 | :alt: Semantic Release 14 | :scale: 100% 15 | :target: https://github.com/semantic-release/semantic-release 16 | .. |img_pc| image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white 17 | :alt: pre-commit 18 | :scale: 100% 19 | :target: https://github.com/pre-commit/pre-commit 20 | 21 | This formula installs and configures RabbitMQ server on GNU/Linux. 22 | 23 | .. contents:: **Table of Contents** 24 | :depth: 1 25 | 26 | General notes 27 | ------------- 28 | 29 | See the full `SaltStack Formulas installation and usage instructions 30 | `_. 31 | 32 | If you are interested in writing or contributing to formulas, please pay attention to the `Writing Formula Section 33 | `_. 34 | 35 | If you want to use this formula, please pay attention to the ``FORMULA`` file and/or ``git tag``, 36 | which contains the currently released version. This formula is versioned according to `Semantic Versioning `_. 37 | 38 | See `Formula Versioning Section `_ for more details. 39 | 40 | If you need (non-default) configuration, please refer to: 41 | 42 | - `how to configure the formula with map.jinja `_ 43 | - the ``pillar.example`` file 44 | - the `Special notes`_ section 45 | 46 | Contributing to this repo 47 | ------------------------- 48 | 49 | Commit messages 50 | ^^^^^^^^^^^^^^^ 51 | 52 | **Commit message formatting is significant!!** 53 | 54 | Please see `How to contribute `_ for more details. 55 | 56 | pre-commit 57 | ^^^^^^^^^^ 58 | 59 | `pre-commit `_ is configured for this formula, which you may optionally use to ease the steps involved in submitting your changes. 60 | First install the ``pre-commit`` package manager using the appropriate `method `_, then run ``bin/install-hooks`` and 61 | now ``pre-commit`` will run automatically on each ``git commit``. :: 62 | 63 | $ bin/install-hooks 64 | pre-commit installed at .git/hooks/pre-commit 65 | pre-commit installed at .git/hooks/commit-msg 66 | 67 | Special notes 68 | ------------- 69 | 70 | The default node in any rabbitmq installation is 'rabbit@localhost'. Multiple nodes per host are allowed if defined in pillar data under `rabbitmq:nodes`. Clustering is supported, see `pillar.example`. 71 | 72 | Available states 73 | ---------------- 74 | 75 | .. contents:: 76 | :local: 77 | 78 | ``rabbitmq`` 79 | ^^^^^^^^^^^^ 80 | 81 | *Meta-state (This is a state that includes other states)*. 82 | 83 | This installs the rabbitmq package, 84 | manages the rabbitmq configuration file and then 85 | starts the associated rabbitmq service. 86 | 87 | ``rabbitmq.package`` 88 | ^^^^^^^^^^^^^^^^^^^^ 89 | 90 | This state will install the rabbitmq package and has a dependency on ``rabbitmq.install`` 91 | via include list. 92 | 93 | ``rabbitmq.config`` 94 | ^^^^^^^^^^^^^^^^^^^ 95 | 96 | This state will configure the rabbitmq service and has a dependency on ``rabbitmq.install`` 97 | via include list. It excludes ``rabbitmq.config.cluster`` state 98 | 99 | ``rabbitmq.service`` 100 | ^^^^^^^^^^^^^^^^^^^^ 101 | 102 | This state will start the rabbitmq service and has a dependency on ``rabbitmq.config`` 103 | via include list. 104 | 105 | ``rabbitmq.clean`` 106 | ^^^^^^^^^^^^^^^^^^ 107 | 108 | *Meta-state (This is a state that includes other states)*. 109 | 110 | this state will undo everything performed in the ``rabbitmq`` meta-state in reverse order, i.e. 111 | stops the service, 112 | removes the configuration file and 113 | then uninstalls the package. 114 | 115 | ``rabbitmq.service.clean`` 116 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 117 | 118 | This state will stop the rabbitmq service and disable it at boot time. 119 | 120 | ``rabbitmq.config.clean`` 121 | ^^^^^^^^^^^^^^^^^^^^^^^^^ 122 | 123 | This state will remove the configuration of the rabbitmq service and has a 124 | dependency on ``rabbitmq.service.clean`` via include list. 125 | 126 | ``rabbitmq.package.clean`` 127 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 128 | 129 | This state will remove the rabbitmq package and has a depency on 130 | ``rabbitmq.config.clean`` via include list. 131 | 132 | *Meta-state (This is a state that includes other states)*. 133 | 134 | Testing 135 | ------- 136 | 137 | Linux testing is done with ``kitchen-salt``. 138 | 139 | Requirements 140 | ^^^^^^^^^^^^ 141 | 142 | * Ruby 143 | * Docker 144 | 145 | .. code-block:: bash 146 | 147 | $ gem install bundler 148 | $ bundle install 149 | $ bin/kitchen test [platform] 150 | 151 | Where ``[platform]`` is the platform name defined in ``kitchen.yml``, 152 | e.g. ``debian-9-2019-2-py3``. 153 | 154 | ``bin/kitchen converge`` 155 | ^^^^^^^^^^^^^^^^^^^^^^^^ 156 | 157 | Creates the docker instance and runs the ``rabbitmq`` main state, ready for testing. 158 | 159 | ``bin/kitchen verify`` 160 | ^^^^^^^^^^^^^^^^^^^^^^ 161 | 162 | Runs the ``inspec`` tests on the actual instance. 163 | 164 | ``bin/kitchen destroy`` 165 | ^^^^^^^^^^^^^^^^^^^^^^^ 166 | 167 | Removes the docker instance. 168 | 169 | ``bin/kitchen test`` 170 | ^^^^^^^^^^^^^^^^^^^^ 171 | 172 | Runs all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``verify`` + ``destroy``. 173 | 174 | ``bin/kitchen login`` 175 | ^^^^^^^^^^^^^^^^^^^^^ 176 | 177 | Gives you SSH access to the instance for manual testing. 178 | -------------------------------------------------------------------------------- /docs/_static/css/custom.css: -------------------------------------------------------------------------------- 1 | /* 2 | Override styles for in-use Sphinx theme 3 | */ 4 | 5 | /* The next two `.wy`-based rules are specifically needed for the dealing with */ 6 | /* the `sphinx_rtd_theme` bug where long lines do not wrap in tables */ 7 | 8 | /* override table width restrictions */ 9 | .wy-table-responsive table th 10 | , .wy-table-responsive table td 11 | { 12 | /* !important prevents the common CSS stylesheets from 13 | overriding this as on RTD they are loaded after this stylesheet */ 14 | white-space: normal !important; 15 | } 16 | 17 | .wy-table-responsive 18 | { 19 | overflow: visible !important; 20 | } 21 | -------------------------------------------------------------------------------- /pre-commit_semantic-release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ############################################################################### 4 | # (A) Update `FORMULA` with `${nextRelease.version}` 5 | ############################################################################### 6 | sed -i -e "s_^\(version:\).*_\1 ${1}_" FORMULA 7 | 8 | 9 | ############################################################################### 10 | # (B) Use `m2r2` to convert automatically produced `.md` docs to `.rst` 11 | ############################################################################### 12 | 13 | # Install `m2r2` 14 | pip3 install m2r2 15 | 16 | # Copy and then convert the `.md` docs 17 | cp ./*.md docs/ 18 | cd docs/ || exit 19 | m2r2 --overwrite ./*.md 20 | 21 | # Change excess `H1` headings to `H2` in converted `CHANGELOG.rst` 22 | sed -i -e '/^=.*$/s/=/-/g' CHANGELOG.rst 23 | sed -i -e '1,4s/-/=/g' CHANGELOG.rst 24 | 25 | # Use for debugging output, when required 26 | # cat AUTHORS.rst 27 | # cat CHANGELOG.rst 28 | 29 | # Return back to the main directory 30 | cd .. 31 | -------------------------------------------------------------------------------- /rabbitmq/_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 | -------------------------------------------------------------------------------- /rabbitmq/_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 | -------------------------------------------------------------------------------- /rabbitmq/clean.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | include: 5 | - .config.clean 6 | - .service.clean 7 | - .package.clean 8 | -------------------------------------------------------------------------------- /rabbitmq/config/bindings/clean.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | --- 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %} 6 | {%- set sls_config_users_clean = tplroot ~ '.config.users.clean' %} 7 | {%- set sls_config_vhosts_clean = tplroot ~ '.config.vhosts.clean' %} 8 | {%- set sls_config_plugins_clean = tplroot ~ '.config.plugins.clean' %} 9 | 10 | include: 11 | - {{ sls_config_plugins_clean }} 12 | - {{ sls_config_users_clean }} 13 | - {{ sls_config_vhosts_clean }} 14 | 15 | {%- for name, node in rabbitmq.nodes.items() %} 16 | {%- if 'bindings' in node and node.bindings is mapping %} 17 | {%- for binding, b in node.bindings.items() %} 18 | 19 | rabbitmq-config-bindings-delete-{{ name }}-{{ binding }}: 20 | cmd.run: 21 | - name: /usr/local/sbin/rabbitmqadmin --node {{ name }} --port={{ node.nodeport + 10000 }} delete binding --vhost={{ b.vhost }} --username={{ b.user }} --password={{ b.passwd }} source={{ b.source }} destination={{ b.destination }} destination_type={{ b.destination_type }} || true # noqa 204 22 | - onlyif: 23 | - test -x /usr/local/sbin/rabbitmqadmin 24 | - test -d {{ rabbitmq.dir.data }} 25 | - runas: rabbitmq 26 | - require_in: 27 | - sls: {{ sls_config_plugins_clean }} 28 | - sls: {{ sls_config_users_clean }} 29 | - sls: {{ sls_config_vhosts_clean }} 30 | 31 | {%- endfor %} 32 | {%- endif %} 33 | {%- endfor %} 34 | -------------------------------------------------------------------------------- /rabbitmq/config/bindings/init.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | include: 5 | - .install 6 | -------------------------------------------------------------------------------- /rabbitmq/config/bindings/install.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | --- 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %} 6 | {%- set sls_config_plugins = tplroot ~ '.config.plugins.install' %} 7 | {%- set sls_config_users = tplroot ~ '.config.users.install' %} 8 | {%- set sls_config_vhosts = tplroot ~ '.config.vhosts.install' %} 9 | 10 | include: 11 | - {{ sls_config_plugins }} 12 | - {{ sls_config_users }} 13 | - {{ sls_config_vhosts }} 14 | 15 | {%- for name, node in rabbitmq.nodes.items() %} 16 | {%- if 'bindings' in node and node.bindings is mapping %} 17 | {%- for binding, b in node.bindings.items() %} 18 | 19 | rabbitmq-config-bindings-enabled-{{ name }}-{{ binding }}: 20 | cmd.run: 21 | - name: /usr/local/sbin/rabbitmqadmin --node {{ name }} --port={{ node.nodeport + 10000 }} declare binding --vhost={{ b.vhost }} --username={{ b.user }} --password={{ b.passwd }} source={{ b.source }} destination={{ b.destination }} destination_type={{ b.destination_type }} routing_key={{ b.routing_key }} # noqa 204 22 | - onlyif: test -x /usr/local/sbin/rabbitmqadmin 23 | - runas: rabbitmq 24 | - require: 25 | - sls: {{ sls_config_plugins }} 26 | - sls: {{ sls_config_users }} 27 | - sls: {{ sls_config_vhosts }} 28 | 29 | {%- endfor %} 30 | {%- endif %} 31 | {%- endfor %} 32 | -------------------------------------------------------------------------------- /rabbitmq/config/clean.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | include: 5 | - .parameters.clean 6 | - .policies.clean 7 | - .bindings.clean 8 | - .exchanges.clean 9 | - .queues.clean 10 | - .vhosts.clean 11 | - .clusters.clean 12 | - .users.clean 13 | - .plugins.clean 14 | - .files.clean 15 | -------------------------------------------------------------------------------- /rabbitmq/config/clusters/clean.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %} 6 | 7 | {%- for name, node in rabbitmq.nodes.items() %} 8 | {%- if 'clustered' in node and node.clustered %} 9 | 10 | rabbitmq-config-clusters-{{ name }}-reset: 11 | cmd.run: 12 | - names: 13 | - /usr/sbin/rabbitmqctl --node {{ name }} stop_app || true 14 | - /usr/sbin/rabbitmqctl --node {{ name }} reset || true 15 | - /usr/sbin/rabbitmqctl --node {{ name }} start_app || true 16 | - /usr/sbin/rabbitmqctl --node {{ name }} cluster_status || true 17 | - runas: rabbitmq 18 | - onlyif: 19 | - test -x /usr/sbin/rabbitmqctl 20 | - test -d {{ rabbitmq.dir.data }} 21 | 22 | {%- endif %} 23 | {%- endfor %} 24 | -------------------------------------------------------------------------------- /rabbitmq/config/clusters/init.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | include: 5 | - .install 6 | -------------------------------------------------------------------------------- /rabbitmq/config/clusters/install.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %} 6 | {%- set sls_service_running = tplroot ~ '.service.running' %} 7 | {%- set sls_config_users = tplroot ~ '.config.users.install' %} 8 | {%- set sls_config_files = tplroot ~ '.config.files.install' %} 9 | 10 | include: 11 | - {{ sls_service_running }} 12 | - {{ sls_config_users }} 13 | - {{ sls_config_files }} 14 | 15 | {%- for name, node in rabbitmq.nodes.items() %} 16 | {%- if 'clustered' in node and node.clustered and 'join_node' in node %} 17 | 18 | rabbitmq-config-clusters-{{ name }}-join-{{ node.join_node }}: 19 | cmd.run: 20 | - names: 21 | - /usr/sbin/rabbitmqctl --node {{ name }} stop_app 22 | - /usr/sbin/rabbitmqctl --node {{ name }} join_cluster {{ node.join_node }} 23 | - /usr/sbin/rabbitmqctl --node {{ name }} start_app 24 | - /usr/sbin/rabbitmqctl --node {{ name }} cluster_status 25 | - runas: rabbitmq 26 | - onlyif: test -x /usr/sbin/rabbitmqctl 27 | - require: 28 | - file: rabbitmq-config-files-managed-erlang-cookie 29 | - sls: {{ sls_config_users }} 30 | - service: rabbitmq-service-running-service-running-{{ name }} 31 | 32 | {%- endif %} 33 | {%- endfor %} 34 | -------------------------------------------------------------------------------- /rabbitmq/config/exchanges/clean.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | --- 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %} 6 | {%- set sls_config_users_clean = tplroot ~ '.config.users.clean' %} 7 | {%- set sls_config_vhosts_clean = tplroot ~ '.config.vhosts.clean' %} 8 | {%- set sls_config_plugins_clean = tplroot ~ '.config.plugins.clean' %} 9 | 10 | include: 11 | - {{ sls_config_plugins_clean }} 12 | - {{ sls_config_users_clean }} 13 | - {{ sls_config_vhosts_clean }} 14 | 15 | {%- for name, node in rabbitmq.nodes.items() %} 16 | {%- if 'exchanges' in node and node.exchanges is mapping %} 17 | {%- for exchange, q in node.exchanges.items() %} 18 | 19 | rabbitmq-config-exchanges-delete-{{ name }}-{{ exchange }}: 20 | cmd.run: 21 | - name: /usr/local/sbin/rabbitmqadmin --node {{ name }} --port={{ node.nodeport + 10000 }} delete exchange --vhost={{ q.vhost }} --username={{ q.user }} --password={{ q.passwd }} name={{ exchange }} || true # noqa 204 22 | - onlyif: 23 | - test -x /usr/local/sbin/rabbitmqadmin 24 | - test -d {{ rabbitmq.dir.data }} 25 | - runas: rabbitmq 26 | - require_in: 27 | - {{ sls_config_users_clean }} 28 | - {{ sls_config_vhosts_clean }} 29 | - {{ sls_config_plugins_clean }} 30 | 31 | {%- endfor %} 32 | {%- endif %} 33 | {%- endfor %} 34 | -------------------------------------------------------------------------------- /rabbitmq/config/exchanges/init.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | include: 5 | - .install 6 | -------------------------------------------------------------------------------- /rabbitmq/config/exchanges/install.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | --- 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %} 6 | {%- set sls_config_plugins = tplroot ~ '.config.plugins.install' %} 7 | {%- set sls_config_users = tplroot ~ '.config.users.install' %} 8 | {%- set sls_config_vhosts = tplroot ~ '.config.vhosts.install' %} 9 | 10 | include: 11 | - {{ sls_config_plugins }} 12 | - {{ sls_config_users }} 13 | - {{ sls_config_vhosts }} 14 | 15 | {%- for name, node in rabbitmq.nodes.items() %} 16 | {%- if 'exchanges' in node and node.exchanges is mapping %} 17 | {%- for exchange, ex in node.exchanges.items() %} 18 | 19 | rabbitmq-config-exchanges-enabled-{{ name }}-{{ exchange }}: 20 | cmd.run: 21 | - name: >- 22 | /usr/local/sbin/rabbitmqadmin --node {{ name }} --port={{ node.nodeport + 10000 }} declare exchange --vhost={{ ex.vhost }} --username={{ ex.user }} --password={{ ex.passwd }} name={{ exchange }} type={{ ex.type }} durable={{ ex.durable }} internal={{ ex.internal }} auto_delete={{ ex.auto_delete }} arguments='{{ "{}" if "arguments" not in ex else ex.arguments|json }}' # noqa 204 23 | - onlyif: test -x /usr/local/sbin/rabbitmqadmin 24 | - runas: rabbitmq 25 | - require: 26 | - sls: {{ sls_config_plugins }} 27 | - sls: {{ sls_config_users }} 28 | - sls: {{ sls_config_vhosts }} 29 | 30 | {%- endfor %} 31 | {%- endif %} 32 | {%- endfor %} 33 | -------------------------------------------------------------------------------- /rabbitmq/config/files/clean.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %} 6 | {%- set sls_package_clean = tplroot ~ '.package.clean' %} 7 | 8 | include: 9 | - {{ sls_package_clean }} 10 | 11 | {%- for name, node in rabbitmq.nodes.items() %} 12 | 13 | rabbitmq-config-files-absent-{{ name }}: 14 | file.absent: 15 | - names: 16 | - {{ rabbitmq.dir.config }} 17 | - require_in: 18 | - sls: {{ sls_package_clean }} 19 | 20 | {%- endfor %} 21 | -------------------------------------------------------------------------------- /rabbitmq/config/files/init.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | include: 5 | - .install 6 | -------------------------------------------------------------------------------- /rabbitmq/config/files/install.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | --- 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import mapdata as r with context %} 6 | {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} 7 | {%- set sls_service_running = tplroot ~ '.service.running' %} 8 | 9 | include: 10 | - {{ sls_service_running }} 11 | 12 | {%- if 'erlang_cookie' in r and r.erlang_cookie %} 13 | 14 | rabbitmq-config-files-managed-erlang-cookie: 15 | file.managed: 16 | - name: {{ r.dir.data }}/.erlang.cookie 17 | - contents: {{ r.erlang_cookie }} 18 | - mode: 400 19 | - user: rabbitmq 20 | - group: {{ r.rootgroup }} 21 | - makedirs: True 22 | 23 | {%- endif %} 24 | {%- for name, node in r.nodes.items() %} 25 | {%- if 'config' in node and node.config is mapping %} 26 | 27 | rabbitmq-config-files-managed-{{ name }}: 28 | file.managed: 29 | - name: '{{ r.dir.config }}/{{ name }}/rabbitmq-server.conf' 30 | - source: {{ files_switch(['config.tmpl'], 31 | lookup='rabbitmq-config-files-managed-' ~ name 32 | ) 33 | }} 34 | - mode: 644 35 | - user: root 36 | - group: {{ r.rootgroup }} 37 | - makedirs: True 38 | - template: jinja 39 | - context: 40 | config: {{ node.config | json }} 41 | - require: 42 | - file: rabbitmq-config-files-managed-erlang-cookie 43 | - require_in: 44 | - service: rabbitmq-service-running-service-running-{{ name }} 45 | - watch_in: 46 | - service: rabbitmq-service-running-service-running-{{ name }} 47 | 48 | {%- endif %} 49 | {%- endfor %} 50 | {%- if 'environ' in r and r.environ %} 51 | 52 | rabbitmq-config-files-environ-managed: 53 | file.managed: 54 | - name: {{ r.dir.config }}/rabbitmq-env.conf 55 | - source: {{ files_switch(['config.tmpl'], 56 | lookup='rabbitmq-config-files-environ-managed' 57 | ) 58 | }} 59 | - mode: 644 60 | - user: root 61 | - group: {{ r.rootgroup }} 62 | - makedirs: True 63 | - template: jinja 64 | - context: 65 | env: {{ r.environ | json }} 66 | 67 | {%- endif %} 68 | {%- if grains.os_family == 'RedHat' and 'locale_all' in r.environ %} 69 | 70 | rabbitmq-config-files-environ-setenv: 71 | environ.setenv: 72 | - name: LC_ALL 73 | - value: {{ 'en_US.UTF-8' if 'locale_all' not in r.environ else r.environ.locale_all }} 74 | - update_minion: True 75 | 76 | {%- endif %} 77 | -------------------------------------------------------------------------------- /rabbitmq/config/init.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | include: 5 | - .files 6 | - .vhosts 7 | - .users 8 | - .queues 9 | - .plugins 10 | - .exchanges 11 | - .bindings 12 | - .policies 13 | - .parameters 14 | - .clusters 15 | -------------------------------------------------------------------------------- /rabbitmq/config/parameters/clean.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | --- 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %} 6 | {%- set sls_config_users_clean = tplroot ~ '.config.users.clean' %} 7 | {%- set sls_config_vhosts_clean = tplroot ~ '.config.vhosts.clean' %} 8 | 9 | include: 10 | - {{ sls_config_users_clean }} 11 | - {{ sls_config_vhosts_clean }} 12 | 13 | {%- for name, node in rabbitmq.nodes.items() %} 14 | {%- if 'parameters' in node and node.parameters is mapping %} 15 | {%- for param, p in node.parameters.items() %} 16 | 17 | rabbitmq-config-parameters-clear-{{ name }}-{{ param }}: 18 | cmd.run: 19 | - name: /usr/sbin/rabbitmqctl --node {{ name }} clear_parameter --vhost={{ '/' if 'vhost' not in p else p.vhost }} {{ p.component }} {{ param }} || true # noqa 204 20 | - onlyif: 21 | - test -x /usr/sbin/rabbitmqctl 22 | - test -d {{ rabbitmq.dir.data }} 23 | - runas: rabbitmq 24 | - require_in: 25 | - sls: {{ sls_config_vhosts_clean }} 26 | - sls: {{ sls_config_users_clean }} 27 | 28 | 29 | {%- endfor %} 30 | {%- endif %} 31 | {%- endfor %} 32 | -------------------------------------------------------------------------------- /rabbitmq/config/parameters/init.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | include: 5 | - .install 6 | -------------------------------------------------------------------------------- /rabbitmq/config/parameters/install.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | --- 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %} 6 | {%- set sls_service_running = tplroot ~ '.service.running' %} 7 | 8 | include: 9 | - {{ sls_service_running }} 10 | 11 | {%- for name, node in rabbitmq.nodes.items() %} 12 | {%- if 'parameters' in node and node.parameters is mapping %} 13 | {%- for param, p in node.parameters.items() %} 14 | 15 | rabbitmq-config-parameters-present-{{ name }}-{{ param }}: 16 | cmd.run: 17 | - name: >- 18 | {%- if p.component == 'federation-upstream' %} 19 | /usr/sbin/rabbitmqctl --node {{ name }} set_parameter --vhost={{ '/' if 'vhost' not in p else p.vhost }} {{ p.component }} '{{ param }}' '{{ p.definition|json }}' # noqa 204 20 | {%- else %}{# federation-upstream-set for now #} 21 | /usr/sbin/rabbitmqctl --node {{ name }} set_parameter --vhost={{ '/' if 'vhost' not in p else p.vhost }} {{ p.component }} '{{ param }}' '[{{ p.definition|json }}]' # noqa 204 22 | {%- endif %} 23 | - runas: rabbitmq 24 | - onlyif: test -x /usr/sbin/rabbitmqctl 25 | - require: 26 | - service: rabbitmq-service-running-service-running-{{ name }} 27 | 28 | {%- endfor %} 29 | {%- endif %} 30 | {%- endfor %} 31 | -------------------------------------------------------------------------------- /rabbitmq/config/plugins/clean.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | --- 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %} 6 | {%- set sls_service_clean = tplroot ~ '.service.clean' %} 7 | 8 | include: 9 | - {{ sls_service_clean }} 10 | 11 | {%- for name, node in rabbitmq.nodes.items() %} 12 | {%- if 'plugins' in node and node.plugins is iterable and node.plugins is not string %} 13 | {%- for plugin in node.plugins %} 14 | 15 | rabbitmq-config-plugins-disabled-{{ name }}-{{ plugin }}: 16 | cmd.run: 17 | - name: /usr/sbin/rabbitmq-plugins --node {{ name }} disable {{ plugin }} 18 | - onlyif: 19 | - test -d {{ rabbitmq.dir.data }} 20 | - test -f {{ rabbitmq.dir.config }}/enabled_plugins 21 | - /usr/sbin/rabbitmq-plugins --node {{ name }} is_enabled {{ plugin }} 22 | - runas: root 23 | - require_in: 24 | - file: rabbitmq-config-plugins-clean-rabbitmqadmin 25 | 26 | {%- endfor %} 27 | {%- endif %} 28 | {%- endfor %} 29 | 30 | rabbitmq-config-plugins-clean-rabbitmqadmin: 31 | file.absent: 32 | - name: /usr/local/sbin/rabbitmqadmin 33 | - require_in: 34 | - sls: {{ sls_service_clean }} 35 | -------------------------------------------------------------------------------- /rabbitmq/config/plugins/init.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | include: 5 | - .install 6 | -------------------------------------------------------------------------------- /rabbitmq/config/plugins/install.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | --- 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %} 6 | {%- set sls_service_running = tplroot ~ '.service.running' %} 7 | 8 | include: 9 | - {{ sls_service_running }} 10 | 11 | {%- for name, node in rabbitmq.nodes.items() %} 12 | {%- if 'plugins' in node and node.plugins is iterable and node.plugins is not string %} 13 | {%- for plugin in node.plugins %} 14 | 15 | rabbitmq-config-plugins-enabled-{{ name }}-{{ plugin }}: 16 | cmd.run: 17 | - name: /usr/sbin/rabbitmq-plugins --node {{ name }} enable {{ plugin }} || true 18 | - runas: root 19 | - unless: /usr/sbin/rabbitmq-plugins --node {{ name }} is_enabled {{ plugin }} 20 | - onchanges_in: 21 | - cmd: rabbitmq-service-running-daemon-reload 22 | - watch_in: 23 | - service: rabbitmq-service-running-service-running-{{ name }} 24 | 25 | {%- if plugin == 'rabbitmq_management' %} 26 | 27 | rabbitmq-config-plugins-{{ name }}-rabbitmqadmin-install: 28 | cmd.run: 29 | - name : curl -k -L http://127.0.0.1:15672/cli/rabbitmqadmin -o /usr/local/sbin/rabbitmqadmin 30 | - unless: test -x /usr/local/sbin/rabbitmqadmin 31 | - onlyif: /usr/sbin/rabbitmq-plugins --node {{ name }} is_enabled rabbitmq_management 32 | - require: 33 | - sls: {{ sls_service_running }} 34 | file.managed: 35 | - name: /usr/local/sbin/rabbitmqadmin 36 | - user: root 37 | - force: false 38 | - replace: false 39 | - group: {{ rabbitmq.rootgroup }} 40 | - mode: 755 41 | - require: 42 | - cmd : rabbitmq-config-plugins-{{ name }}-rabbitmqadmin-install 43 | 44 | {%- endif %} 45 | {%- endfor %} 46 | {%- endif %} 47 | {%- endfor %} 48 | -------------------------------------------------------------------------------- /rabbitmq/config/policies/clean.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | --- 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %} 6 | {%- set sls_config_users_clean = tplroot ~ '.config.users.clean' %} 7 | {%- set sls_config_vhosts_clean = tplroot ~ '.config.vhosts.clean' %} 8 | 9 | include: 10 | - {{ sls_config_users_clean }} 11 | - {{ sls_config_vhosts_clean }} 12 | 13 | {%- for name, node in rabbitmq.nodes.items() %} 14 | {%- if 'policies' in node and node.policies is mapping %} 15 | {%- for policy, p in node.policies.items() %} 16 | 17 | rabbitmq-config-policies-clear-{{ name }}-{{ policy }}: 18 | cmd.run: 19 | - name: /usr/sbin/rabbitmqctl --node {{ name }} clear_policy {{ policy }} --vhost={{ '/' if 'vhost' not in p else p.vhost }} || true # noqa 204 20 | - onlyif: 21 | - test -x /usr/sbin/rabbitmqctl 22 | - test -d {{ rabbitmq.dir.data }} 23 | - runas: rabbitmq 24 | - require_in: 25 | - sls: {{ sls_config_vhosts_clean }} 26 | - sls: {{ sls_config_users_clean }} 27 | 28 | 29 | {%- endfor %} 30 | {%- endif %} 31 | {%- endfor %} 32 | -------------------------------------------------------------------------------- /rabbitmq/config/policies/init.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | include: 5 | - .install 6 | -------------------------------------------------------------------------------- /rabbitmq/config/policies/install.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | --- 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %} 6 | {%- set sls_service_running = tplroot ~ '.service.running' %} 7 | 8 | include: 9 | - {{ sls_service_running }} 10 | 11 | {%- for name, node in rabbitmq.nodes.items() %} 12 | {%- if 'policies' in node and node.policies is mapping %} 13 | {%- for policy, p in node.policies.items() %} 14 | 15 | rabbitmq-config-policies-enabled-{{ name }}-{{ policy }}: 16 | cmd.run: 17 | - name: >- 18 | /usr/sbin/rabbitmqctl --node {{ name }} set_policy {{ policy }} --vhost={{ '/' if 'vhost' not in p else p.vhost }} '{{ p.pattern }}' '{{ p.definition|json }}' --priority {{ 0 if 'priority' not in p else p.priority }} --apply-to {{ 'all' if 'apply_to' not in p else p.apply_to }} # noqa 204 19 | - runas: rabbitmq 20 | - onlyif: test -x /usr/sbin/rabbitmqctl 21 | - require: 22 | - service: rabbitmq-service-running-service-running-{{ name }} 23 | 24 | {%- endfor %} 25 | {%- endif %} 26 | {%- endfor %} 27 | -------------------------------------------------------------------------------- /rabbitmq/config/queues/clean.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | --- 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %} 6 | {%- set sls_config_users_clean = tplroot ~ '.config.users.clean' %} 7 | {%- set sls_config_vhosts_clean = tplroot ~ '.config.vhosts.clean' %} 8 | {%- set sls_config_plugins_clean = tplroot ~ '.config.plugins.clean' %} 9 | 10 | include: 11 | - {{ sls_config_plugins_clean }} 12 | - {{ sls_config_users_clean }} 13 | - {{ sls_config_vhosts_clean }} 14 | 15 | {%- for name, node in rabbitmq.nodes.items() %} 16 | {%- if 'queues' in node and node.queues is mapping %} 17 | {%- for queue, q in node.queues.items() %} 18 | 19 | rabbitmq-config-queues-delete-{{ name }}-{{ queue }}: 20 | cmd.run: 21 | - name: /usr/local/sbin/rabbitmqadmin --node {{ name }} --port={{ node.nodeport + 10000 }} delete queue --vhost={{ q.vhost }} --username={{ q.user }} --password={{ q.passwd }} name={{ queue }} || true # noqa 204 22 | - onlyif: 23 | - test -x /usr/local/sbin/rabbitmqadmin 24 | - test -x /usr/sbin/rabbitmqctl 25 | - test -d {{ rabbitmq.dir.data }} 26 | - /usr/sbin/rabbitmqctl --node {{ name }} --vhost={{ q.vhost }} list_queues | grep ^{{ queue }}\s* 27 | - runas: rabbitmq 28 | - require_in: 29 | - sls: {{ sls_config_plugins_clean }} 30 | - sls: {{ sls_config_users_clean }} 31 | - sls: {{ sls_config_vhosts_clean }} 32 | 33 | {%- endfor %} 34 | {%- endif %} 35 | {%- endfor %} 36 | -------------------------------------------------------------------------------- /rabbitmq/config/queues/init.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | include: 5 | - .install 6 | -------------------------------------------------------------------------------- /rabbitmq/config/queues/install.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | --- 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %} 6 | {%- set sls_config_plugins = tplroot ~ '.config.plugins.install' %} 7 | {%- set sls_config_users = tplroot ~ '.config.users.install' %} 8 | {%- set sls_config_vhosts = tplroot ~ '.config.vhosts.install' %} 9 | 10 | include: 11 | - {{ sls_config_plugins }} 12 | - {{ sls_config_users }} 13 | - {{ sls_config_vhosts }} 14 | 15 | {%- for name, node in rabbitmq.nodes.items() %} 16 | {%- if 'queues' in node and node.queues is mapping %} 17 | {%- for queue, q in node.queues.items() %} 18 | 19 | rabbitmq-config-queues-enabled-{{ name }}-{{ queue }}: 20 | cmd.run: 21 | - name: >- 22 | /usr/local/sbin/rabbitmqadmin --node {{ name }} --port={{ node.nodeport + 10000 }} declare queue --vhost={{ q.vhost }} --username={{ q.user }} --password={{ q.passwd }} name={{ queue }} durable={{ q.durable|to_bool|lower }} auto_delete={{ q.auto_delete|to_bool|lower }} arguments='{{ "{}" if "arguments" not in q else q.arguments|json }}' # noqa 204 23 | - onlyif: test -x /usr/local/sbin/rabbitmqadmin 24 | - runas: rabbitmq 25 | - require: 26 | - sls: {{ sls_config_plugins }} 27 | - sls: {{ sls_config_users }} 28 | - sls: {{ sls_config_vhosts }} 29 | - unless: /usr/sbin/rabbitmqctl --node {{ name }} --vhost={{ q.vhost }} list_queues | grep ^{{ queue }}\s* 30 | 31 | {%- endfor %} 32 | {%- endif %} 33 | {%- endfor %} 34 | -------------------------------------------------------------------------------- /rabbitmq/config/users/clean.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | --- 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import mapdata as r with context %} 6 | {%- set sls_service_clean = tplroot ~ '.service.clean' %} 7 | 8 | include: 9 | - {{ sls_service_clean }} 10 | 11 | {%- if grains.os_family == 'RedHat' and 'locale_all' in r.environ %} 12 | 13 | rabbitmq-config-users-environ-locale: 14 | environ.setenv: 15 | - name: LC_ALL 16 | - value: {{ 'en_US.UTF-8' if 'locale_all' not in r.environ else r.environ.locale_all }} 17 | - update_minion: True 18 | 19 | {%- endif %} 20 | {%- for name, node in r.nodes.items() %} 21 | {%- if 'users' in node and node.users is mapping %} 22 | {%- for user, items in node.users.items() %} 23 | 24 | rabbitmq-config-users-delete-{{ name }}-{{ user }}: 25 | cmd.run: 26 | - name: /usr/sbin/rabbitmqctl --node {{ name }} delete_user {{ user }} ||true 27 | - onlyif: 28 | - test -x /usr/sbin/rabbitmqctl 29 | - test -d {{ r.dir.data }} 30 | - runas: rabbitmq 31 | - require_in: 32 | - sls: {{ sls_service_clean }} 33 | 34 | {%- endfor %} 35 | {%- endif %} 36 | {%- endfor %} 37 | -------------------------------------------------------------------------------- /rabbitmq/config/users/init.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | include: 5 | - .install 6 | -------------------------------------------------------------------------------- /rabbitmq/config/users/install.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | --- 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %} 6 | {%- set sls_service_running = tplroot ~ '.service.running' %} 7 | {%- set sls_vhosts_install = tplroot ~ '.config.vhosts.install' %} 8 | {%- set cmd = '/usr/sbin/rabbitmqctl' %} 9 | 10 | include: 11 | - {{ sls_service_running }} 12 | - {{ sls_vhosts_install }} 13 | 14 | {%- for name, node in rabbitmq.nodes.items() %} 15 | {%- if 'users' in node and node.users is mapping %} 16 | {%- for user, u in node.users.items() %} 17 | 18 | rabbitmq-config-users-added-{{ name }}-{{ user }}: 19 | cmd.run: 20 | - names: 21 | - {{ cmd }} --node {{ name }} add_user {{ user }} {{ u.password }} ||true 22 | {%- if 'force' in u and u.force %} 23 | - {{ cmd }} --node {{ name }} change_password {{ user }} {{ u.password }} 24 | {%- endif %} 25 | {%- if 'tags' in u and u.tags %} 26 | - {{ cmd }} --node {{ name }} set_user_tags {{ user }} {{ u.tags|join(' ') }} # noqa 204 27 | {%- endif %} 28 | {%- if 'perms' in u and u.perms %} 29 | {%- for vhost, perms in u.perms.items() %} 30 | - {{ cmd }} --node {{ name }} set_permissions -p {{ vhost }} {{ user }} {{ perms|map("json")|join(" ") }} # noqa 204 31 | {%- endfor %} 32 | {%- endif %} 33 | - onlyif: test -x {{ cmd }} 34 | - runas: rabbitmq 35 | - require: 36 | - service: rabbitmq-service-running-service-running-{{ name }} 37 | - sls: {{ sls_vhosts_install }} 38 | 39 | {%- endfor %} 40 | {%- endif %} 41 | {% if 'remove_guest_user' not in node or node.remove_guest_user == True %} 42 | 43 | rabbitmq-config-users-guest-absent-{{ name }}: 44 | cmd.run: 45 | - name: {{ cmd }} --node {{ name }} delete_user guest || true 46 | 47 | {% endif %} 48 | {%- endfor %} 49 | -------------------------------------------------------------------------------- /rabbitmq/config/vhosts/clean.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | --- 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %} 6 | {%- set sls_config_users_clean = tplroot ~ '.config.users.clean' %} 7 | {%- set sls_config_plugins_clean = tplroot ~ '.config.plugins.clean' %} 8 | 9 | include: 10 | - {{ sls_config_plugins_clean }} 11 | - {{ sls_config_users_clean }} 12 | 13 | {%- for name, node in rabbitmq.nodes.items() %} 14 | {%- if 'vhosts' in node and node.vhosts is iterable and node.vhosts is not string %} 15 | {%- for vhost in node.vhosts %} 16 | 17 | rabbitmq-config-vhosts-delete-{{ name }}-{{ vhost }}: 18 | cmd.run: 19 | - name: /usr/sbin/rabbitmqctl --node {{ name }} delete_vhost {{ vhost }} || true 20 | - onlyif: 21 | - test -x /usr/sbin/rabbitmqctl 22 | - test -d {{ rabbitmq.dir.data }} 23 | - runas: rabbitmq 24 | - require_in: 25 | - sls: {{ sls_config_plugins_clean }} 26 | - sls: {{ sls_config_users_clean }} 27 | 28 | {%- endfor %} 29 | {%- endif %} 30 | {%- endfor %} 31 | -------------------------------------------------------------------------------- /rabbitmq/config/vhosts/init.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | include: 5 | - .install 6 | -------------------------------------------------------------------------------- /rabbitmq/config/vhosts/install.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | --- 4 | {%- set tplroot = tpldir.split('/')[0] %} 5 | {%- from tplroot ~ "/map.jinja" import mapdata as rabbitmq with context %} 6 | {%- set sls_config_plugins = tplroot ~ '.config.plugins.install' %} 7 | {%- set sls_config_users = tplroot ~ '.config.users.install' %} 8 | 9 | include: 10 | - {{ sls_config_plugins }} 11 | - {{ sls_config_users }} 12 | 13 | {%- for name, node in rabbitmq.nodes.items() %} 14 | {%- if 'vhosts' in node and node.vhosts is iterable and node.vhosts is not string %} 15 | {%- for vhost in node.vhosts %} 16 | 17 | rabbitmq-config-vhosts-add-{{ name }}-{{ vhost }}: 18 | cmd.run: 19 | - name: /usr/sbin/rabbitmqctl --node {{ name }} add_vhost {{ vhost }} 20 | - onlyif: test -x /usr/sbin/rabbitmqctl 21 | - runas: rabbitmq 22 | - require: 23 | - sls: {{ sls_config_plugins }} 24 | - require_in: 25 | - sls: {{ sls_config_users }} 26 | 27 | {%- endfor %} 28 | {%- endif %} 29 | {%- endfor %} 30 | -------------------------------------------------------------------------------- /rabbitmq/files/default/config.tmpl: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | # File managed by Salt at <{{ source }}>. 3 | # Your changes will be overwritten. 4 | ######################################################################## 5 | 6 | {%- if config is defined %} 7 | {% for key, value in config.items() %} 8 | {{ key }}={{ value }} 9 | {%- endfor %} 10 | {%- elif env is defined %} 11 | {% for key, value in env.items() %} 12 | {{ key | upper }}={{ value }} 13 | {%- endfor %} 14 | {%- endif %} 15 | -------------------------------------------------------------------------------- /rabbitmq/files/default/systemd.ini.jinja: -------------------------------------------------------------------------------- 1 | ######################################################### 2 | # File managed by Salt. Changes risk being overwritten. 3 | ######################################################### 4 | [Unit] 5 | Description=RabbitMQ broker {{ '' if name is not defined or name else name }} 6 | After=network.target epmd@0.0.0.0.socket 7 | Wants=network.target epmd@0.0.0.0.socket 8 | 9 | [Service] 10 | Type=notify 11 | User=rabbitmq 12 | Group=rabbitmq 13 | UMask=0027 14 | NotifyAccess=all 15 | TimeoutStartSec=600 16 | Environment="RABBITMQ_NODENAME={{ 'rabbit' if nodename is not defined else nodename }}" 17 | Environment="RABBITMQ_NODE_PORT={{ '5672' if nodeport is not defined else nodeport }}" 18 | Environment="RABBITMQ_SERVER_START_ARGS=-rabbitmq_management listener [{port,{{ nodeport + 10000 }}}]" 19 | Environment="RABBITMQ_DIST_PORT={{ '25672' if distport is not defined else distport }}" 20 | Environment="RABBITMQ_MNESIA_DIR={{ '/var/lib/rabbitmq/mnesia' if mnesia_dir is not defined else mnesia_dir }}" 21 | Environment="RABBITMQ_CONFIG_FILE={{ '/etc/rabbitmq/rabbitmq.conf' if cfgfile is not defined else cfgfile }}" 22 | 23 | # To override LimitNOFILE, create the following file: 24 | # 25 | # /etc/systemd/system/rabbitmq-server.service.d/limits.conf 26 | # 27 | # with the following content: 28 | # 29 | # [Service] 30 | # LimitNOFILE=65536 31 | 32 | LimitNOFILE=32768 33 | 34 | # Note: systemd on CentOS 7 complains about in-line comments, 35 | # so only append them here 36 | # 37 | # Restart: 38 | # The following setting will automatically restart RabbitMQ 39 | # in the event of a failure. systemd service restarts are not a 40 | # replacement for service monitoring. Please see 41 | # https://www.rabbitmq.com/monitoring.html 42 | Restart=on-failure 43 | RestartSec=10 44 | WorkingDirectory={{ '/var/lib/rabbitmq' if workdir is not defined else workdir }} 45 | ExecStart=/usr/sbin/rabbitmq-server 46 | ExecStop=/usr/sbin/rabbitmqctl shutdown 47 | # See rabbitmq/rabbitmq-server-release#51 48 | SuccessExitStatus=69 49 | 50 | [Install] 51 | WantedBy=multi-user.target 52 | -------------------------------------------------------------------------------- /rabbitmq/init.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | 4 | include: 5 | - .package 6 | - .config 7 | - .service 8 | -------------------------------------------------------------------------------- /rabbitmq/libmatchers.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 ~ "/libsaltcli.jinja" import cli with context %} 7 | 8 | {%- set query_map = { 9 | "C": "config.get", 10 | "G": "grains.get", 11 | "I": "pillar.get", 12 | } %} 13 | 14 | {#- When no part before `@` is provided: #} 15 | {#- - define a YAML file path, noted `Y` #} 16 | {#- - use `salt["config.get"]`, noted `C` #} 17 | {#- - use colon `:` delimiter for querying #} 18 | {%- set _defaults = { 19 | "type": "Y", 20 | "query_type": "C", 21 | "query_delimiter": ":" 22 | } %} 23 | 24 | {%- macro parse_matchers( 25 | matchers, 26 | config_get_strategy=None, 27 | log_prefix="libmatchers: " 28 | ) %} 29 | {#- matcher format is `[[: