├── .ansible-lint
├── .ansible-lint-ignore
├── .flake8
├── .github
├── release-drafter.yml
├── stale.yml
└── workflows
│ ├── default.yml
│ ├── release-drafter.yml
│ └── release-galaxy.yml
├── .gitignore
├── .gitlab-ci.yml
├── .pre-commit-config.yaml
├── .travis.yml
├── .yamllint
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── CONTRIBUTORS.md
├── LICENSE.md
├── README.md
├── defaults
└── main.yml
├── files
└── .gitkeep
├── handlers
└── main.yml
├── meta
└── main.yml
├── molecule
├── centos7
│ ├── INSTALL.rst
│ ├── molecule.yml
│ └── verify.yml
├── centos8
│ ├── INSTALL.rst
│ ├── molecule.yml
│ └── verify.yml
├── debian10
│ ├── INSTALL.rst
│ ├── molecule.yml
│ └── verify.yml
├── debian11
│ ├── INSTALL.rst
│ ├── molecule.yml
│ └── verify.yml
├── debian12
│ ├── INSTALL.rst
│ ├── molecule.yml
│ └── verify.yml
├── debian9
│ ├── INSTALL.rst
│ ├── molecule.yml
│ └── verify.yml
├── fedora
│ ├── INSTALL.rst
│ ├── molecule.yml
│ └── verify.yml
├── rocky8
│ ├── INSTALL.rst
│ ├── molecule.yml
│ └── verify.yml
├── rocky9
│ ├── INSTALL.rst
│ ├── molecule.yml
│ └── verify.yml
├── shared
│ ├── converge.yml
│ ├── prepare.yml
│ ├── side_effect.yml
│ └── verify.yml
├── ubuntu1604
│ ├── INSTALL.rst
│ ├── molecule.yml
│ └── verify.yml
├── ubuntu1804
│ ├── INSTALL.rst
│ ├── molecule.yml
│ └── verify.yml
├── ubuntu2004
│ ├── INSTALL.rst
│ ├── molecule.yml
│ └── verify.yml
└── ubuntu2204
│ ├── INSTALL.rst
│ ├── molecule.yml
│ └── verify.yml
├── playbook.yml
├── poetry.lock
├── pyproject.toml
├── requirements-dev.in
├── requirements-dev.txt
├── requirements.in
├── requirements.txt
├── requirements.yml
├── tasks
├── cacti.yml
├── checks.yml
├── configure_root_access.yml
├── debian.yml
├── galera_monitoring.yml
├── main.yml
├── manage_node_state.yml
├── mariadb_packages_install.yml
├── max-open-files.yml
├── mysql_databases.yml
├── mysql_users.yml
├── oom-score-adjust.yml
├── redhat.yml
├── setup_cluster.yml
├── system_performance_tuning.yml
├── timeout-start-sec.yml
└── unconfigure_cluster.yml
├── templates
├── .gitkeep
├── etc
│ ├── apt
│ │ └── preferences.d
│ │ │ └── mariadb.j2
│ ├── mariadb_overrides.cnf.j2
│ ├── my.cnf.d
│ │ ├── server.cnf.j2
│ │ └── server.cnf.temp.j2
│ ├── mysql
│ │ ├── conf.d
│ │ │ ├── client.cnf.j2
│ │ │ ├── galera.cnf.j2
│ │ │ └── galera.cnf.temp.j2
│ │ ├── debian.cnf.j2
│ │ ├── galeranotify.py2.j2
│ │ ├── galeranotify.py3.j2
│ │ └── my.cnf.j2
│ └── systemd
│ │ └── system
│ │ └── mariadb.service.d
│ │ ├── max-open-files.conf.j2
│ │ ├── oom-score-adjust.conf.j2
│ │ └── timeout-start-sec.conf.j2
└── root
│ └── my.cnf.j2
└── vars
├── almalinux-8.yml
├── almalinux-9.yml
├── centos-8.yml
├── centos-9.yml
├── debian-11.yml
├── debian-12.yml
├── debian.yml
├── fedora.yml
├── main.yml
├── redhat.yml
├── rocky-8.yml
├── rocky-9.yml
├── ubuntu-20.yml
├── ubuntu-22.yml
└── ubuntu-24.yml
/.ansible-lint:
--------------------------------------------------------------------------------
1 | skip_list:
2 | - fqcn[action-core]
3 | - fqcn[action]
4 | - jinja[spacing]
5 | - key-order[task]
6 | - name[casing]
7 | - name[missing]
8 | - name[play]
9 | - name[template]
10 | - schema[meta]
11 | - schema[tasks]
12 |
--------------------------------------------------------------------------------
/.ansible-lint-ignore:
--------------------------------------------------------------------------------
1 | # This file contains ignores rule violations for ansible-lint
2 | tasks/configure_root_access.yml ignore-errors
3 | tasks/setup_cluster.yml no-changed-when
4 |
--------------------------------------------------------------------------------
/.flake8:
--------------------------------------------------------------------------------
1 | [flake8]
2 | exclude = .venv/
3 |
--------------------------------------------------------------------------------
/.github/release-drafter.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name-template: "v$RESOLVED_VERSION 🌈"
3 | tag-template: "v$RESOLVED_VERSION"
4 | categories:
5 | - title: "🚀 Features"
6 | labels:
7 | - "feature"
8 | - "enhancement"
9 | - title: "🐛 Bug Fixes"
10 | labels:
11 | - "fix"
12 | - "bugfix"
13 | - "bug"
14 | - title: "🧰 Maintenance"
15 | label: "chore"
16 | - title: "🧺 Miscellaneous" #Everything except ABAP
17 | label: "misc"
18 | change-template: "- $TITLE @$AUTHOR (#$NUMBER)"
19 | change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
20 | version-resolver:
21 | major:
22 | labels:
23 | - "major"
24 | minor:
25 | labels:
26 | - "minor"
27 | patch:
28 | labels:
29 | - "patch"
30 | default: patch
31 | template: |
32 | ## Changes
33 | $CHANGES
34 |
--------------------------------------------------------------------------------
/.github/stale.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Number of days of inactivity before an issue becomes stale
3 | daysUntilStale: 60
4 | # Number of days of inactivity before a stale issue is closed
5 | daysUntilClose: 7
6 | # Issues with these labels will never be considered stale
7 | exemptLabels:
8 | - pinned
9 | - security
10 | # Label to use when marking an issue as stale
11 | staleLabel: wontfix
12 | # Comment to post when marking an issue as stale. Set to `false` to disable
13 | markComment: >
14 | This issue has been automatically marked as stale because it has not had
15 | recent activity. It will be closed if no further activity occurs. Thank you
16 | for your contributions.
17 | # Comment to post when closing a stale issue. Set to `false` to disable
18 | closeComment: false
19 |
--------------------------------------------------------------------------------
/.github/workflows/default.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: Verification
3 | on:
4 | push:
5 | branches-ignore:
6 | - main
7 | - master
8 | pull_request:
9 | branches:
10 | - develop
11 | - main
12 | - master
13 | jobs:
14 | pre-commit:
15 | name: pre-commit Lint
16 | runs-on: ubuntu-latest
17 | steps:
18 | - uses: actions/checkout@v4
19 | with:
20 | submodules: recursive
21 | - name: Set up Python 3.10
22 | uses: actions/setup-python@v4
23 | with:
24 | python-version: "3.10"
25 | - uses: actions/cache@v4
26 | with:
27 | path: ~/.cache/pip
28 | key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
29 | restore-keys: |
30 | ${{ runner.os }}-pip-
31 | - name: Install dependencies
32 | run: |
33 | python -m pip install --upgrade pip
34 | pip install -r requirements.txt
35 | pip install pre-commit
36 | - name: Run pre-commit checks
37 | uses: pre-commit/action@v3.0.0
38 | molecule:
39 | name: Molecule Test
40 | runs-on: ubuntu-latest
41 | strategy:
42 | fail-fast: false
43 | max-parallel: 4
44 | matrix:
45 | molecule_distro:
46 | # - alpine313
47 | # - alpine314
48 | # - centos7
49 | # - centos8
50 | # - debian8
51 | - debian10
52 | - debian11
53 | - debian12
54 | # - fedora
55 | # - fedora34
56 | # - fedora35
57 | - rocky8
58 | - rocky9
59 | # - ubuntu1604
60 | - ubuntu1804
61 | - ubuntu2004
62 | - ubuntu2204
63 | python-version: ["3.10"]
64 |
65 | steps:
66 | - uses: actions/checkout@v3
67 | with:
68 | submodules: recursive
69 | - name: Set up Python ${{ matrix.python-version }}
70 | uses: actions/setup-python@v4
71 | with:
72 | python-version: ${{ matrix.python-version }}
73 | - uses: actions/cache@v4
74 | with:
75 | path: ~/.cache/pip
76 | key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
77 | restore-keys: |
78 | ${{ runner.os }}-pip-
79 | - name: Install dependencies
80 | run: |
81 | python -m pip install --upgrade pip
82 | pip install -r requirements.txt -r requirements-dev.txt
83 | pip install pre-commit
84 | - name: Test with molecule
85 | run: |
86 | molecule test --scenario-name ${{ matrix.molecule_distro }}
87 |
--------------------------------------------------------------------------------
/.github/workflows/release-drafter.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: Release Drafter
3 |
4 | on:
5 | push:
6 | # branches to consider in the event; optional, defaults to all
7 | branches:
8 | - main
9 | - master
10 |
11 | jobs:
12 | update_release_draft:
13 | runs-on: ubuntu-latest
14 | steps:
15 | # Drafts your next Release notes as Pull Requests are merged into "master"
16 | - uses: release-drafter/release-drafter@v5
17 | env:
18 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19 |
--------------------------------------------------------------------------------
/.github/workflows/release-galaxy.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: Ansible Galaxy
3 |
4 | on:
5 | push:
6 | branches:
7 | - main
8 | - master
9 | release:
10 | types:
11 | - published
12 |
13 | jobs:
14 | galaxy:
15 | runs-on: ubuntu-latest
16 | steps:
17 | - uses: actions/checkout@v4
18 | with:
19 | submodules: recursive
20 |
21 | - name: Set up Python
22 | uses: actions/setup-python@v4
23 | with:
24 | python-version: '3.11'
25 |
26 | - uses: actions/cache@v4
27 | with:
28 | path: ~/.cache/pip
29 | key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
30 | restore-keys: |
31 | ${{ runner.os }}-pip-
32 |
33 | - name: Install dependencies
34 | run: |
35 | python -m pip install --upgrade pip
36 | pip install -r requirements.txt -r requirements-dev.txt
37 | pip install pre-commit
38 |
39 | - name: Trigger a new import on Galaxy.
40 | run: ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }} $(echo ${{ github.repository }} | cut -d/ -f1) $(echo ${{ github.repository }} | cut -d/ -f2)
41 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .venv/
2 | .idea/
3 | .vscode/
4 | venv/
5 |
--------------------------------------------------------------------------------
/.gitlab-ci.yml:
--------------------------------------------------------------------------------
1 | ---
2 | image: docker:git
3 |
4 | services:
5 | - docker:dind
6 |
7 | stages:
8 | - molecule-test
9 |
10 | before_script:
11 | - apk update && apk add --no-cache docker
12 | python3-dev py3-pip docker gcc git curl build-base
13 | autoconf automake py3-cryptography linux-headers
14 | musl-dev libffi-dev openssl-dev openssh
15 | - docker info
16 | - python3 --version
17 | - python3 -m venv venv
18 | - source venv/bin/activate
19 | - pip3 install --upgrade pip pip-tools
20 | - pip-sync requirements.txt requirements-dev.txt
21 | - ansible --version
22 | - molecule --version
23 |
24 | centos7:
25 | stage: molecule-test
26 | script:
27 | - molecule test --scenario-name centos7
28 |
29 | centos8:
30 | stage: molecule-test
31 | script:
32 | - molecule test --scenario-name centos8
33 |
34 | rocky8:
35 | stage: molecule-test
36 | script:
37 | - molecule test --scenario-name rocky8
38 |
39 | rocky9:
40 | stage: molecule-test
41 | script:
42 | - molecule test --scenario-name rocky9
43 |
44 | debian9:
45 | stage: molecule-test
46 | script:
47 | - molecule test --scenario-name debian9
48 |
49 | debian10:
50 | stage: molecule-test
51 | script:
52 | - molecule test --scenario-name debian10
53 |
54 | debian11:
55 | stage: molecule-test
56 | script:
57 | - molecule test --scenario-name debian11
58 |
59 | #fedora:
60 | # stage: molecule-test
61 | # script:
62 | # - molecule test --scenario-name fedora
63 |
64 | ubuntu1604:
65 | stage: molecule-test
66 | script:
67 | - molecule test --scenario-name ubuntu1604
68 |
69 | ubuntu1804:
70 | stage: molecule-test
71 | script:
72 | - molecule test --scenario-name ubuntu1804
73 |
74 | ubuntu2004:
75 | stage: molecule-test
76 | script:
77 | - molecule test --scenario-name ubuntu2004
78 |
79 | ubuntu2204:
80 | stage: molecule-test
81 | script:
82 | - molecule test --scenario-name ubuntu2204
83 |
--------------------------------------------------------------------------------
/.pre-commit-config.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | # See https://pre-commit.com for more information
3 | # See https://pre-commit.com/hooks.html for more hooks
4 | repos:
5 | - repo: https://github.com/pre-commit/pre-commit-hooks
6 | rev: v4.4.0
7 | hooks:
8 | - id: check-added-large-files
9 | - id: check-executables-have-shebangs
10 | - id: check-merge-conflict
11 | - id: check-symlinks
12 | - id: detect-private-key
13 | - id: end-of-file-fixer
14 | - id: no-commit-to-branch
15 | args: [--branch, develop, --branch, master, --branch, main]
16 | - id: trailing-whitespace
17 | - repo: https://github.com/ansible-community/ansible-lint
18 | rev: v6.17.2
19 | hooks:
20 | - id: ansible-lint
21 | - repo: https://github.com/psf/black
22 | rev: 23.7.0
23 | hooks:
24 | - id: black
25 | language_version: python3
26 | - repo: https://github.com/PyCQA/flake8
27 | rev: 6.0.0
28 | hooks:
29 | - id: flake8
30 | - repo: https://github.com/adrienverge/yamllint
31 | rev: v1.32.0
32 | hooks:
33 | - id: yamllint
34 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | sudo: required
3 | language: python
4 | services:
5 | - docker
6 | before_install:
7 | - sudo apt-get -qq update
8 | env:
9 | - molecule_distro=centos7
10 | - molecule_distro=centos8
11 | - molecule_distro=rocky8
12 | - molecule_distro=debian9
13 | - molecule_distro=debian10
14 | - molecule_distro=debian11
15 | # - molecule_distro=fedora
16 | - molecule_distro=ubuntu1604
17 | - molecule_distro=ubuntu1804
18 | - molecule_distro=ubuntu2004
19 | - molecule_distro=ubuntu2204
20 | install:
21 | - pip3 install --upgrade pip pip-tools
22 | - pip-sync requirements.txt requirements-dev.txt
23 | - ansible --version
24 | - molecule --version
25 | script:
26 | - molecule test --scenario-name "$molecule_distro"
27 | notifications:
28 | webhooks: https://galaxy.ansible.com/api/v1/notifications/
29 |
--------------------------------------------------------------------------------
/.yamllint:
--------------------------------------------------------------------------------
1 | ---
2 | # Based on ansible-lint config
3 | extends: default
4 |
5 | ignore: |
6 | .venv/
7 | .cache/
8 |
9 | rules:
10 | braces:
11 | max-spaces-inside: 1
12 | level: error
13 | brackets:
14 | max-spaces-inside: 1
15 | level: error
16 | colons:
17 | max-spaces-after: -1
18 | level: error
19 | commas:
20 | max-spaces-after: -1
21 | level: error
22 | comments: disable
23 | comments-indentation: disable
24 | document-start: disable
25 | empty-lines:
26 | max: 3
27 | level: error
28 | hyphens:
29 | level: error
30 | indentation: disable
31 | key-duplicates: enable
32 | line-length: disable
33 | new-line-at-end-of-file: disable
34 | new-lines:
35 | type: unix
36 | trailing-spaces: disable
37 | truthy: disable
38 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrlesmithjr/ansible-mariadb-galera-cluster/128a25b5e74c3544cfb0b922ccb7b7b29c7e0470/CHANGELOG.md
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | - Using welcoming and inclusive language
18 | - Being respectful of differing viewpoints and experiences
19 | - Gracefully accepting constructive criticism
20 | - Focusing on what is best for the community
21 | - Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | - The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | - Trolling, insulting/derogatory comments, and personal or political attacks
28 | - Public or private harassment
29 | - Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | - Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at me@example.com. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to ansible-mariadb-galera-cluster
2 |
3 | ## Table Of Contents
4 |
5 | [Code of Conduct](#code-of-conduct)
6 | [Environment Setup](#environment-setup)
7 | [Running Tests](#running-tests)
8 |
9 | ## Code of Conduct
10 |
11 | This project and everyone participating in it is governed by the [ansible-mariadb-galera-cluster Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [me@example.com](mailto:me@example.com).
12 |
13 | ## Environment Setup
14 | ```
15 | python3.10 -m venv .venv
16 | source .venv/bin/activate
17 |
18 | # Install Requirements
19 | pip install -r requirements.txt -r requirements-dev.txt
20 | pip install pre-commit
21 |
22 | # One-Time Install of Commit Hooks
23 | pre-commit install
24 | ```
25 |
26 | ## Running Tests
27 | This project uses [Molecule](https://molecule.readthedocs.io/en/latest/index.html) to run tests:
28 | ```
29 | molecule test --scenario-name $SCENARIO
30 | ```
31 |
32 | For a list of valid scenario names, see the folders listed under `molecule`. To see the scenario names run as part of continuous integration testing, see `.github/workflows/default.yml`.
33 |
--------------------------------------------------------------------------------
/CONTRIBUTORS.md:
--------------------------------------------------------------------------------
1 | Larry Smith Jr. - mrlesmithjr@gmail.com
2 | Roman Danko - mail@romandanko.sk
3 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Larry Smith Jr.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | **Table of Contents** _generated with [DocToc](https://github.com/thlorenz/doctoc)_
6 |
7 | - [ansible-mariadb-galera-cluster](#ansible-mariadb-galera-cluster)
8 | - [Build Status](#build-status)
9 | - [Requirements](#requirements)
10 | - [Role Variables](#role-variables)
11 | - [Dependencies](#dependencies)
12 | - [Example Playbook](#example-playbook)
13 | - [License](#license)
14 | - [Author Information](#author-information)
15 |
16 |
17 |
18 | # ansible-mariadb-galera-cluster
19 |
20 | An [Ansible](https://www.ansible.com) role to install/configure a [MariaDB-Galera Cluster](https://mariadb.com/kb/en/mariadb/what-is-mariadb-galera-cluster/)
21 |
22 | ## Requirements
23 |
24 | - Collections:
25 | - community.mysql
26 |
27 | ## Role Variables
28 |
29 | [defaults/main.yml](defaults/main.yml)
30 |
31 | ## Dependencies
32 |
33 | None
34 |
35 | ## Example Playbook
36 |
37 | [Example playbook](./playbook.yml)
38 |
39 | ## License
40 |
41 | MIT
42 |
43 | ## Author Information
44 |
45 | Larry Smith Jr.
46 |
47 | - [@mrlesmithjr](https://twitter.com/mrlesmithjr)
48 | - [mrlesmithjr@gmail.com](mailto:mrlesmithjr@gmail.com)
49 | - [http://everythingshouldbevirtual.com](http://everythingshouldbevirtual.com)
50 |
51 |
52 |
--------------------------------------------------------------------------------
/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for ansible-mariadb-galera-cluster
3 |
4 | # MariaDB setting
5 |
6 | # Define mariadb version
7 | mariadb_version: "10.11"
8 |
9 | # Defines if we should enable the MariaDB repo or use version within OS repos.
10 | galera_enable_mariadb_repo: true
11 |
12 | # Defines repository settings for apt
13 | mariadb_debian_repo: "deb [arch=amd64,arm64,ppc64el] http://nyc2.mirrors.digitalocean.com/mariadb/repo/{{ mariadb_version }}/{{ ansible_distribution|lower }} {{ ansible_distribution_release|lower }} main"
14 | mariadb_debian_repo_keyserver: "keyserver.ubuntu.com"
15 | mariadb_debian_repo_pin: "nyc2.mirrors.digitalocean.com"
16 | mariadb_debian_repo_pin_priority: 600
17 |
18 | # Defines repository settings for rpm
19 | mariadb_redhat_repo: "https://yum.mariadb.org/{{ mariadb_version }}/{{ ansible_distribution|lower }}{{ ansible_distribution_major_version }}-amd64"
20 | mariadb_redhat_repo_key: "https://yum.mariadb.org/RPM-GPG-KEY-MariaDB"
21 |
22 | # bind address for MariaDB's 3306 port.
23 | # By default takes the value of the galera cluster IP, but can be overriden
24 | # to 0.0.0.0 (for example) to allow MySQL connections to localhost
25 | mariadb_bind_address: "{{ galera_cluster_bind_address }}"
26 |
27 | # Defines if root logins should be allowed from any host
28 | galera_allow_root_from_any: false
29 |
30 | # Define listen port
31 | mariadb_mysql_port: 3306
32 |
33 | # Define mysql root password
34 | # generate using echo password | mkpasswd -s -m sha-512
35 | mariadb_mysql_root_password: "root"
36 |
37 | # Define mysql mem multiplier (used to calculate key_buffer_size)
38 | mariadb_mysql_mem_multiplier: .25
39 |
40 | mariadb_mysql_settings:
41 | datadir: "/var/lib/mysql"
42 | #Default is 16M
43 | key_buffer_size: "{{ (ansible_memtotal_mb | int * mariadb_mysql_mem_multiplier) | round | int }}M"
44 | log_error: /var/log/mysql/error.log
45 | max_allowed_packet: "16M"
46 | max_binlog_size: "100M"
47 | query_cache_limit: "1M"
48 | query_cache_size: "16M"
49 | # MariaDB default: https://mariadb.com/kb/en/server-system-variables/#thread_cache_size
50 | thread_cache_size: 256
51 |
52 | # Define TLS certs & keys which will be used to encrypt mysql, WSREP, SST connections
53 | # This variable should have defined exactly three items, any other item count is handled like none.
54 | # Items must be named ca_cert, server_key, server_cert. Each item must have defined values name and content.
55 | # Names will be used to create such file at target system. Content can be defined inline like example below,
56 | # or can by linked to variables defined in ansible-vault or other lookup plugins (file, hashicorp vault, etc.)
57 | #
58 | # mariadb_tls_files:
59 | # ca_cert:
60 | # name: "ca.pem"
61 | # content: |
62 | # -- ca-cert content --
63 | # server_key:
64 | # name: "server-key.pem"
65 | # content: |
66 | # -- server-cert content --
67 | # server_cert:
68 | # name: "server-cert.pem"
69 | # content: |
70 | # -- server-cert content --
71 | mariadb_tls_files: []
72 |
73 | # Recommended utf8 settings:
74 | # https://mariadb.com/kb/en/setting-character-sets-and-collations/#example-changing-the-default-character-set-to-utf-8
75 | # mariadb_charset_server: utf8mb4
76 | # mariadb_collation_server: utf8mb4_general_ci
77 | # mariadb_charset_client: utf8mb4
78 |
79 | # Role default: unset (server defaults: latin1)
80 | mariadb_charset_server: "auto"
81 | mariadb_collation_server: "auto"
82 | # Role default: utf8
83 | mariadb_charset_client: "utf8"
84 |
85 | # If this is defined it will create a file with overrides
86 | # mariadb_config_overrides:
87 | # mariadb:
88 | # max_connections: 2048
89 |
90 | # Defines if mariadb is already available on the target hosts
91 | # It will compare version between ansible and system and exit early if missmatch
92 | # This prevent unexpected change on role upgrade
93 | mariadb_upgrade: false
94 |
95 | # Galera settings
96 |
97 | # Defines if the galera cluster should be reconfigured
98 | # it will initiate cluster shutdown and bootstrap
99 | # common mariadb setting doesn't require this option
100 | galera_reconfigure_galera: false
101 |
102 | # Define interface in which to bind
103 | # ex. eth0|eth1|enp0s3|enp0s8
104 | galera_cluster_bind_interface: "eth0"
105 |
106 | # Define bind address for galera cluster
107 | galera_cluster_bind_address: "{{ hostvars[inventory_hostname]['ansible_' + galera_cluster_bind_interface]['ipv4']['address'] }}"
108 |
109 | # Defines wsrep node address
110 | galera_wsrep_node_address: "{{ galera_cluster_bind_address }}:{{ galera_wsrep_node_address_port }}"
111 |
112 | # Defines wsrep node port
113 | galera_wsrep_node_address_port: 4567
114 |
115 | # Define the number of wsrep_slave_threads:
116 | # - if `auto` we will use "number of vCPUs - 1"
117 | # - else the value define here is used
118 | galera_wsrep_slave_threads: 1
119 |
120 | # Define the name of the cluster
121 | galera_cluster_name: "vagrant-test"
122 |
123 | # Define Ansible group in which the nodes exist to be part of the cluster
124 | galera_cluster_nodes_group: "galera-cluster-nodes"
125 |
126 | # https://mariadb.com/kb/en/mariadb/wsrep_provider_options/
127 | galera_extra_wsrep_provider_options: {}
128 | # evs.auto_evict: 1
129 | # evs.delayed_margin: 'PT5S'
130 | # evs.delayed_keep_period: 'PT45S'
131 |
132 | # Define which network segment this node is in.
133 | # value is an integer from 0 to 255
134 | # By default all nodes are placed in the same segment (0)
135 | # http://galeracluster.com/documentation-webpages/galeraparameters.html#gmcast-segment
136 | #
137 | # Set to true to add `gmcast.segment` in each node,
138 | # On each node you must define `galera_gmcast_segment` variable
139 | galera_use_gmcast_segment: false
140 |
141 | # Address to listen on for Incremental State Transfer.
142 | # By default this is the
: from wsrep_node_address.
143 | galera_ist_recv_addr: "{{ galera_cluster_bind_address }}"
144 | galera_ist_recv_addr_port: "{{ galera_wsrep_node_address_port|int + 1 }}"
145 |
146 | # This option defines the address to which the node will bind in order to
147 | # receive Incremental State Transfers. When this option is not set, it takes
148 | # its value from ist.recv_addr or, in the event that that is also not set,
149 | # from wsrep_node_address. You may find it useful when the node runs behind a
150 | # NAT or in similar cases where the public and private addresses differ.
151 | galera_ist_recv_bind: "{{ galera_cluster_bind_address }}"
152 |
153 | # This option enables configuration TLS encryption for WSREP (disabled by default).
154 | # To enable encryption mariadb_tls_files must be configured also.
155 | galera_wsrep_tls_enabled: false
156 |
157 | # This option enables configuration TLS encryption for SST (disabled by default).
158 | # To enable encryption mariadb_tls_files must be configured also.
159 | galera_sst_tls_enabled: false
160 |
161 | # If you enable galera_sst_tls_enabled mariabackup need to authenticate locally on donor node.
162 | # Credentials bellow are appended to other user defined mariadb_mysql_users.
163 | # By default unix_socket auth plugin is used, for more info see documentaion
164 | # https://mariadb.com/kb/en/mariabackup-sst-method/#passwordless-authentication-unix-socket.
165 | # In MariaDB 10.4.3 and later unix_socket is instaleld by default, for later version see
166 | # https://mariadb.com/kb/en/authentication-plugin-unix-socket.
167 | # If you need to use password auth change set mariadb_sst_user.plugin to mysql_native_password
168 | # and set mariadb_sst_password.
169 | mariadb_sst_user_plugin: "unix_socket"
170 | mariadb_sst_username: "mysql"
171 | mariadb_sst_password: ""
172 |
173 | # This option defines the wsrep_sst_method that should be used by the cluster.
174 | # Possible options:
175 | # - mariabackup - recommended for MariaDB - default if TLS is enabled via galera_sst_tls_enabled,
176 | # - xtrabackup-v2 - not recommended, not implemented by this role, see limitations at https://mariadb.com/kb/en/xtrabackup-v2-sst-method/
177 | # - rsync - default
178 | galera_sst_method: "{{ (mariadb_tls_files and mariadb_tls_files|length == 3 and galera_sst_tls_enabled) | ternary('mariabackup', 'rsync') }}"
179 |
180 | # MariaDB system tunning
181 |
182 | # Tune system swappiness. Default value "auto" means don't tune.
183 | # Recommended value based on:
184 | # https://mariadb.com/kb/en/mariadb-memory-allocation/#swappiness
185 | # mariadb_swappiness: 1
186 | mariadb_swappiness: "auto"
187 |
188 | # Add the posibility to adjust the OOM score (only works for SystemD)
189 | mariadb_oom_score_adjust: 0
190 |
191 | # Add the posibility to adjust the LimitNOFILE (only works for SystemD)
192 | # default: 0 does not tamper LimitNOFILE
193 | # notice for SystemD: 0 does not mean 'unlimited', use 'infinity' for unlimited
194 | mariadb_max_open_files: 0
195 |
196 | # Add the posibility to adjust timeout for starting service (only works for SystemD)
197 | mariadb_timeout_start_sec: 0
198 |
199 | # InnoDB tuning
200 |
201 | # Amount of memory to use for InnoDB row cache.
202 | # Set to a specific amount in bytes or to "auto" for server defaults.
203 | mariadb_innodb_buffer_pool_size: "auto"
204 |
205 | # Automatic pool size tuning example:
206 |
207 | # What percentage of system memory to use for InnoDB row cache
208 | # 0.5 means 50%
209 | mariadb_innodb_mem_multiplier: 0.5
210 |
211 | # Calculate the amount of memory based on the above percentage, in bytes
212 | # mariadb_innodb_buffer_pool_size: >-
213 | # {{ (ansible_memtotal_mb|int * mariadb_innodb_mem_multiplier * 1024 * 1024)
214 | # | round | int }}
215 |
216 | # Maximum allowed concurrent connections. MySQL default is 151
217 | mariadb_max_connections: "auto"
218 |
219 | # The length of time in seconds an InnoDB transaction waits for a row lock before giving up.
220 | mariadb_innodb_lock_wait_timeout: "50"
221 |
222 | # Queries that take more time than 'mariadb_long_query_time' to complete are
223 | # considered as slow. Values in seconds or 'auto' for the MySQL default (10)
224 | # phpmyadmin recommends this value to be set to "5" or less.
225 | mariadb_long_query_time: "auto"
226 |
227 | # Enable logging of slow queries
228 | mariadb_slow_query_log_enabled: false
229 |
230 | # MariaDB default: 4
231 | # https://mariadb.com/kb/en/innodb-system-variables/#innodb_read_io_threads
232 | mariadb_innodb_read_io_threads: "auto"
233 |
234 | # MariaDB default: 4
235 | # https://mariadb.com/kb/en/innodb-system-variables/#innodb_write_io_threads
236 | mariadb_innodb_write_io_threads: "auto"
237 |
238 | # Automatic I/O thread tuning for systems with more than 8 CPU cores
239 |
240 | # The calculation below only counts real CPU cores, not SMT ones which MariaDB
241 | # rightfully does not like.
242 | mariadb_real_cpus: "{{ ansible_processor_count * ansible_processor_cores }}"
243 |
244 | # mariadb_innodb_read_io_threads: >-
245 | # {% if mariadb_real_cpus|int > 8
246 | # %}{{ mariadb_real_cpus|int / 2 | abs | int }}{%
247 | # else %}4{% endif %}
248 |
249 | # mariadb_innodb_write_io_threads: >-
250 | # {% if mariadb_real_cpus|int > 8
251 | # %}{{ mariadb_real_cpus|int / 2 | abs | int }}{%
252 | # else %}4{% endif %}
253 |
254 | # Define databases & users to be created
255 |
256 | # Create these MariaDB databases during installation
257 | # Example:
258 | # mariadb_databases:
259 | # - name: keystone
260 | # - name: mydb
261 | # init_script: files/init_mydb.sql
262 | mariadb_databases: []
263 |
264 | # Define additional MySQL users
265 | mariadb_mysql_users: []
266 | # - name: example
267 | # hosts:
268 | # - "%"
269 | # - "127.0.0.1"
270 | # - "::1"
271 | # - "localhost"
272 | # password: secret
273 | # encrypted: no (default)
274 | # priv: *.*:USAGE (default}
275 | # state: present (default)
276 | # append_privs: no (default)
277 |
278 | # Monitoring settings
279 |
280 | # Defines if galera monitoring script should be installes
281 | galera_enable_galera_monitoring_script: false
282 |
283 | # Define galera monitoring script path & name
284 | galera_monitor_script_name: "galeranotify.py{{ ansible_python.version.major|int }}"
285 | galera_monitor_script_path: "/etc/mysql"
286 |
287 | # Defines the which node should be considered the first in the cluster
288 | # Used to bootstrap cluster
289 | galera_mysql_first_node: "{{ groups[galera_cluster_nodes_group][0] }}"
290 |
291 | # Define the primary domain name of your environment
292 | mariadb_pri_domain_name: "example.org"
293 |
294 | # Define smtp domain for email
295 | mariadb_smtp_domain_name: "{{ mariadb_pri_domain_name }}"
296 |
297 | # Define smtp server to send email through
298 | mariadb_smtp_server: "smtp.{{ mariadb_pri_domain_name }}"
299 |
300 | # Defines email address to receive notifications
301 | galera_email_notifications: "notifications@{{ mariadb_smtp_domain_name }}"
302 |
303 | # Define email address that cluster notifications will be sent from
304 | galera_notify_mail_from: "galeranotify@{{ mariadb_smtp_domain_name }}"
305 |
306 | # Define email address that cluster notification will be sent to
307 | galera_notify_mail_to: "{{ galera_email_notifications }}"
308 |
309 | # Define smtp server to send notifications through
310 | galera_notify_smtp_server: "{{ mariadb_smtp_server }}"
311 | galera_notify_smtp_auth: "False"
312 | galera_notify_smtp_username: ""
313 | galera_notify_smtp_password: ""
314 | galera_notify_smtp_port: 25
315 | # Set to True if you need SMTP over SSL
316 | galera_notify_smtp_ssl: False
317 | # Set to True if you need SMTP over STARTTLS
318 | galera_notify_smtp_starttls: False
319 |
320 | # Defines if cacti monitoring should be enabled for mysql - If used. May remove later.
321 | galera_enable_cacti_monitoring: false
322 |
323 | # Define the cacti user info for cacti db monitoring - If used. May remove later.
324 | cacti_db_password: "cactiuser"
325 | cacti_db_user: "cactiuser"
326 |
327 | # Whether to output user data when managing users.
328 | galera_users_no_log: true
329 |
--------------------------------------------------------------------------------
/files/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrlesmithjr/ansible-mariadb-galera-cluster/128a25b5e74c3544cfb0b922ccb7b7b29c7e0470/files/.gitkeep
--------------------------------------------------------------------------------
/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for ansible-mariadb-galera-cluster
3 | - name: "reload systemd daemon"
4 | ansible.builtin.systemd:
5 | daemon_reload: true
6 | become: true
7 |
--------------------------------------------------------------------------------
/meta/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | galaxy_info:
3 | author: Larry Smith Jr.
4 | description: An ansible role to install/configure a [MariaDB-Galera Cluster](https://mariadb.com/kb/en/mariadb/what-is-mariadb-galera-cluster/)
5 | role_name: mariadb_galera_cluster
6 | namespace: mrlesmithjr
7 |
8 | license: MIT
9 |
10 | min_ansible_version: 9.1
11 | platforms:
12 | - name: EL
13 | versions:
14 | - 7
15 | - 8
16 | - 9
17 | - name: Ubuntu
18 | versions:
19 | - xenial
20 | - bionic
21 | - focal
22 | - jammy
23 | - name: Debian
24 | versions:
25 | - stretch
26 | - buster
27 | - bullseye
28 | - name: Fedora
29 | versions:
30 | - 39
31 |
32 | galaxy_tags:
33 | - database
34 | - sql
35 | dependencies: []
36 |
--------------------------------------------------------------------------------
/molecule/centos7/INSTALL.rst:
--------------------------------------------------------------------------------
1 | *******
2 | Docker driver installation guide
3 | *******
4 |
5 | Requirements
6 | ============
7 |
8 | * Docker Engine
9 |
10 | Install
11 | =======
12 |
13 | Please refer to the `Virtual environment`_ documentation for installation best
14 | practices. If not using a virtual environment, please consider passing the
15 | widely recommended `'--user' flag`_ when invoking ``pip``.
16 |
17 | .. _Virtual environment: https://virtualenv.pypa.io/en/latest/
18 | .. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
19 |
20 | .. code-block:: bash
21 |
22 | $ pip install 'molecule[docker]'
23 |
--------------------------------------------------------------------------------
/molecule/centos7/molecule.yml:
--------------------------------------------------------------------------------
1 | ---
2 | dependency:
3 | name: galaxy
4 | enabled: false
5 | options:
6 | role-file: requirements.yml
7 | driver:
8 | name: docker
9 | lint: |
10 | yamllint .
11 | ansible-lint
12 | flake8
13 | platforms:
14 | - name: node1
15 | image: mrlesmithjr/centos:7
16 | privileged: true
17 | command: /usr/sbin/init
18 | volumes:
19 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
20 | cgroupns_mode: host
21 | groups:
22 | - galera-cluster-nodes
23 | - name: node2
24 | image: mrlesmithjr/centos:7
25 | privileged: true
26 | command: /usr/sbin/init
27 | volumes:
28 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
29 | cgroupns_mode: host
30 | groups:
31 | - galera-cluster-nodes
32 | provisioner:
33 | name: ansible
34 | playbooks:
35 | converge: ../shared/converge.yml
36 | prepare: ../shared/prepare.yml
37 | side_effect: ../shared/side_effect.yml
38 | verifier:
39 | name: ansible
40 |
--------------------------------------------------------------------------------
/molecule/centos7/verify.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # This is an example playbook to execute Ansible tests.
3 |
4 | - name: Verify
5 | hosts: all
6 | tasks:
7 | - name: Example assertion
8 | assert:
9 | that: true
10 |
--------------------------------------------------------------------------------
/molecule/centos8/INSTALL.rst:
--------------------------------------------------------------------------------
1 | *******
2 | Docker driver installation guide
3 | *******
4 |
5 | Requirements
6 | ============
7 |
8 | * Docker Engine
9 |
10 | Install
11 | =======
12 |
13 | Please refer to the `Virtual environment`_ documentation for installation best
14 | practices. If not using a virtual environment, please consider passing the
15 | widely recommended `'--user' flag`_ when invoking ``pip``.
16 |
17 | .. _Virtual environment: https://virtualenv.pypa.io/en/latest/
18 | .. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
19 |
20 | .. code-block:: bash
21 |
22 | $ pip install 'molecule[docker]'
23 |
--------------------------------------------------------------------------------
/molecule/centos8/molecule.yml:
--------------------------------------------------------------------------------
1 | ---
2 | dependency:
3 | name: galaxy
4 | enabled: false
5 | options:
6 | role-file: requirements.yml
7 | driver:
8 | name: docker
9 | lint: |
10 | yamllint .
11 | ansible-lint
12 | flake8
13 | platforms:
14 | - name: node1
15 | image: mrlesmithjr/centos:8
16 | privileged: true
17 | command: /usr/sbin/init
18 | volumes:
19 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
20 | cgroupns_mode: host
21 | groups:
22 | - galera-cluster-nodes
23 | - name: node2
24 | image: mrlesmithjr/centos:8
25 | privileged: true
26 | command: /usr/sbin/init
27 | volumes:
28 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
29 | cgroupns_mode: host
30 | groups:
31 | - galera-cluster-nodes
32 | provisioner:
33 | name: ansible
34 | playbooks:
35 | converge: ../shared/converge.yml
36 | prepare: ../shared/prepare.yml
37 | side_effect: ../shared/side_effect.yml
38 | verifier:
39 | name: ansible
40 |
--------------------------------------------------------------------------------
/molecule/centos8/verify.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # This is an example playbook to execute Ansible tests.
3 |
4 | - name: Verify
5 | hosts: all
6 | tasks:
7 | - name: Example assertion
8 | assert:
9 | that: true
10 |
--------------------------------------------------------------------------------
/molecule/debian10/INSTALL.rst:
--------------------------------------------------------------------------------
1 | *******
2 | Docker driver installation guide
3 | *******
4 |
5 | Requirements
6 | ============
7 |
8 | * Docker Engine
9 |
10 | Install
11 | =======
12 |
13 | Please refer to the `Virtual environment`_ documentation for installation best
14 | practices. If not using a virtual environment, please consider passing the
15 | widely recommended `'--user' flag`_ when invoking ``pip``.
16 |
17 | .. _Virtual environment: https://virtualenv.pypa.io/en/latest/
18 | .. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
19 |
20 | .. code-block:: bash
21 |
22 | $ pip install 'molecule[docker]'
23 |
--------------------------------------------------------------------------------
/molecule/debian10/molecule.yml:
--------------------------------------------------------------------------------
1 | ---
2 | dependency:
3 | name: galaxy
4 | enabled: false
5 | options:
6 | role-file: requirements.yml
7 | driver:
8 | name: docker
9 | lint: |
10 | yamllint .
11 | ansible-lint
12 | flake8
13 | platforms:
14 | - name: node1
15 | image: mrlesmithjr/debian:10
16 | privileged: true
17 | command: /lib/systemd/systemd
18 | volumes:
19 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
20 | cgroupns_mode: host
21 | groups:
22 | - galera-cluster-nodes
23 | - name: node2
24 | image: mrlesmithjr/debian:10
25 | privileged: true
26 | command: /lib/systemd/systemd
27 | volumes:
28 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
29 | cgroupns_mode: host
30 | groups:
31 | - galera-cluster-nodes
32 | provisioner:
33 | name: ansible
34 | playbooks:
35 | converge: ../shared/converge.yml
36 | prepare: ../shared/prepare.yml
37 | side_effect: ../shared/side_effect.yml
38 | verifier:
39 | name: ansible
40 |
--------------------------------------------------------------------------------
/molecule/debian10/verify.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # This is an example playbook to execute Ansible tests.
3 |
4 | - name: Verify
5 | hosts: all
6 | tasks:
7 | - name: Example assertion
8 | assert:
9 | that: true
10 |
--------------------------------------------------------------------------------
/molecule/debian11/INSTALL.rst:
--------------------------------------------------------------------------------
1 | *******
2 | Docker driver installation guide
3 | *******
4 |
5 | Requirements
6 | ============
7 |
8 | * Docker Engine
9 |
10 | Install
11 | =======
12 |
13 | Please refer to the `Virtual environment`_ documentation for installation best
14 | practices. If not using a virtual environment, please consider passing the
15 | widely recommended `'--user' flag`_ when invoking ``pip``.
16 |
17 | .. _Virtual environment: https://virtualenv.pypa.io/en/latest/
18 | .. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
19 |
20 | .. code-block:: bash
21 |
22 | $ pip install 'molecule[docker]'
23 |
--------------------------------------------------------------------------------
/molecule/debian11/molecule.yml:
--------------------------------------------------------------------------------
1 | ---
2 | dependency:
3 | name: galaxy
4 | enabled: false
5 | options:
6 | role-file: requirements.yml
7 | driver:
8 | name: docker
9 | lint: |
10 | yamllint .
11 | ansible-lint
12 | flake8
13 | platforms:
14 | - name: node1
15 | image: mrlesmithjr/debian:11
16 | privileged: true
17 | command: /lib/systemd/systemd
18 | volumes:
19 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
20 | cgroupns_mode: host
21 | groups:
22 | - galera-cluster-nodes
23 | - name: node2
24 | image: mrlesmithjr/debian:11
25 | privileged: true
26 | command: /lib/systemd/systemd
27 | volumes:
28 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
29 | cgroupns_mode: host
30 | groups:
31 | - galera-cluster-nodes
32 | provisioner:
33 | name: ansible
34 | playbooks:
35 | converge: ../shared/converge.yml
36 | prepare: ../shared/prepare.yml
37 | side_effect: ../shared/side_effect.yml
38 | verifier:
39 | name: ansible
40 |
--------------------------------------------------------------------------------
/molecule/debian11/verify.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # This is an example playbook to execute Ansible tests.
3 |
4 | - name: Verify
5 | hosts: all
6 | tasks:
7 | - name: Example assertion
8 | assert:
9 | that: true
10 |
--------------------------------------------------------------------------------
/molecule/debian12/INSTALL.rst:
--------------------------------------------------------------------------------
1 | *******
2 | Docker driver installation guide
3 | *******
4 |
5 | Requirements
6 | ============
7 |
8 | * Docker Engine
9 |
10 | Install
11 | =======
12 |
13 | Please refer to the `Virtual environment`_ documentation for installation best
14 | practices. If not using a virtual environment, please consider passing the
15 | widely recommended `'--user' flag`_ when invoking ``pip``.
16 |
17 | .. _Virtual environment: https://virtualenv.pypa.io/en/latest/
18 | .. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
19 |
20 | .. code-block:: bash
21 |
22 | $ pip install 'molecule[docker]'
23 |
--------------------------------------------------------------------------------
/molecule/debian12/molecule.yml:
--------------------------------------------------------------------------------
1 | ---
2 | dependency:
3 | name: galaxy
4 | enabled: false
5 | options:
6 | role-file: requirements.yml
7 | driver:
8 | name: docker
9 | lint: |
10 | yamllint .
11 | ansible-lint
12 | flake8
13 | platforms:
14 | - name: node1
15 | image: mrlesmithjr/debian:12
16 | privileged: true
17 | command: /lib/systemd/systemd
18 | volumes:
19 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
20 | cgroupns_mode: host
21 | groups:
22 | - galera-cluster-nodes
23 | - name: node2
24 | image: mrlesmithjr/debian:12
25 | privileged: true
26 | command: /lib/systemd/systemd
27 | volumes:
28 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
29 | cgroupns_mode: host
30 | groups:
31 | - galera-cluster-nodes
32 | provisioner:
33 | name: ansible
34 | playbooks:
35 | converge: ../shared/converge.yml
36 | prepare: ../shared/prepare.yml
37 | side_effect: ../shared/side_effect.yml
38 | verifier:
39 | name: ansible
40 |
--------------------------------------------------------------------------------
/molecule/debian12/verify.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # This is an example playbook to execute Ansible tests.
3 |
4 | - name: Verify
5 | hosts: all
6 | tasks:
7 | - name: Example assertion
8 | assert:
9 | that: true
10 |
--------------------------------------------------------------------------------
/molecule/debian9/INSTALL.rst:
--------------------------------------------------------------------------------
1 | *******
2 | Docker driver installation guide
3 | *******
4 |
5 | Requirements
6 | ============
7 |
8 | * Docker Engine
9 |
10 | Install
11 | =======
12 |
13 | Please refer to the `Virtual environment`_ documentation for installation best
14 | practices. If not using a virtual environment, please consider passing the
15 | widely recommended `'--user' flag`_ when invoking ``pip``.
16 |
17 | .. _Virtual environment: https://virtualenv.pypa.io/en/latest/
18 | .. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
19 |
20 | .. code-block:: bash
21 |
22 | $ pip install 'molecule[docker]'
23 |
--------------------------------------------------------------------------------
/molecule/debian9/molecule.yml:
--------------------------------------------------------------------------------
1 | ---
2 | dependency:
3 | name: galaxy
4 | enabled: false
5 | options:
6 | role-file: requirements.yml
7 | driver:
8 | name: docker
9 | lint: |
10 | yamllint .
11 | ansible-lint
12 | flake8
13 | platforms:
14 | - name: node1
15 | image: mrlesmithjr/debian:9
16 | privileged: true
17 | command: /lib/systemd/systemd
18 | volumes:
19 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
20 | cgroupns_mode: host
21 | groups:
22 | - galera-cluster-nodes
23 | - name: node2
24 | image: mrlesmithjr/debian:9
25 | privileged: true
26 | command: /lib/systemd/systemd
27 | volumes:
28 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
29 | cgroupns_mode: host
30 | groups:
31 | - galera-cluster-nodes
32 | provisioner:
33 | name: ansible
34 | playbooks:
35 | converge: ../shared/converge.yml
36 | prepare: ../shared/prepare.yml
37 | side_effect: ../shared/side_effect.yml
38 | verifier:
39 | name: ansible
40 |
--------------------------------------------------------------------------------
/molecule/debian9/verify.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # This is an example playbook to execute Ansible tests.
3 |
4 | - name: Verify
5 | hosts: all
6 | tasks:
7 | - name: Example assertion
8 | assert:
9 | that: true
10 |
--------------------------------------------------------------------------------
/molecule/fedora/INSTALL.rst:
--------------------------------------------------------------------------------
1 | *******
2 | Docker driver installation guide
3 | *******
4 |
5 | Requirements
6 | ============
7 |
8 | * Docker Engine
9 |
10 | Install
11 | =======
12 |
13 | Please refer to the `Virtual environment`_ documentation for installation best
14 | practices. If not using a virtual environment, please consider passing the
15 | widely recommended `'--user' flag`_ when invoking ``pip``.
16 |
17 | .. _Virtual environment: https://virtualenv.pypa.io/en/latest/
18 | .. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
19 |
20 | .. code-block:: bash
21 |
22 | $ pip install 'molecule[docker]'
23 |
--------------------------------------------------------------------------------
/molecule/fedora/molecule.yml:
--------------------------------------------------------------------------------
1 | ---
2 | dependency:
3 | name: galaxy
4 | enabled: false
5 | options:
6 | role-file: requirements.yml
7 | driver:
8 | name: docker
9 | lint: |
10 | yamllint .
11 | ansible-lint
12 | flake8
13 | platforms:
14 | - name: node1
15 | image: jrei/systemd-fedora
16 | privileged: true
17 | command: /usr/sbin/init
18 | volumes:
19 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
20 | cgroupns_mode: host
21 | groups:
22 | - galera-cluster-nodes
23 | - name: node2
24 | image: jrei/systemd-fedora
25 | privileged: true
26 | command: /usr/sbin/init
27 | volumes:
28 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
29 | cgroupns_mode: host
30 | groups:
31 | - galera-cluster-nodes
32 | provisioner:
33 | name: ansible
34 | playbooks:
35 | converge: ../shared/converge.yml
36 | prepare: ../shared/prepare.yml
37 | side_effect: ../shared/side_effect.yml
38 | verifier:
39 | name: ansible
40 |
--------------------------------------------------------------------------------
/molecule/fedora/verify.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # This is an example playbook to execute Ansible tests.
3 |
4 | - name: Verify
5 | hosts: all
6 | tasks:
7 | - name: Example assertion
8 | assert:
9 | that: true
10 |
--------------------------------------------------------------------------------
/molecule/rocky8/INSTALL.rst:
--------------------------------------------------------------------------------
1 | *******
2 | Docker driver installation guide
3 | *******
4 |
5 | Requirements
6 | ============
7 |
8 | * Docker Engine
9 |
10 | Install
11 | =======
12 |
13 | Please refer to the `Virtual environment`_ documentation for installation best
14 | practices. If not using a virtual environment, please consider passing the
15 | widely recommended `'--user' flag`_ when invoking ``pip``.
16 |
17 | .. _Virtual environment: https://virtualenv.pypa.io/en/latest/
18 | .. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
19 |
20 | .. code-block:: bash
21 |
22 | $ pip install 'molecule[docker]'
23 |
--------------------------------------------------------------------------------
/molecule/rocky8/molecule.yml:
--------------------------------------------------------------------------------
1 | ---
2 | dependency:
3 | name: galaxy
4 | enabled: false
5 | options:
6 | role-file: requirements.yml
7 | driver:
8 | name: docker
9 | lint: |
10 | yamllint .
11 | ansible-lint
12 | flake8
13 | platforms:
14 | - name: node1
15 | image: mrlesmithjr/rocky:8
16 | privileged: true
17 | command: /usr/sbin/init
18 | volumes:
19 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
20 | cgroupns_mode: host
21 | groups:
22 | - galera-cluster-nodes
23 | - name: node2
24 | image: mrlesmithjr/rocky:8
25 | privileged: true
26 | command: /usr/sbin/init
27 | volumes:
28 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
29 | cgroupns_mode: host
30 | groups:
31 | - galera-cluster-nodes
32 | provisioner:
33 | name: ansible
34 | playbooks:
35 | converge: ../shared/converge.yml
36 | prepare: ../shared/prepare.yml
37 | side_effect: ../shared/side_effect.yml
38 | verifier:
39 | name: ansible
40 |
--------------------------------------------------------------------------------
/molecule/rocky8/verify.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # This is an example playbook to execute Ansible tests.
3 |
4 | - name: Verify
5 | hosts: all
6 | tasks:
7 | - name: Example assertion
8 | assert:
9 | that: true
10 |
--------------------------------------------------------------------------------
/molecule/rocky9/INSTALL.rst:
--------------------------------------------------------------------------------
1 | *******
2 | Docker driver installation guide
3 | *******
4 |
5 | Requirements
6 | ============
7 |
8 | * Docker Engine
9 |
10 | Install
11 | =======
12 |
13 | Please refer to the `Virtual environment`_ documentation for installation best
14 | practices. If not using a virtual environment, please consider passing the
15 | widely recommended `'--user' flag`_ when invoking ``pip``.
16 |
17 | .. _Virtual environment: https://virtualenv.pypa.io/en/latest/
18 | .. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
19 |
20 | .. code-block:: bash
21 |
22 | $ pip install 'molecule[docker]'
23 |
--------------------------------------------------------------------------------
/molecule/rocky9/molecule.yml:
--------------------------------------------------------------------------------
1 | ---
2 | dependency:
3 | name: galaxy
4 | enabled: false
5 | options:
6 | role-file: requirements.yml
7 | driver:
8 | name: docker
9 | lint: |
10 | yamllint .
11 | ansible-lint
12 | flake8
13 | platforms:
14 | - name: node1
15 | image: mrlesmithjr/rocky:9
16 | privileged: true
17 | command: /usr/sbin/init
18 | volumes:
19 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
20 | cgroupns_mode: host
21 | groups:
22 | - galera-cluster-nodes
23 | - name: node2
24 | image: mrlesmithjr/rocky:9
25 | privileged: true
26 | command: /usr/sbin/init
27 | volumes:
28 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
29 | cgroupns_mode: host
30 | groups:
31 | - galera-cluster-nodes
32 | provisioner:
33 | name: ansible
34 | playbooks:
35 | converge: ../shared/converge.yml
36 | prepare: ../shared/prepare.yml
37 | side_effect: ../shared/side_effect.yml
38 | verifier:
39 | name: ansible
40 |
--------------------------------------------------------------------------------
/molecule/rocky9/verify.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # This is an example playbook to execute Ansible tests.
3 |
4 | - name: Verify
5 | hosts: all
6 | tasks:
7 | - name: Example assertion
8 | assert:
9 | that: true
10 |
--------------------------------------------------------------------------------
/molecule/shared/converge.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Converge
3 | hosts: all
4 | tasks:
5 | - name: Include ansible-mariadb-galera-cluster
6 | include_role:
7 | name: ansible-mariadb-galera-cluster
8 |
--------------------------------------------------------------------------------
/molecule/shared/prepare.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: all
3 | tasks:
4 | - name: Update Apt Cache
5 | apt:
6 | update_cache: true
7 | become: true
8 | when: ansible_os_family == "Debian"
9 |
--------------------------------------------------------------------------------
/molecule/shared/side_effect.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Side effects
3 | hosts: all
4 | vars:
5 | mariadb_mysql_root_password: 'password'
6 | tasks:
7 | - name: Include ansible-mariadb-galera-cluster
8 | include_role:
9 | name: ansible-mariadb-galera-cluster
10 |
--------------------------------------------------------------------------------
/molecule/shared/verify.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # This is an example playbook to execute Ansible tests.
3 |
4 | - name: Verify
5 | hosts: all
6 | tasks:
7 | - name: Example assertion
8 | assert:
9 | that: true
10 |
--------------------------------------------------------------------------------
/molecule/ubuntu1604/INSTALL.rst:
--------------------------------------------------------------------------------
1 | *******
2 | Docker driver installation guide
3 | *******
4 |
5 | Requirements
6 | ============
7 |
8 | * Docker Engine
9 |
10 | Install
11 | =======
12 |
13 | Please refer to the `Virtual environment`_ documentation for installation best
14 | practices. If not using a virtual environment, please consider passing the
15 | widely recommended `'--user' flag`_ when invoking ``pip``.
16 |
17 | .. _Virtual environment: https://virtualenv.pypa.io/en/latest/
18 | .. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
19 |
20 | .. code-block:: bash
21 |
22 | $ pip install 'molecule[docker]'
23 |
--------------------------------------------------------------------------------
/molecule/ubuntu1604/molecule.yml:
--------------------------------------------------------------------------------
1 | ---
2 | dependency:
3 | name: galaxy
4 | enabled: false
5 | options:
6 | role-file: requirements.yml
7 | driver:
8 | name: docker
9 | lint: |
10 | yamllint .
11 | ansible-lint
12 | flake8
13 | platforms:
14 | - name: node1
15 | image: mrlesmithjr/ubuntu:16.04
16 | privileged: true
17 | command: /lib/systemd/systemd
18 | volumes:
19 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
20 | cgroupns_mode: host
21 | groups:
22 | - galera-cluster-nodes
23 | - name: node2
24 | image: mrlesmithjr/ubuntu:16.04
25 | privileged: true
26 | command: /lib/systemd/systemd
27 | volumes:
28 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
29 | cgroupns_mode: host
30 | groups:
31 | - galera-cluster-nodes
32 | provisioner:
33 | name: ansible
34 | playbooks:
35 | converge: ../shared/converge.yml
36 | prepare: ../shared/prepare.yml
37 | side_effect: ../shared/side_effect.yml
38 | verifier:
39 | name: ansible
40 |
--------------------------------------------------------------------------------
/molecule/ubuntu1604/verify.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # This is an example playbook to execute Ansible tests.
3 |
4 | - name: Verify
5 | hosts: all
6 | tasks:
7 | - name: Example assertion
8 | assert:
9 | that: true
10 |
--------------------------------------------------------------------------------
/molecule/ubuntu1804/INSTALL.rst:
--------------------------------------------------------------------------------
1 | *******
2 | Docker driver installation guide
3 | *******
4 |
5 | Requirements
6 | ============
7 |
8 | * Docker Engine
9 |
10 | Install
11 | =======
12 |
13 | Please refer to the `Virtual environment`_ documentation for installation best
14 | practices. If not using a virtual environment, please consider passing the
15 | widely recommended `'--user' flag`_ when invoking ``pip``.
16 |
17 | .. _Virtual environment: https://virtualenv.pypa.io/en/latest/
18 | .. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
19 |
20 | .. code-block:: bash
21 |
22 | $ pip install 'molecule[docker]'
23 |
--------------------------------------------------------------------------------
/molecule/ubuntu1804/molecule.yml:
--------------------------------------------------------------------------------
1 | ---
2 | dependency:
3 | name: galaxy
4 | enabled: false
5 | options:
6 | role-file: requirements.yml
7 | driver:
8 | name: docker
9 | lint: |
10 | yamllint .
11 | ansible-lint
12 | flake8
13 | platforms:
14 | - name: node1
15 | image: mrlesmithjr/ubuntu:18.04
16 | privileged: true
17 | command: /lib/systemd/systemd
18 | volumes:
19 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
20 | cgroupns_mode: host
21 | groups:
22 | - galera-cluster-nodes
23 | - name: node2
24 | image: mrlesmithjr/ubuntu:18.04
25 | privileged: true
26 | command: /lib/systemd/systemd
27 | volumes:
28 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
29 | cgroupns_mode: host
30 | groups:
31 | - galera-cluster-nodes
32 | provisioner:
33 | name: ansible
34 | playbooks:
35 | converge: ../shared/converge.yml
36 | prepare: ../shared/prepare.yml
37 | side_effect: ../shared/side_effect.yml
38 | verifier:
39 | name: ansible
40 |
--------------------------------------------------------------------------------
/molecule/ubuntu1804/verify.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # This is an example playbook to execute Ansible tests.
3 |
4 | - name: Verify
5 | hosts: all
6 | tasks:
7 | - name: Example assertion
8 | assert:
9 | that: true
10 |
--------------------------------------------------------------------------------
/molecule/ubuntu2004/INSTALL.rst:
--------------------------------------------------------------------------------
1 | *******
2 | Docker driver installation guide
3 | *******
4 |
5 | Requirements
6 | ============
7 |
8 | * Docker Engine
9 |
10 | Install
11 | =======
12 |
13 | Please refer to the `Virtual environment`_ documentation for installation best
14 | practices. If not using a virtual environment, please consider passing the
15 | widely recommended `'--user' flag`_ when invoking ``pip``.
16 |
17 | .. _Virtual environment: https://virtualenv.pypa.io/en/latest/
18 | .. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
19 |
20 | .. code-block:: bash
21 |
22 | $ pip install 'molecule[docker]'
23 |
--------------------------------------------------------------------------------
/molecule/ubuntu2004/molecule.yml:
--------------------------------------------------------------------------------
1 | ---
2 | dependency:
3 | name: galaxy
4 | enabled: false
5 | options:
6 | role-file: requirements.yml
7 | driver:
8 | name: docker
9 | lint: |
10 | yamllint .
11 | ansible-lint
12 | flake8
13 | platforms:
14 | - name: node1
15 | image: mrlesmithjr/ubuntu:20.04
16 | privileged: true
17 | command: /lib/systemd/systemd
18 | volumes:
19 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
20 | cgroupns_mode: host
21 | groups:
22 | - galera-cluster-nodes
23 | - name: node2
24 | image: mrlesmithjr/ubuntu:20.04
25 | privileged: true
26 | command: /lib/systemd/systemd
27 | volumes:
28 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
29 | cgroupns_mode: host
30 | groups:
31 | - galera-cluster-nodes
32 | provisioner:
33 | name: ansible
34 | playbooks:
35 | converge: ../shared/converge.yml
36 | prepare: ../shared/prepare.yml
37 | side_effect: ../shared/side_effect.yml
38 | verifier:
39 | name: ansible
40 |
--------------------------------------------------------------------------------
/molecule/ubuntu2004/verify.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # This is an example playbook to execute Ansible tests.
3 |
4 | - name: Verify
5 | hosts: all
6 | tasks:
7 | - name: Example assertion
8 | assert:
9 | that: true
10 |
--------------------------------------------------------------------------------
/molecule/ubuntu2204/INSTALL.rst:
--------------------------------------------------------------------------------
1 | *******
2 | Docker driver installation guide
3 | *******
4 |
5 | Requirements
6 | ============
7 |
8 | * Docker Engine
9 |
10 | Install
11 | =======
12 |
13 | Please refer to the `Virtual environment`_ documentation for installation best
14 | practices. If not using a virtual environment, please consider passing the
15 | widely recommended `'--user' flag`_ when invoking ``pip``.
16 |
17 | .. _Virtual environment: https://virtualenv.pypa.io/en/latest/
18 | .. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
19 |
20 | .. code-block:: bash
21 |
22 | $ pip install 'molecule[docker]'
23 |
--------------------------------------------------------------------------------
/molecule/ubuntu2204/molecule.yml:
--------------------------------------------------------------------------------
1 | ---
2 | dependency:
3 | name: galaxy
4 | enabled: false
5 | options:
6 | role-file: requirements.yml
7 | driver:
8 | name: docker
9 | lint: |
10 | yamllint .
11 | ansible-lint
12 | flake8
13 | platforms:
14 | - name: node1
15 | image: mrlesmithjr/ubuntu:22.04
16 | privileged: true
17 | command: /lib/systemd/systemd
18 | volumes:
19 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
20 | cgroupns_mode: host
21 | groups:
22 | - galera-cluster-nodes
23 | - name: node2
24 | image: mrlesmithjr/ubuntu:22.04
25 | privileged: true
26 | command: /lib/systemd/systemd
27 | volumes:
28 | - /sys/fs/cgroup:/sys/fs/cgroup:rw
29 | cgroupns_mode: host
30 | groups:
31 | - galera-cluster-nodes
32 | provisioner:
33 | name: ansible
34 | playbooks:
35 | converge: ../shared/converge.yml
36 | prepare: ../shared/prepare.yml
37 | side_effect: ../shared/side_effect.yml
38 | verifier:
39 | name: ansible
40 |
--------------------------------------------------------------------------------
/molecule/ubuntu2204/verify.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # This is an example playbook to execute Ansible tests.
3 |
4 | - name: Verify
5 | hosts: all
6 | tasks:
7 | - name: Example assertion
8 | assert:
9 | that: true
10 |
--------------------------------------------------------------------------------
/playbook.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Example Playbook
3 | hosts: all
4 | tasks:
5 | - name: Include ansible-mariadb-galera-cluster
6 | include_role:
7 | name: ansible-mariadb-galera-cluster
8 |
--------------------------------------------------------------------------------
/pyproject.toml:
--------------------------------------------------------------------------------
1 | [tool.poetry]
2 | name = "ansible-mariadb-galera-cluster"
3 | version = "0.1.0"
4 | description = ""
5 | authors = ["Larry Smith Jr. "]
6 |
7 | [tool.poetry.dependencies]
8 | python = ">=3.10,<4.0"
9 | ansible = "9.1.0"
10 | netaddr = "^0.8.0"
11 |
12 | [tool.poetry.group.dev.dependencies]
13 | ansible-lint = "6.8.7"
14 | black = "^24.3.0"
15 | pylint = "^2.15.7"
16 | molecule = {extras = ["docker"], version = "^4.0.3"}
17 | flake8 = "^6.0.0"
18 | cookiecutter = "^2.1.1"
19 | pre-commit = "^2.20.0"
20 |
21 | [build-system]
22 | requires = ["poetry-core>=1.0.0"]
23 | build-backend = "poetry.core.masonry.api"
24 |
--------------------------------------------------------------------------------
/requirements-dev.in:
--------------------------------------------------------------------------------
1 | # Python requirements for development
2 | -c requirements.txt
3 | autopep8
4 | flake8
5 | pycodestyle
6 | pylint
7 | tox
8 |
--------------------------------------------------------------------------------
/requirements-dev.txt:
--------------------------------------------------------------------------------
1 | ansible-compat==2.2.6 ; python_version >= "3.10" and python_version < "4.0"
2 | ansible-core==2.16.3 ; python_version >= "3.10" and python_version < "4.0"
3 | ansible-lint==6.8.7 ; python_version >= "3.10" and python_version < "4.0"
4 | ansible==9.1.0 ; python_version >= "3.10" and python_version < "4.0"
5 | arrow==1.2.3 ; python_version >= "3.10" and python_version < "4.0"
6 | astroid==2.12.13 ; python_version >= "3.10" and python_version < "4.0"
7 | attrs==22.1.0 ; python_version >= "3.10" and python_version < "4.0"
8 | binaryornot==0.4.4 ; python_version >= "3.10" and python_version < "4.0"
9 | black==22.10.0 ; python_version >= "3.10" and python_version < "4.0"
10 | bracex==2.3.post1 ; python_version >= "3.10" and python_version < "4.0"
11 | certifi==2022.9.24 ; python_version >= "3.10" and python_version < "4"
12 | cffi==1.15.1 ; python_version >= "3.10" and python_version < "4.0"
13 | cfgv==3.3.1 ; python_version >= "3.10" and python_version < "4.0"
14 | chardet==5.1.0 ; python_version >= "3.10" and python_version < "4.0"
15 | charset-normalizer==2.1.1 ; python_version >= "3.10" and python_version < "4"
16 | click-help-colors==0.9.1 ; python_version >= "3.10" and python_version < "4.0"
17 | click==8.1.3 ; python_version >= "3.10" and python_version < "4.0"
18 | colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and sys_platform == "win32" or python_version >= "3.10" and python_version < "4.0" and platform_system == "Windows"
19 | commonmark==0.9.1 ; python_version >= "3.10" and python_version < "4.0"
20 | cookiecutter==2.1.1 ; python_version >= "3.10" and python_version < "4.0"
21 | cryptography==42.0.4 ; python_version >= "3.10" and python_version < "4.0"
22 | dill==0.3.6 ; python_version >= "3.10" and python_version < "4.0"
23 | distlib==0.3.6 ; python_version >= "3.10" and python_version < "4.0"
24 | distro==1.8.0 ; python_version >= "3.10" and python_version < "4.0" and sys_platform == "linux" or python_version >= "3.10" and python_version < "4.0" and sys_platform == "linux2"
25 | docker==6.0.1 ; python_version >= "3.10" and python_version < "4.0"
26 | enrich==1.2.7 ; python_version >= "3.10" and python_version < "4.0"
27 | filelock==3.8.2 ; python_version >= "3.10" and python_version < "4.0"
28 | flake8==6.0.0 ; python_version >= "3.10" and python_version < "4.0"
29 | identify==2.5.9 ; python_version >= "3.10" and python_version < "4.0"
30 | idna==3.4 ; python_version >= "3.10" and python_version < "4"
31 | importlib-resources==5.10.1 ; python_version >= "3.10"
32 | isort==5.10.1 ; python_version >= "3.10" and python_version < "4.0"
33 | jinja2-time==0.2.0 ; python_version >= "3.10" and python_version < "4.0"
34 | jinja2==3.1.3 ; python_version >= "3.10" and python_version < "4.0"
35 | jsonschema==4.17.3 ; python_version >= "3.10" and python_version < "4.0"
36 | lazy-object-proxy==1.8.0 ; python_version >= "3.10" and python_version < "4.0"
37 | markupsafe==2.1.1 ; python_version >= "3.10" and python_version < "4.0"
38 | mccabe==0.7.0 ; python_version >= "3.10" and python_version < "4.0"
39 | molecule-docker==2.1.0 ; python_version >= "3.10" and python_version < "4.0"
40 | molecule==4.0.4 ; python_version >= "3.10" and python_version < "4.0"
41 | molecule[docker]==4.0.4 ; python_version >= "3.10" and python_version < "4.0"
42 | mypy-extensions==0.4.3 ; python_version >= "3.10" and python_version < "4.0"
43 | netaddr==0.8.0 ; python_version >= "3.10" and python_version < "4.0"
44 | nodeenv==1.7.0 ; python_version >= "3.10" and python_version < "4.0"
45 | packaging==21.3 ; python_version >= "3.10" and python_version < "4.0"
46 | pathspec==0.10.2 ; python_version >= "3.10" and python_version < "4.0"
47 | pkgutil-resolve-name==1.3.10 ; python_version >= "3.10"
48 | platformdirs==2.6.0 ; python_version >= "3.10" and python_version < "4.0"
49 | pluggy==1.0.0 ; python_version >= "3.10" and python_version < "4.0"
50 | pre-commit==2.20.0 ; python_version >= "3.10" and python_version < "4.0"
51 | pycodestyle==2.10.0 ; python_version >= "3.10" and python_version < "4.0"
52 | pycparser==2.21 ; python_version >= "3.10" and python_version < "4.0"
53 | pyflakes==3.0.1 ; python_version >= "3.10" and python_version < "4.0"
54 | pygments==2.13.0 ; python_version >= "3.10" and python_version < "4.0"
55 | pylint==2.15.8 ; python_version >= "3.10" and python_version < "4.0"
56 | pyparsing==3.0.9 ; python_version >= "3.10" and python_version < "4.0"
57 | pyrsistent==0.19.2 ; python_version >= "3.10" and python_version < "4.0"
58 | python-dateutil==2.8.2 ; python_version >= "3.10" and python_version < "4.0"
59 | python-slugify==7.0.0 ; python_version >= "3.10" and python_version < "4.0"
60 | pywin32==305 ; python_version >= "3.10" and python_version < "4.0" and sys_platform == "win32"
61 | pyyaml==6.0 ; python_version >= "3.10" and python_version < "4.0"
62 | requests==2.28.1 ; python_version >= "3.10" and python_version < "4"
63 | resolvelib==0.8.1 ; python_version >= "3.10" and python_version < "4.0"
64 | rich==12.6.0 ; python_version >= "3.10" and python_version < "4.0"
65 | ruamel-yaml-clib==0.2.7 ; platform_python_implementation == "CPython" and python_version < "3.11" and python_version >= "3.10"
66 | ruamel-yaml==0.17.21 ; python_version >= "3.10" and python_version < "4.0"
67 | selinux==0.2.1 ; python_version >= "3.10" and python_version < "4.0" and sys_platform == "linux" or python_version >= "3.10" and python_version < "4.0" and sys_platform == "linux2"
68 | setuptools==65.6.3 ; python_version >= "3.10" and python_version < "4.0"
69 | six==1.16.0 ; python_version >= "3.10" and python_version < "4.0"
70 | subprocess-tee==0.4.0 ; python_version >= "3.10" and python_version < "4.0"
71 | text-unidecode==1.3 ; python_version >= "3.10" and python_version < "4.0"
72 | toml==0.10.2 ; python_version >= "3.10" and python_version < "4.0"
73 | tomli==2.0.1 ; python_version >= "3.10" and python_full_version < "3.11.0a7"
74 | tomlkit==0.11.6 ; python_version >= "3.10" and python_version < "4.0"
75 | typing-extensions==4.4.0 ; python_version >= "3.10" and python_version < "3.10"
76 | urllib3==1.26.13 ; python_version >= "3.10" and python_version < "4"
77 | virtualenv==20.17.1 ; python_version >= "3.10" and python_version < "4.0"
78 | wcmatch==8.4.1 ; python_version >= "3.10" and python_version < "4.0"
79 | websocket-client==1.4.2 ; python_version >= "3.10" and python_version < "4.0"
80 | wrapt==1.14.1 ; python_version >= "3.10" and python_version < "4.0"
81 | yamllint==1.28.0 ; python_version >= "3.10" and python_version < "4.0"
82 | zipp==3.11.0 ; python_version >= "3.10"
83 |
--------------------------------------------------------------------------------
/requirements.in:
--------------------------------------------------------------------------------
1 | # Python requirements for executing
2 | ansible
3 | ansible-lint
4 | docker
5 | mkdocs
6 | molecule[docker]
7 | pip-tools
8 | yamllint
9 | netaddr
10 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | ansible-core==2.16.3 ; python_version >= "3.10" and python_version < "4.0"
2 | ansible==9.1.0 ; python_version >= "3.10" and python_version < "4.0"
3 | cffi==1.15.1 ; python_version >= "3.10" and python_version < "4.0"
4 | cryptography==42.0.4 ; python_version >= "3.10" and python_version < "4.0"
5 | jinja2==3.1.3 ; python_version >= "3.10" and python_version < "4.0"
6 | markupsafe==2.1.1 ; python_version >= "3.10" and python_version < "4.0"
7 | netaddr==0.8.0 ; python_version >= "3.10" and python_version < "4.0"
8 | packaging==21.3 ; python_version >= "3.10" and python_version < "4.0"
9 | pycparser==2.21 ; python_version >= "3.10" and python_version < "4.0"
10 | pyparsing==3.0.9 ; python_version >= "3.10" and python_version < "4.0"
11 | pyyaml==6.0 ; python_version >= "3.10" and python_version < "4.0"
12 | resolvelib==0.8.1 ; python_version >= "3.10" and python_version < "4.0"
13 |
--------------------------------------------------------------------------------
/requirements.yml:
--------------------------------------------------------------------------------
1 | ---
2 | collections:
3 | - name: ansible.utils
4 | version: ">=2.12.0"
5 | - name: ansible.netcommon
6 | - name: community.docker
7 | version: "*" # Need to ensure that the latest version is installed or Molecule fails
8 | roles: []
9 |
--------------------------------------------------------------------------------
/tasks/cacti.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: cacti_monitoring | adding cacti db user for monitoring
3 | community.mysql.mysql_user:
4 | host: "{{ cacti_server }}"
5 | login_unix_socket: "{{ mariadb_login_unix_socket | default(omit) }}"
6 | name: "{{ cacti_db_user }}"
7 | password: "{{ cacti_db_password }}"
8 | priv: "*.*:SUPER,PROCESS"
9 | state: "present"
10 | become: true
11 | tags:
12 | - cacti_monitoring
13 | run_once: true
14 | when: >
15 | cacti_server is defined
16 |
17 | - name: cacti_monitoring | adding cacti db user for monitoring
18 | community.mysql.mysql_user:
19 | host: "{{ cacti_server_fqdn }}"
20 | login_unix_socket: "{{ mariadb_login_unix_socket | default(omit) }}"
21 | name: "{{ cacti_db_user }}"
22 | password: "{{ cacti_db_password }}"
23 | priv: "*.*:SUPER,PROCESS"
24 | state: "present"
25 | become: true
26 | tags:
27 | - cacti_monitoring
28 | run_once: true
29 | when: >
30 | cacti_server_fqdn is defined
31 |
--------------------------------------------------------------------------------
/tasks/checks.yml:
--------------------------------------------------------------------------------
1 | ---
2 |
3 | - name: ensure NIC specified in 'galera_cluster_bind_interface' exists
4 | ansible.builtin.assert:
5 | that: galera_cluster_bind_interface in ansible_interfaces
6 | fail_msg: >-
7 | The NIC name "{{ galera_cluster_bind_interface }}" specified in
8 | "galera_cluster_bind_interface" does not exist on the target host.
9 | Available interfaces are: "{{ ansible_interfaces | join(',') }}".
10 | tags:
11 | - install
12 | - config
13 |
14 | - name: When mariadb_sst_username is unix_socket, the mariadb_sst_password should not be set
15 | ansible.builtin.assert:
16 | that:
17 | - mariadb_sst_password == ""
18 | fail_msg: >-
19 | When the mariadb_sst_user_plugin is set to unix_socket
20 | the mariadb_sst_password should not be set because it is ignored.
21 | when: mariadb_sst_user_plugin == "unix_socket"
22 | tags:
23 | - install
24 | - config
25 |
26 | - name: When mariadb_sst_username is mysql_native_password, mariadb_sst_password should also be set
27 | ansible.builtin.assert:
28 | that:
29 | - mariadb_sst_password != ""
30 | fail_msg: >-
31 | When the mariadb_sst_user_plugin is set to mysql_native_password
32 | the mariadb_sst_password should also be set.
33 | when: mariadb_sst_user_plugin == "mysql_native_password"
34 | tags:
35 | - install
36 | - config
37 |
38 | - name: Check mariadb_version on target system
39 | ansible.builtin.command: "mariadb -V"
40 | check_mode: false
41 | register: mariadb_version_check
42 | failed_when: '"mariadb" not in mariadb_version_check.stdout and mariadb_version_check.rc == 0'
43 | changed_when: not 'mariadb_version_check.rc == 0'
44 | when: not mariadb_upgrade|bool
45 | tags:
46 | - install
47 | - config
48 |
49 | - name: Extract MariaDB version
50 | set_fact:
51 | mariadb_version_checked: "{{ mariadb_version_check | regex_search('\\d+\\.\\d+\\.\\d+-MariaDB') }}"
52 | check_mode: false
53 | when: not mariadb_upgrade|bool and mariadb_version_check.rc == 0
54 | tags:
55 | - install
56 | - config
57 |
58 | - name:
59 | ansible.builtin.debug:
60 | msg: "Installed {{ mariadb_version_checked }} - mariadb_version: {{ mariadb_version }}"
61 | when: not mariadb_upgrade|bool and mariadb_version_check.rc == 0
62 |
63 | - name: Verify the expected mariadb_version
64 | ansible.builtin.assert:
65 | that: 'mariadb_version_checked.startswith("{{ mariadb_version }}")'
66 | fail_msg: >-
67 | The mariadb_version "{{ mariadb_version }}" doesn't match the one
68 | installed on the system: {{ mariadb_version_checked }}.
69 | Use the correct mariadb_version or set mariadb_upgrade: True
70 | when: not mariadb_upgrade|bool and mariadb_version_check.rc == 0
71 | tags:
72 | - install
73 | - config
74 |
--------------------------------------------------------------------------------
/tasks/configure_root_access.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: configure_root_access | updating root passwords
3 | community.mysql.mysql_user:
4 | host: "{{ item }}"
5 | login_unix_socket: "{{ mariadb_login_unix_socket | default(omit) }}"
6 | name: "root"
7 | password: "{{ mariadb_mysql_root_password }}"
8 | become: true
9 | no_log: "{{ galera_users_no_log | bool }}"
10 | ignore_errors: true
11 | run_once: true
12 | retries: 6
13 | delay: 5
14 | with_items:
15 | - "{{ ansible_hostname }}"
16 | - "127.0.0.1"
17 | - "::1"
18 | - "localhost"
19 |
20 | - name: configure_root_access | configuring root my.cnf
21 | ansible.builtin.template:
22 | src: "root/my.cnf.j2"
23 | dest: "/root/.my.cnf"
24 | owner: "root"
25 | group: "root"
26 | mode: "u=rw,g=,o="
27 | become: true
28 | no_log: "{{ galera_users_no_log | bool }}"
29 |
30 | - name: configure_root_access | updating root passwords (allow from anywhere)
31 | community.mysql.mysql_user:
32 | host: "{{ item }}"
33 | login_unix_socket: "{{ mariadb_login_unix_socket | default(omit) }}"
34 | name: "root"
35 | password: "{{ mariadb_mysql_root_password }}"
36 | priv: "*.*:ALL,GRANT"
37 | become: true
38 | no_log: "{{ galera_users_no_log | bool }}"
39 | run_once: true
40 | retries: 6
41 | delay: 5
42 | with_items:
43 | - "%"
44 | when: galera_allow_root_from_any|bool
45 |
--------------------------------------------------------------------------------
/tasks/debian.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: debian | update package list
3 | ansible.builtin.apt:
4 | update_cache: true
5 | cache_valid_time: 3600
6 | become: true
7 |
8 | - name: debian | installing pre-reqs
9 | ansible.builtin.apt:
10 | name: "{{ mariadb_pre_req_packages }}"
11 | state: "present"
12 | become: true
13 | loop:
14 |
15 | - name: debian | adding MariaDB Repo Keys
16 | apt_key:
17 | keyserver: "{{ mariadb_debian_repo_keyserver }}"
18 | id: "{{ mariadb_debian_repo_key|string }}"
19 | state: "present"
20 | become: true
21 | when: galera_enable_mariadb_repo|bool and not mariadb_debian_repo_key_url is defined
22 |
23 | - name: debian | adding MariaDB Repo Keys
24 | apt_key:
25 | url: "{{ mariadb_debian_repo_key_url }}"
26 | state: "present"
27 | become: true
28 | when: galera_enable_mariadb_repo|bool and mariadb_debian_repo_key_url is defined
29 |
30 | - name: debian | pinning MariaDB Repo
31 | ansible.builtin.template:
32 | src: "etc/apt/preferences.d/mariadb.j2"
33 | dest: "/etc/apt/preferences.d/mariadb"
34 | mode: "0644"
35 | become: true
36 | when: galera_enable_mariadb_repo|bool
37 |
38 | - name: debian | adding mariadb repo
39 | apt_repository:
40 | repo: "{{ mariadb_debian_repo }}"
41 | state: "present"
42 | become: true
43 | when: galera_enable_mariadb_repo|bool
44 |
45 | - name: debian | precreate /etc/mysql/conf.d in case we need to add mariadb_config_overrides file
46 | ansible.builtin.file:
47 | path: "/etc/mysql/conf.d"
48 | state: "directory"
49 | mode: "0755"
50 | become: true
51 | when: mariadb_config_overrides is defined
52 |
53 | - name: debian | add an overrides file
54 | ansible.builtin.template:
55 | src: "etc/mariadb_overrides.cnf.j2"
56 | dest: "/etc/mysql/conf.d/overrides.cnf"
57 | mode: "0644"
58 | become: true
59 | when: mariadb_config_overrides is defined
60 |
61 | - ansible.builtin.import_tasks: mariadb_packages_install.yml
62 |
--------------------------------------------------------------------------------
/tasks/galera_monitoring.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: galera_monitoring | configuring monitor script for galera
3 | ansible.builtin.template:
4 | src: "etc/mysql/{{ galera_monitor_script_name }}.j2"
5 | dest: "{{ galera_monitor_script_path }}/{{ galera_monitor_script_name }}"
6 | owner: "mysql"
7 | group: "mysql"
8 | mode: "u=rwx,g=rwx,o="
9 | become: true
10 | register: galera_monitoring_updated
11 |
12 | - name: galera_monitoring | restarting mysql on first node
13 | ansible.builtin.service:
14 | name: "{{ mariadb_systemd_service_name }}"
15 | state: "restarted"
16 | become: true
17 | when: >
18 | inventory_hostname == galera_mysql_first_node and
19 | galera_monitoring_updated.changed
20 |
21 | - name: galera_monitoring | waiting for mysql to start on first node
22 | ansible.builtin.service:
23 | name: "{{ mariadb_systemd_service_name }}"
24 | state: "started"
25 | become: true
26 | register: "_mariadb_galera_cluster_node"
27 | until: _mariadb_galera_cluster_node.status.ActiveState == "active"
28 | retries: 60
29 | delay: 5
30 | delegate_to: "{{ galera_mysql_first_node }}"
31 | run_once: true
32 | when: >
33 | inventory_hostname != galera_mysql_first_node and
34 | galera_monitoring_updated.changed
35 |
36 | - name: galera_monitoring | restarting mysql on additional servers
37 | ansible.builtin.service:
38 | name: "{{ mariadb_systemd_service_name }}"
39 | state: "restarted"
40 | become: true
41 | throttle: 1
42 | when: >
43 | inventory_hostname != galera_mysql_first_node and
44 | galera_monitoring_updated.changed
45 |
46 | - name: galera_monitoring | waiting for mysql to start on other nodes
47 | ansible.builtin.service:
48 | name: "{{ mariadb_systemd_service_name }}"
49 | state: "started"
50 | become: true
51 | register: "_mariadb_galera_cluster_node"
52 | until: _mariadb_galera_cluster_node.status.ActiveState == "active"
53 | retries: 60
54 | delay: 5
55 | when: >
56 | inventory_hostname != galera_mysql_first_node and
57 | galera_monitoring_updated.changed
58 |
--------------------------------------------------------------------------------
/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for ansible-mariadb-galera-cluster
3 | - name: gather os specific variables
4 | ansible.builtin.include_vars: "{{ item }}"
5 | tags:
6 | - always
7 | - install
8 | - config
9 | with_first_found:
10 | - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
11 | - "{{ ansible_distribution | lower }}.yml"
12 | - "{{ ansible_os_family | lower }}.yml"
13 |
14 | - ansible.builtin.import_tasks: checks.yml
15 | tags:
16 | - always
17 | - install
18 |
19 | - ansible.builtin.import_tasks: debian.yml
20 | tags:
21 | - install
22 | when: ansible_os_family == "Debian"
23 |
24 | - ansible.builtin.import_tasks: redhat.yml
25 | tags:
26 | - install
27 | when: ansible_os_family == "RedHat"
28 |
29 | - ansible.builtin.import_tasks: system_performance_tuning.yml
30 | tags:
31 | - config
32 |
33 | - name: flush handlers before continuing
34 | meta: flush_handlers
35 | tags:
36 | - install
37 | - config
38 |
39 | # ensure the first node is running in order to add users
40 | - name: "ensure {{ mariadb_systemd_service_name }} is started on first node"
41 | ansible.builtin.service:
42 | name: "{{ mariadb_systemd_service_name }}"
43 | state: "started"
44 | become: true
45 | when: inventory_hostname == galera_mysql_first_node
46 |
47 | - ansible.builtin.import_tasks: mysql_users.yml
48 | tags:
49 | - config
50 | - mysql_users
51 |
52 | - ansible.builtin.import_tasks: setup_cluster.yml
53 | tags:
54 | - config
55 |
56 | - ansible.builtin.import_tasks: configure_root_access.yml
57 | tags:
58 | - config
59 |
60 | - ansible.builtin.import_tasks: mysql_databases.yml
61 | tags:
62 | - mysql_databases
63 | when:
64 | - mariadb_databases | count > 0
65 | - inventory_hostname == galera_mysql_first_node
66 |
67 | - ansible.builtin.import_tasks: galera_monitoring.yml
68 | tags:
69 | - config_galera_monitoring
70 | when: galera_enable_galera_monitoring_script|bool
71 |
72 | - ansible.builtin.import_tasks: cacti.yml
73 | tags:
74 | - config_cacti_monitoring
75 | when: galera_enable_cacti_monitoring
76 |
--------------------------------------------------------------------------------
/tasks/manage_node_state.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: manage_node_state | make node systemd service {{ mariadb_systemd_service_state }}
3 | ansible.builtin.service:
4 | name: "{{ mariadb_systemd_service_name }}"
5 | state: "{{ mariadb_systemd_service_state }}"
6 | become: true
7 | when: inventory_hostname == item
8 |
9 | - name: manage_node_state | Populate service facts
10 | ansible.builtin.service_facts:
11 |
12 | - name: manage_node_state | reset failed status (otherwise service can't be stopped)
13 | command: "systemctl reset-failed {{ mariadb_systemd_service_name }}" # noqa command-instead-of-module
14 | become: true
15 | check_mode: false
16 | changed_when: false
17 | when:
18 | - '"stopped" in mariadb_systemd_service_state'
19 | - inventory_hostname == item
20 | - '"failed" in ansible_facts.services[mariadb_systemd_service_name].state'
21 |
22 | - name: manage_node_state | ensure node is fully stopped before continuing
23 | ansible.builtin.service:
24 | name: "{{ mariadb_systemd_service_name }}"
25 | state: "stopped"
26 | become: true
27 | register: "_mariadb_galera_cluster_node"
28 | until: _mariadb_galera_cluster_node.status.ActiveState == "inactive"
29 | retries: 60
30 | delay: 5
31 | when:
32 | - '"stopped" in mariadb_systemd_service_state'
33 | - inventory_hostname == item
34 |
35 | - name: manage_node_state | ensure node is fully started before continuing
36 | ansible.builtin.service:
37 | name: "{{ mariadb_systemd_service_name }}"
38 | state: "started"
39 | become: true
40 | register: "_mariadb_galera_cluster_node"
41 | until: _mariadb_galera_cluster_node.status.ActiveState == "active"
42 | retries: 60
43 | delay: 5
44 | when:
45 | - '"started" in mariadb_systemd_service_state'
46 | - inventory_hostname == item
47 |
48 | - name: manage_node_state | sleep for extra 15 seconds to wait for node state stabilization
49 | wait_for:
50 | timeout: 15
51 | check_mode: false
52 | delegate_to: localhost
53 | become: false
54 | when:
55 | - '"started" in mariadb_systemd_service_state'
56 | - inventory_hostname == item
57 |
--------------------------------------------------------------------------------
/tasks/mariadb_packages_install.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: mariadb_packages_install | installing mariadb-galera packages
3 | ansible.builtin.package:
4 | name: "{{ (galera_sst_method == 'mariabackup') | ternary( mariadb_packages | union( mariabackup_packages ), mariadb_packages ) }}"
5 | state: "{{ mariadb_upgrade | ternary( 'latest', 'present' ) }}"
6 | update_cache: true
7 | become: true
8 |
--------------------------------------------------------------------------------
/tasks/max-open-files.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Supplementary configuration file
3 | - name: max-open-files | Create folder
4 | ansible.builtin.file:
5 | path: "/etc/systemd/system/mariadb.service.d"
6 | state: "directory"
7 | owner: "root"
8 | group: "root"
9 | mode: "u=rwx,g=rx,o=rx"
10 | notify: "reload systemd daemon"
11 | become: true
12 |
13 | - name: max-open-files | Add the overriding file
14 | ansible.builtin.template:
15 | src: "etc/systemd/system/mariadb.service.d/max-open-files.conf.j2"
16 | dest: "/etc/systemd/system/mariadb.service.d/max-open-files.conf"
17 | owner: "root"
18 | group: "root"
19 | mode: "u=rw,g=r,o=r"
20 | notify: "reload systemd daemon"
21 | become: true
22 |
--------------------------------------------------------------------------------
/tasks/mysql_databases.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Borrowed from percona xtradb cluster ansible role:
3 | # https://github.com/cdelgehier/ansible-role-XtraDB-Cluster/blob/master/tasks/postinstall.yml
4 | # Many thanks to Cedric DELGEHIER
5 | - name: mysql_databases | create the databases
6 | community.mysql.mysql_db:
7 | name: "{{ item.name }}"
8 | state: present
9 | login_unix_socket: "{{ mariadb_login_unix_socket | default(omit) }}"
10 | with_items: "{{ mariadb_databases }}"
11 | become: true
12 | register: _db
13 |
14 | - name: mysql_databases | copy database init scripts
15 | ansible.builtin.copy:
16 | src: "{{ item.item.init_script }}"
17 | dest: "/tmp/{{ item.item.init_script | basename }}"
18 | mode: "0600"
19 | with_items: "{{ _db.results }}"
20 | when:
21 | - item.changed
22 | - item.item.init_script is defined
23 |
24 | - name: mysql_databases | initialise databases
25 | community.mysql.mysql_db:
26 | name: "{{ item.item.name }}"
27 | state: import
28 | target: "/tmp/{{ item.item.init_script | basename }}"
29 | login_unix_socket: "{{ mariadb_login_unix_socket | default(omit) }}"
30 | with_items: "{{ _db.results }}"
31 | become: true
32 | when:
33 | - item.changed
34 | - item.item.init_script is defined
35 |
36 | - name: mysql_databases | delete init scripts from the server
37 | ansible.builtin.file:
38 | name: "/tmp/{{ item.item.init_script | basename }}"
39 | state: absent
40 | with_items: "{{ _db.results }}"
41 | when:
42 | - item.changed
43 | - item.item.init_script is defined
44 |
--------------------------------------------------------------------------------
/tasks/mysql_users.yml:
--------------------------------------------------------------------------------
1 | ---
2 |
3 | - name: "Check if {{ mariadb_sst_username }} exists in the system"
4 | block:
5 | - name: "Check if {{ mariadb_sst_username }} exists in the system"
6 | ansible.builtin.getent:
7 | database: passwd
8 | key: "{{ mariadb_sst_username }}"
9 | ignore_errors: true
10 | register: mariadb_sst_username__found
11 | - name: Fail if the above user does not exist
12 | ansible.builtin.fail:
13 | msg: >-
14 | The plugin for mariadb_sst_username was
15 | set to unix_socket but the user does not exist.
16 | when: mariadb_sst_username__found.failed
17 | delegate_to: "{{ galera_mysql_first_node }}"
18 | run_once: true
19 | when: mariadb_sst_user_plugin == "unix_socket"
20 |
21 | - name: Create definition for mariadb_sst_user via unix_socket
22 | ansible.builtin.set_fact:
23 | mariadb_sst_user:
24 | - name: "{{ mariadb_sst_username }}"
25 | hosts:
26 | - 'localhost'
27 | plugin: "{{ mariadb_sst_user_plugin }}"
28 | priv: "*.*:RELOAD,PROCESS,LOCK TABLES,BINLOG MONITOR"
29 | delegate_to: "{{ galera_mysql_first_node }}"
30 | run_once: true
31 | when: mariadb_sst_user_plugin == "unix_socket"
32 |
33 | - name: Create definition for mariadb_sst_user via mysql_native_password
34 | ansible.builtin.set_fact:
35 | mariadb_sst_user:
36 | - name: "{{ mariadb_sst_username }}"
37 | hosts:
38 | - 'localhost'
39 | password: "{{ mariadb_sst_password }}"
40 | priv: "*.*:RELOAD,PROCESS,LOCK TABLES,BINLOG MONITOR"
41 | delegate_to: "{{ galera_mysql_first_node }}"
42 | run_once: true
43 | when: mariadb_sst_user_plugin == "mysql_native_password"
44 |
45 | - name: mysql_users | create MySQL users
46 | community.mysql.mysql_user:
47 | append_privs: "{{ item.0.append_privs | default('no') }}"
48 | encrypted: "{{ item.0.encrypted | default('no') }}"
49 | host: "{{ item.1 }}"
50 | login_unix_socket: "{{ mariadb_login_unix_socket | default(omit) }}"
51 | name: "{{ item.0.name }}"
52 | password: "{{ item.0.password | default(omit) }}"
53 | plugin: "{{ item.0.plugin | default(omit) }}"
54 | plugin_auth_string: "{{ item.0.plugin_auth_string | default(omit) }}"
55 | plugin_hash_string: "{{ item.0.plugin_hash_string | default(omit) }}"
56 | tls_requires: "{{ item.0.tls_requires | default(omit) }}"
57 | priv: "{{ item.0.priv | default('*.*:USAGE') }}"
58 | state: "{{ item.0.state | default('present') }}"
59 | become: true
60 | no_log: true
61 | delegate_to: "{{ galera_mysql_first_node }}"
62 | run_once: true
63 | with_subelements:
64 | - "{{ (galera_sst_method == 'mariabackup') | ternary( mariadb_mysql_users | union( mariadb_sst_user ), mariadb_mysql_users ) }}"
65 | - "hosts"
66 |
--------------------------------------------------------------------------------
/tasks/oom-score-adjust.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Supplementary configuration file
3 | - name: oom_score_adjust | create folder
4 | ansible.builtin.file:
5 | path: "/etc/systemd/system/mariadb.service.d"
6 | state: "directory"
7 | owner: "root"
8 | group: "root"
9 | mode: "u=rwx,g=rx,o=rx"
10 | notify: "reload systemd daemon"
11 | become: true
12 |
13 | - name: oom_score_adjust | add the overriding file
14 | ansible.builtin.template:
15 | src: "etc/systemd/system/mariadb.service.d/oom-score-adjust.conf.j2"
16 | dest: "/etc/systemd/system/mariadb.service.d/oom-score-adjust.conf"
17 | owner: "root"
18 | group: "root"
19 | mode: "u=rw,g=r,o=r"
20 | notify: "reload systemd daemon"
21 | become: true
22 |
--------------------------------------------------------------------------------
/tasks/redhat.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: redhat | adding mariadb repo
3 | ansible.builtin.yum_repository:
4 | name: "mariadb"
5 | file: "MariaDB"
6 | description: "MariaDB"
7 | baseurl: "{{ mariadb_redhat_repo }}"
8 | gpgkey: "{{ mariadb_redhat_repo_key }}"
9 | gpgcheck: true
10 | become: true
11 | register: "repo_added"
12 | when:
13 | - galera_enable_mariadb_repo | bool
14 |
15 | # fix for conflicting package from appstream
16 | - name: redhat | disable appstream mysql/mariadb modules
17 | ansible.builtin.command:
18 | cmd: "dnf -y module disable mysql mariadb"
19 | changed_when: false
20 | become: true
21 | when:
22 | - ansible_distribution_major_version is version('8', '==')
23 | - galera_enable_mariadb_repo | bool
24 |
25 | - name: redhat | clean dnf metadata (centos8 & fedora)
26 | shell: "dnf clean all && rm -r /var/cache/dnf"
27 | changed_when: false
28 | become: true
29 | when:
30 | - repo_added.changed
31 | - ansible_distribution_major_version is version('8', '>=')
32 | - galera_enable_mariadb_repo | bool
33 |
34 | - name: redhat | installing pre-reqs
35 | ansible.builtin.yum:
36 | name: "{{ mariadb_pre_req_packages }}"
37 | state: "present"
38 | update_cache: true
39 | become: true
40 |
41 | - name: redhat | precreate /etc/my.cnf.d in case we need to add mariadb_config_overrides file
42 | ansible.builtin.file:
43 | path: "/etc/my.cnf.d"
44 | state: "directory"
45 | mode: 0755
46 | become: true
47 | when: mariadb_config_overrides is defined
48 |
49 | - name: redhat | add an overrides file
50 | ansible.builtin.template:
51 | src: "etc/mariadb_overrides.cnf.j2"
52 | dest: "/etc/my.cnf.d/overrides.cnf"
53 | owner: "root"
54 | group: "root"
55 | mode: 0644
56 | become: true
57 | when: mariadb_config_overrides is defined
58 |
59 | - ansible.builtin.import_tasks: mariadb_packages_install.yml
60 |
61 | - name: redhat | remove migrated-from-my.cnf-settings.conf that is causing MariaDB to not start
62 | ansible.builtin.file:
63 | path: "/etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf"
64 | state: "absent"
65 | become: true
66 | notify: reload systemd daemon
67 |
68 | - name: redhat | ensuring mariadb mysql is enabled on boot
69 | ansible.builtin.service:
70 | name: "mariadb"
71 | enabled: true
72 | become: true
73 |
--------------------------------------------------------------------------------
/tasks/setup_cluster.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Mark cluster node unconfigured when setting need cluster shutdown
3 | - name: setup_cluster | mark galera cluster node unconfigured
4 | ansible.builtin.file:
5 | path: "/etc/galera_cluster_configured"
6 | state: "absent"
7 | become: true
8 | when: galera_reconfigure_galera
9 |
10 | - name: setup_cluster | checking if galera cluster already configured
11 | ansible.builtin.stat:
12 | path: "/etc/galera_cluster_configured"
13 | register: "galera_cluster_configured"
14 |
15 | # Configure common settings for mariadb and galera
16 | - name: setup_cluster | create TLS certificates directory
17 | ansible.builtin.file:
18 | path: "{{ mariadb_certificates_dir }}"
19 | state: "directory"
20 | owner: "mysql"
21 | group: "mysql"
22 | mode: "0500"
23 | become: true
24 | when:
25 | - mariadb_tls_files is defined
26 | - mariadb_tls_files | length == 3
27 |
28 | - name: setup_cluster | copy TLS CA cert, server cert & private key
29 | ansible.builtin.copy:
30 | content: "{{ item.value.content }}"
31 | dest: "{{ mariadb_certificates_dir }}/{{ item.value.name }}"
32 | owner: "mysql"
33 | group: "mysql"
34 | mode: "0400"
35 | backup: true
36 | with_dict: "{{ mariadb_tls_files }}"
37 | become: true
38 | no_log: true
39 | register: _mariadb_galera_cluster_newcerts
40 | when:
41 | - mariadb_tls_files is defined
42 | - mariadb_tls_files | length == 3
43 |
44 | - name: Merge all wsrep_provider_options to be templated later
45 | block:
46 | - name: WSREP ist.recv_
47 | set_fact:
48 | galera_extra_wsrep_provider_options: >
49 | {{
50 | galera_extra_wsrep_provider_options | combine({
51 | 'ist.recv_addr': galera_ist_recv_addr + ":" + galera_ist_recv_addr_port|string,
52 | 'ist.recv_bind': galera_ist_recv_bind
53 | })
54 | }}
55 | - name: WSREP TLS encryption settings
56 | set_fact:
57 | galera_extra_wsrep_provider_options: >
58 | {{
59 | galera_extra_wsrep_provider_options | combine({
60 | 'socket.ssl_cert': mariadb_certificates_dir + "/" + mariadb_tls_files.server_cert.name,
61 | 'socket.ssl_key': mariadb_certificates_dir + "/" + mariadb_tls_files.server_key.name,
62 | 'socket.ssl_ca': mariadb_certificates_dir + "/" + mariadb_tls_files.ca_cert.name
63 | })
64 | }}
65 | when:
66 | - mariadb_tls_files
67 | - mariadb_tls_files|length == 3
68 | - galera_wsrep_tls_enabled
69 | - name: Add galera_use_gmcast_segment if present
70 | set_fact:
71 | galera_extra_wsrep_provider_options: "{{ galera_extra_wsrep_provider_options | combine({ 'gmcast.segment': hostvars[inventory_hostname]['galera_gmcast_segment']|int }) }}"
72 | when:
73 | - galera_use_gmcast_segment
74 | - ('galera_gmcast_segment' in hostvars[inventory_hostname])
75 | - name: Show all galera_extra_wsrep_provider_options
76 | ansible.builtin.debug:
77 | var: galera_extra_wsrep_provider_options
78 | verbosity: 3
79 |
80 | - name: setup_cluster | configuring settings for mariadb and galera
81 | ansible.builtin.template:
82 | src: "{{ file.name }}.j2"
83 | dest: "/{{ file.name }}"
84 | mode: "{{ file.mode |default ('0644') }}"
85 | follow: true
86 | become: true
87 | register: "_mariadb_galera_cluster_reconfigured"
88 | loop: "{{ mariadb_confs }}"
89 | loop_control:
90 | loop_var: file
91 |
92 | - name: setup_cluster | cluster rolling restart - apply config changes (first node)
93 | ansible.builtin.include_tasks: manage_node_state.yml
94 | vars:
95 | mariadb_systemd_service_state: "restarted"
96 | with_items: "{{ galera_mysql_first_node }}"
97 | when: >
98 | galera_cluster_configured.stat.exists and
99 | (_mariadb_galera_cluster_reconfigured.changed or
100 | _mariadb_galera_cluster_newcerts.changed)
101 |
102 | - name: setup_cluster | cluster rolling restart - apply config changes (other nodes)
103 | ansible.builtin.include_tasks: manage_node_state.yml
104 | vars:
105 | mariadb_systemd_service_state: "restarted"
106 | with_items: "{{ ansible_play_hosts | difference(galera_mysql_first_node) }}"
107 | when: >
108 | galera_cluster_configured.stat.exists and
109 | (_mariadb_galera_cluster_reconfigured.changed or
110 | _mariadb_galera_cluster_newcerts.changed)
111 |
112 | # Offline (re)configuration of glaera cluster settings - cluster bootstrap
113 | - name: setup_cluster | cluster bootstrap - stopping mysql to (re)configure cluster (other nodes)
114 | ansible.builtin.include_tasks: manage_node_state.yml
115 | vars:
116 | mariadb_systemd_service_state: "stopped"
117 | with_items: "{{ ansible_play_hosts | difference(galera_mysql_first_node) }}"
118 | when: >
119 | not galera_cluster_configured.stat.exists
120 |
121 | - name: setup_cluster | cluster bootstrap - stopping mysql to (re)configure cluster (first node)
122 | ansible.builtin.include_tasks: manage_node_state.yml
123 | vars:
124 | mariadb_systemd_service_state: "stopped"
125 | with_items: "{{ galera_mysql_first_node }}"
126 | when: >
127 | not galera_cluster_configured.stat.exists
128 |
129 | - name: setup_cluster | cluster bootstrap - killing lingering mysql processes to ensure mysql is stopped
130 | ansible.builtin.command: "pkill {{ mariadb_systemd_service_name }}" # noqa ignore-errors
131 | become: true
132 | ignore_errors: true
133 | when: not galera_cluster_configured.stat.exists
134 |
135 | - name: setup_cluster | cluster bootstrap - configuring temp galera config for first node
136 | ansible.builtin.template:
137 | src: "{{ item }}.temp.j2"
138 | dest: "/{{ item }}"
139 | mode: "0644"
140 | become: true
141 | loop: "{{ mariadb_temp_confs }}"
142 | when: >
143 | not galera_cluster_configured.stat.exists and
144 | inventory_hostname == galera_mysql_first_node
145 |
146 | - name: setup_cluster | cluster bootstrap - bootstrapping first node
147 | ansible.builtin.command: "/usr/bin/galera_new_cluster"
148 | become: true
149 | when: >
150 | not galera_cluster_configured.stat.exists and
151 | inventory_hostname == galera_mysql_first_node
152 |
153 | - name: setup_cluster | cluster bootstrap - ensure first node is fully started before joining other nodes
154 | ansible.builtin.include_tasks: manage_node_state.yml
155 | vars:
156 | mariadb_systemd_service_state: "started"
157 | with_items: "{{ galera_mysql_first_node }}"
158 | when: >
159 | not galera_cluster_configured.stat.exists
160 |
161 | - name: setup_cluster | cluster bootstrap - joining galera cluster
162 | include_tasks: manage_node_state.yml
163 | vars:
164 | mariadb_systemd_service_state: "started"
165 | with_items: "{{ ansible_play_hosts | difference(galera_mysql_first_node) }}"
166 | when: >
167 | not galera_cluster_configured.stat.exists
168 |
169 | - name: setup_cluster | cluster bootstrap - configuring final galera config for first node
170 | ansible.builtin.template:
171 | src: "{{ file.name }}.j2"
172 | dest: "/{{ file.name }}"
173 | mode: "{{ file.mode |default ('0644') }}"
174 | loop: "{{ mariadb_confs }}"
175 | loop_control:
176 | loop_var: file
177 | become: true
178 | when: >
179 | not galera_cluster_configured.stat.exists and
180 | inventory_hostname == galera_mysql_first_node
181 |
182 | - name: setup_cluster | cluster bootstrap - restarting first node with final galera config
183 | include_tasks: manage_node_state.yml
184 | vars:
185 | mariadb_systemd_service_state: "restarted"
186 | with_items: "{{ galera_mysql_first_node }}"
187 | when: >
188 | not galera_cluster_configured.stat.exists
189 |
190 | - name: setup_cluster | cluster bootstrap - marking node as configured for galera cluster
191 | ansible.builtin.file:
192 | path: "/etc/galera_cluster_configured"
193 | state: "touch"
194 | mode: "0644"
195 | become: true
196 | when: not galera_cluster_configured.stat.exists
197 |
--------------------------------------------------------------------------------
/tasks/system_performance_tuning.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - ansible.builtin.import_tasks: max-open-files.yml
3 | when: >
4 | ansible_service_mgr == "systemd" and
5 | mariadb_max_open_files != 0
6 |
7 | - ansible.builtin.import_tasks: oom-score-adjust.yml
8 | when: >
9 | ansible_service_mgr == "systemd" and
10 | mariadb_oom_score_adjust != 0
11 |
12 | - ansible.builtin.import_tasks: timeout-start-sec.yml
13 | when: >
14 | ansible_service_mgr == "systemd" and
15 | mariadb_timeout_start_sec != 0
16 |
17 | # Borrowed from percona xtradb cluster ansible role:
18 | # https://github.com/cdelgehier/ansible-role-XtraDB-Cluster/blob/master/tasks/bootstrap.yml
19 | # Many thanks to Cedric DELGEHIER
20 | - name: system_perfromance_tuning | configure swappiness
21 | ansible.posix.sysctl:
22 | name: "vm.swappiness"
23 | value: "{{ mariadb_swappiness }}"
24 | state: "present"
25 | become: true
26 | when:
27 | - mariadb_swappiness != 'auto'
28 | - "not (
29 | (ansible_virtualization_role == 'guest')
30 | and (ansible_virtualization_type == 'lxc')
31 | )"
32 |
--------------------------------------------------------------------------------
/tasks/timeout-start-sec.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Supplementary configuration file
3 | - name: timeout-start-sec | Create folder
4 | ansible.builtin.file:
5 | path: "/etc/systemd/system/mariadb.service.d"
6 | state: "directory"
7 | recurse: true
8 | owner: "root"
9 | group: "root"
10 | mode: "u=rwx,g=rx,o=rx"
11 | notify: "reload systemd daemon"
12 | become: true
13 |
14 | - name: timeout-start-sec | Add the overriding file
15 | ansible.builtin.template:
16 | src: "etc/systemd/system/mariadb.service.d/timeout-start-sec.conf.j2"
17 | dest: "/etc/systemd/system/mariadb.service.d/timeout-start-sec.conf"
18 | owner: "root"
19 | group: "root"
20 | mode: "u=rw,g=r,o=r"
21 | notify: "reload systemd daemon"
22 | become: true
23 |
--------------------------------------------------------------------------------
/tasks/unconfigure_cluster.yml:
--------------------------------------------------------------------------------
1 | ---
2 |
--------------------------------------------------------------------------------
/templates/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrlesmithjr/ansible-mariadb-galera-cluster/128a25b5e74c3544cfb0b922ccb7b7b29c7e0470/templates/.gitkeep
--------------------------------------------------------------------------------
/templates/etc/apt/preferences.d/mariadb.j2:
--------------------------------------------------------------------------------
1 | Package: mariadb-*
2 | Pin: origin {{ mariadb_debian_repo_pin }}
3 | Pin-Priority: {{ mariadb_debian_repo_pin_priority }}
4 |
--------------------------------------------------------------------------------
/templates/etc/mariadb_overrides.cnf.j2:
--------------------------------------------------------------------------------
1 |
2 | {% for group, settings in mariadb_config_overrides.items() %}
3 |
4 | [{{ group }}]
5 | {% for key, value in settings.items() %}
6 | {{ key }} = {{ value }}
7 | {% endfor %}
8 |
9 | {% endfor %}
10 |
--------------------------------------------------------------------------------
/templates/etc/my.cnf.d/server.cnf.j2:
--------------------------------------------------------------------------------
1 | [mysqld]
2 | binlog_format=ROW
3 | default_storage_engine=InnoDB
4 | innodb_autoinc_lock_mode=2
5 |
6 | #
7 | # Allow server to accept connections on this interface
8 | #
9 | bind-address={{ mariadb_bind_address }}
10 |
11 | {% if mariadb_charset_server | default('auto') != 'auto' %}
12 | character-set-server = {{ mariadb_charset_server }}
13 | init-connect = 'SET NAMES {{ mariadb_charset_server }}'
14 | {% endif %}
15 | {% if mariadb_collation_server | default('auto') != 'auto' %}
16 | collation-server = {{ mariadb_collation_server }}
17 | {% endif %}
18 |
19 | {% if mariadb_innodb_buffer_pool_size | default('auto') != "auto" %}
20 | innodb_buffer_pool_size = {{ mariadb_innodb_buffer_pool_size }}
21 | {% endif %}
22 | {% if mariadb_innodb_read_io_threads | default('auto') != "auto" %}
23 | innodb_read_io_threads = {{ mariadb_innodb_read_io_threads }}
24 | {% endif %}
25 | {% if mariadb_innodb_write_io_threads | default('auto') != "auto" %}
26 | innodb_write_io_threads = {{ mariadb_innodb_write_io_threads }}
27 | {% endif %}
28 | {% if mariadb_max_connections | default('auto') != "auto" %}
29 | max_connections = {{ mariadb_max_connections }}
30 | {% endif %}
31 | {% if mariadb_slow_query_log_enabled %}
32 | slow_query_log
33 | {% endif %}
34 | {% if mariadb_long_query_time | default('auto') != "auto" %}
35 | long_query_time = {{ mariadb_long_query_time }}
36 | {% endif %}
37 |
38 | {% if mariadb_tls_files and mariadb_tls_files|length == 3 %}
39 | ssl_ca = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.ca_cert.name }}
40 | ssl_cert = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.server_cert.name }}
41 | ssl_key = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.server_key.name }}
42 | {% endif %}
43 |
44 | [galera]
45 | wsrep_on=ON
46 | wsrep_node_name={{ ansible_hostname }}
47 | wsrep_provider={{ galera_wsrep_provider }}
48 | wsrep_cluster_name="{{ galera_cluster_name }}"
49 | {% set _galera_cluster_node_addresses = [] %}
50 | {% for node in galera_cluster_nodes %}
51 | {% set _ = _galera_cluster_node_addresses.append( hostvars[node]['galera_cluster_bind_address'] | default(hostvars[node]['ansible_' ~ galera_cluster_bind_interface]['ipv4']['address']) | mandatory ) %}
52 | {% endfor %}
53 | wsrep_cluster_address="{{ 'gcomm://' ~ _galera_cluster_node_addresses | map('ansible.utils.ipwrap') | list | join(',') }}"
54 | # To start failed cluster comment out above and uncomment below...Once cluster is started revert changes and restart mysql on main node where change was made
55 | #wsrep_cluster_address="gcomm://"
56 |
57 | wsrep_sst_method={{ galera_sst_method }}
58 | {% if galera_sst_method == 'mariabackup' %}
59 | wsrep_sst_auth="{{ mariadb_sst_username }}:{{ mariadb_sst_password }}"
60 | {% endif %}
61 |
62 | {% if galera_wsrep_slave_threads == "auto" %}
63 | wsrep_slave_threads={{ 1 if (ansible_processor_vcpus <= 1) else (ansible_processor_vcpus - 1) }}
64 | {% else %}
65 | wsrep_slave_threads={{ galera_wsrep_slave_threads }}
66 | {% endif %}
67 | #innodb_flush_log_at_trx_commit=0
68 |
69 | {% if galera_enable_galera_monitoring_script %}
70 | wsrep_notify_cmd='{{ galera_monitor_script_path }}/{{ galera_monitor_script_name }}'
71 | {% endif %}
72 |
73 | wsrep_node_address="{{ galera_wsrep_node_address }}"
74 |
75 | wsrep_provider_options = "{% for item in galera_extra_wsrep_provider_options %}{% set _key = item.split(': ')[0] %}{% set _val = galera_extra_wsrep_provider_options[_key] %}{{ _key }} = {{ _val }}{% if not loop.last %}; {% endif %}{% endfor %}"
76 |
77 | [sst]
78 | {% if mariadb_tls_files and mariadb_tls_files|length == 3 and galera_sst_tls_enabled %}
79 | encrypt=3
80 | tcert = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.server_cert.name }}
81 | tkey = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.server_key.name }}
82 | {% endif %}
83 |
--------------------------------------------------------------------------------
/templates/etc/my.cnf.d/server.cnf.temp.j2:
--------------------------------------------------------------------------------
1 | [mysqld]
2 | binlog_format=ROW
3 | default_storage_engine=InnoDB
4 | innodb_autoinc_lock_mode=2
5 |
6 | #
7 | # Allow server to accept connections on this interface
8 | #
9 | bind-address={{ mariadb_bind_address }}
10 |
11 | {% if mariadb_charset_server | default('auto') != 'auto' %}
12 | character-set-server = {{ mariadb_charset_server }}
13 | init-connect = 'SET NAMES {{ mariadb_charset_server }}'
14 | {% endif %}
15 | {% if mariadb_collation_server | default('auto') != 'auto' %}
16 | collation-server = {{ mariadb_collation_server }}
17 | {% endif %}
18 |
19 | {% if mariadb_innodb_buffer_pool_size | default('auto') != "auto" %}
20 | innodb_buffer_pool_size = {{ mariadb_innodb_buffer_pool_size }}
21 | {% endif %}
22 | {% if mariadb_innodb_read_io_threads | default('auto') != "auto" %}
23 | innodb_read_io_threads = {{ mariadb_innodb_read_io_threads }}
24 | {% endif %}
25 | {% if mariadb_innodb_write_io_threads | default('auto') != "auto" %}
26 | innodb_write_io_threads = {{ mariadb_innodb_write_io_threads }}
27 | {% endif %}
28 | {% if mariadb_max_connections | default('auto') != "auto" %}
29 | max_connections = {{ mariadb_max_connections }}
30 | {% endif %}
31 | {% if mariadb_slow_query_log_enabled %}
32 | slow_query_log
33 | {% endif %}
34 | {% if mariadb_long_query_time | default('auto') != "auto" %}
35 | long_query_time = {{ mariadb_long_query_time }}
36 | {% endif %}
37 |
38 | {% if mariadb_tls_files and mariadb_tls_files|length == 3 %}
39 | ssl_ca = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.ca_cert.name }}
40 | ssl_cert = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.server_cert.name }}
41 | ssl_key = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.server_key.name }}
42 | {% endif %}
43 |
44 | [galera]
45 | wsrep_on=ON
46 | wsrep_node_name={{ ansible_hostname }}
47 | wsrep_provider={{ galera_wsrep_provider }}
48 | wsrep_cluster_name="{{ galera_cluster_name }}"
49 | {% set _galera_cluster_node_addresses = [] %}
50 | {% for node in galera_cluster_nodes %}
51 | {% set _ = _galera_cluster_node_addresses.append( hostvars[node]['galera_cluster_bind_address'] | default(hostvars[node]['ansible_' ~ galera_cluster_bind_interface]['ipv4']['address']) | mandatory ) %}
52 | {% endfor %}
53 | #wsrep_cluster_address="{{ 'gcomm://' ~ _galera_cluster_node_addresses | map('ansible.utils.ipwrap') | list | join(',') }}"
54 | # To start failed cluster comment out above and uncomment below...Once cluster is started revert changes and restart mysql on main node where change was made
55 | wsrep_cluster_address="gcomm://"
56 |
57 | wsrep_sst_method={{ galera_sst_method }}
58 | {% if galera_sst_method == 'mariabackup' %}
59 | wsrep_sst_auth="{{ mariadb_sst_username }}:{{ mariadb_sst_password }}"
60 | {% endif %}
61 |
62 | {% if galera_wsrep_slave_threads == "auto" %}
63 | wsrep_slave_threads={{ 1 if (ansible_processor_vcpus <= 1) else (ansible_processor_vcpus - 1) }}
64 | {% else %}
65 | wsrep_slave_threads={{ galera_wsrep_slave_threads }}
66 | {% endif %}
67 | #innodb_flush_log_at_trx_commit=0
68 |
69 | {% if galera_enable_galera_monitoring_script %}
70 | wsrep_notify_cmd='{{ galera_monitor_script_path }}/{{ galera_monitor_script_name }}'
71 | {% endif %}
72 |
73 | wsrep_node_address="{{ galera_wsrep_node_address }}"
74 |
75 | wsrep_provider_options = "{% for item in galera_extra_wsrep_provider_options %}{% set _key = item.split(': ')[0] %}{% set _val = galera_extra_wsrep_provider_options[_key] %}{{ _key }} = {{ _val }}{% if not loop.last %}; {% endif %}{% endfor %}"
76 |
77 | [sst]
78 | {% if mariadb_tls_files and mariadb_tls_files|length == 3 and galera_sst_tls_enabled %}
79 | encrypt=3
80 | tcert = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.server_cert.name }}
81 | tkey = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.server_key.name }}
82 | {% endif %}
83 |
--------------------------------------------------------------------------------
/templates/etc/mysql/conf.d/client.cnf.j2:
--------------------------------------------------------------------------------
1 | [client]
2 | default-character-set = {{ mariadb_charset_client }}
3 |
--------------------------------------------------------------------------------
/templates/etc/mysql/conf.d/galera.cnf.j2:
--------------------------------------------------------------------------------
1 | [mysqld]
2 | binlog_format=ROW
3 | default_storage_engine=InnoDB
4 | innodb_autoinc_lock_mode=2
5 |
6 | #
7 | # Allow server to accept connections on this interface
8 | #
9 | bind-address={{ mariadb_bind_address }}
10 |
11 | {% if mariadb_charset_server | default('auto') != 'auto' %}
12 | character-set-server = {{ mariadb_charset_server }}
13 | init-connect = 'SET NAMES {{ mariadb_charset_server }}'
14 | {% endif %}
15 | {% if mariadb_collation_server | default('auto') != 'auto' %}
16 | collation-server = {{ mariadb_collation_server }}
17 | {% endif %}
18 |
19 | {% if mariadb_innodb_buffer_pool_size | default('auto') != "auto" %}
20 | innodb_buffer_pool_size = {{ mariadb_innodb_buffer_pool_size }}
21 | {% endif %}
22 | {% if mariadb_innodb_read_io_threads | default('auto') != "auto" %}
23 | innodb_read_io_threads = {{ mariadb_innodb_read_io_threads }}
24 | {% endif %}
25 | {% if mariadb_innodb_write_io_threads | default('auto') != "auto" %}
26 | innodb_write_io_threads = {{ mariadb_innodb_write_io_threads }}
27 | {% endif %}
28 | {% if mariadb_max_connections | default('auto') != "auto" %}
29 | max_connections = {{ mariadb_max_connections }}
30 | {% endif %}
31 | {% if mariadb_slow_query_log_enabled %}
32 | slow_query_log
33 | {% endif %}
34 | {% if mariadb_long_query_time | default('auto') != "auto" %}
35 | long_query_time = {{ mariadb_long_query_time }}
36 | {% endif %}
37 |
38 | {% if mariadb_tls_files and mariadb_tls_files|length == 3 %}
39 | ssl_ca = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.ca_cert.name }}
40 | ssl_cert = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.server_cert.name }}
41 | ssl_key = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.server_key.name }}
42 | {% endif %}
43 |
44 | [galera]
45 | wsrep_on=ON
46 | wsrep_node_name={{ ansible_hostname }}
47 | wsrep_provider={{ galera_wsrep_provider }}
48 | wsrep_cluster_name="{{ galera_cluster_name }}"
49 | {% set _galera_cluster_node_addresses = [] %}
50 | {% for node in galera_cluster_nodes %}
51 | {% set _ = _galera_cluster_node_addresses.append( hostvars[node][galera_cluster_bind_address] | default(hostvars[node]['ansible_' ~ galera_cluster_bind_interface]['ipv4']['address']) | mandatory ) %}
52 | {% endfor %}
53 | wsrep_cluster_address="{{ 'gcomm://' ~ _galera_cluster_node_addresses | map('ansible.utils.ipwrap') | list | join(',') }}"
54 | # To start failed cluster comment out above and uncomment below...Once cluster is started revert changes and restart mysql on main node where change was made
55 | #wsrep_cluster_address="gcomm://"
56 |
57 | wsrep_sst_method={{ galera_sst_method }}
58 | {% if galera_sst_method == 'mariabackup' %}
59 | wsrep_sst_auth="{{ mariadb_sst_username }}:{{ mariadb_sst_password }}"
60 | {% endif %}
61 |
62 | {% if galera_wsrep_slave_threads == "auto" %}
63 | wsrep_slave_threads={{ 1 if (ansible_processor_vcpus <= 1) else (ansible_processor_vcpus - 1) }}
64 | {% else %}
65 | wsrep_slave_threads={{ galera_wsrep_slave_threads }}
66 | {% endif %}
67 | #innodb_flush_log_at_trx_commit=0
68 |
69 | {% if galera_enable_galera_monitoring_script %}
70 | wsrep_notify_cmd='{{ galera_monitor_script_path }}/{{ galera_monitor_script_name }}'
71 | {% endif %}
72 |
73 | wsrep_node_address="{{ galera_wsrep_node_address }}"
74 |
75 | wsrep_provider_options = "{% for item in galera_extra_wsrep_provider_options %}{% set _key = item.split(': ')[0] %}{% set _val = galera_extra_wsrep_provider_options[_key] %}{{ _key }} = {{ _val }}{% if not loop.last %}; {% endif %}{% endfor %}"
76 |
77 | [sst]
78 | {% if mariadb_tls_files and mariadb_tls_files|length == 3 and galera_sst_tls_enabled %}
79 | encrypt=3
80 | tcert = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.server_cert.name }}
81 | tkey = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.server_key.name }}
82 | {% endif %}
83 |
--------------------------------------------------------------------------------
/templates/etc/mysql/conf.d/galera.cnf.temp.j2:
--------------------------------------------------------------------------------
1 | [mysqld]
2 | binlog_format=ROW
3 | default_storage_engine=InnoDB
4 | innodb_autoinc_lock_mode=2
5 |
6 | #
7 | # Allow server to accept connections on this interface
8 | #
9 | bind-address={{ mariadb_bind_address }}
10 |
11 | {% if mariadb_charset_server | default('auto') != 'auto' %}
12 | character-set-server = {{ mariadb_charset_server }}
13 | init-connect = 'SET NAMES {{ mariadb_charset_server }}'
14 | {% endif %}
15 | {% if mariadb_collation_server | default('auto') != 'auto' %}
16 | collation-server = {{ mariadb_collation_server }}
17 | {% endif %}
18 |
19 | {% if mariadb_innodb_buffer_pool_size | default('auto') != "auto" %}
20 | innodb_buffer_pool_size = {{ mariadb_innodb_buffer_pool_size }}
21 | {% endif %}
22 | {% if mariadb_innodb_read_io_threads | default('auto') != "auto" %}
23 | innodb_read_io_threads = {{ mariadb_innodb_read_io_threads }}
24 | {% endif %}
25 | {% if mariadb_innodb_write_io_threads | default('auto') != "auto" %}
26 | innodb_write_io_threads = {{ mariadb_innodb_write_io_threads }}
27 | {% endif %}
28 | {% if mariadb_max_connections | default('auto') != "auto" %}
29 | max_connections = {{ mariadb_max_connections }}
30 | {% endif %}
31 | {% if mariadb_slow_query_log_enabled %}
32 | slow_query_log
33 | {% endif %}
34 | {% if mariadb_long_query_time | default('auto') != "auto" %}
35 | long_query_time = {{ mariadb_long_query_time }}
36 | {% endif %}
37 |
38 | {% if mariadb_tls_files and mariadb_tls_files|length == 3 %}
39 | ssl_ca = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.ca_cert.name }}
40 | ssl_cert = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.server_cert.name }}
41 | ssl_key = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.server_key.name }}
42 | {% endif %}
43 |
44 | [galera]
45 | wsrep_on=ON
46 | wsrep_node_name={{ ansible_hostname }}
47 | wsrep_provider={{ galera_wsrep_provider }}
48 | wsrep_cluster_name="{{ galera_cluster_name }}"
49 | {% set _galera_cluster_node_addresses = [] %}
50 | {% for node in galera_cluster_nodes %}
51 | {% set _ = _galera_cluster_node_addresses.append( hostvars[node][galera_cluster_bind_address] | default(hostvars[node]['ansible_' ~ galera_cluster_bind_interface]['ipv4']['address']) | mandatory ) %}
52 | {% endfor %}
53 | #wsrep_cluster_address="{{ 'gcomm://' ~ _galera_cluster_node_addresses | map('ansible.utils.ipwrap') | list | join(',') }}"
54 | # To start failed cluster comment out above and uncomment below...Once cluster is started revert changes and restart mysql on main node where change was made
55 | wsrep_cluster_address="gcomm://"
56 |
57 | wsrep_sst_method={{ galera_sst_method }}
58 | {% if galera_sst_method == 'mariabackup' %}
59 | wsrep_sst_auth="{{ mariadb_sst_username }}:{{ mariadb_sst_password }}"
60 | {% endif %}
61 |
62 | {% if galera_wsrep_slave_threads == "auto" %}
63 | wsrep_slave_threads={{ 1 if (ansible_processor_vcpus <= 1) else (ansible_processor_vcpus - 1) }}
64 | {% else %}
65 | wsrep_slave_threads={{ galera_wsrep_slave_threads }}
66 | {% endif %}
67 | #innodb_flush_log_at_trx_commit=0
68 |
69 | {% if galera_enable_galera_monitoring_script %}
70 | wsrep_notify_cmd='{{ galera_monitor_script_path }}/{{ galera_monitor_script_name }}'
71 | {% endif %}
72 |
73 | wsrep_provider_options="ist.recv_addr={{ galera_ist_recv_addr }}:{{ galera_ist_recv_addr_port }}"
74 | wsrep_provider_options="ist.recv_bind={{ galera_ist_recv_bind }}"
75 | wsrep_node_address="{{ galera_wsrep_node_address }}"
76 |
77 | {% if galera_extra_wsrep_provider_options is defined %}
78 | wsrep_provider_options = "{% for item in galera_extra_wsrep_provider_options %}{% set _key = item.split(': ')[0] %}{% set _val = galera_extra_wsrep_provider_options[_key] %}{{ _key }} = {{ _val }}{% if not loop.last %}; {% endif %}{% endfor %}"
79 | {% endif %}
80 |
81 | [sst]
82 | {% if mariadb_tls_files and mariadb_tls_files|length == 3 and galera_sst_tls_enabled %}
83 | encrypt=3
84 | tcert = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.server_cert.name }}
85 | tkey = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.server_key.name }}
86 | {% endif %}
87 |
--------------------------------------------------------------------------------
/templates/etc/mysql/debian.cnf.j2:
--------------------------------------------------------------------------------
1 | {% if ansible_distribution | lower == 'debian' and ansible_distribution_major_version | int >= 11 %}
2 | # THIS FILE IS OBSOLETE. STOP USING IT IF POSSIBLE.
3 | # This file exists only for backwards compatibility for
4 | # tools that run '--defaults-file=/etc/mysql/debian.cnf'
5 | # and have root level access to the local filesystem.
6 | # With those permissions one can run 'mariadb' directly
7 | # anyway thanks to unix socket authentication and hence
8 | # this file is useless. See package README for more info.
9 |
10 | {% endif %}
11 | # {{ ansible_managed }}
12 | # Automatically generated for Debian scripts. DO NOT TOUCH! (opps)
13 | [client]
14 | host = localhost
15 | {% if ((ansible_distribution | lower == 'debian' and ansible_distribution_major_version | int >= 11) or
16 | (ansible_distribution | lower == 'ubuntu' and ansible_distribution_major_version | int >= 20)) %}
17 | user = root
18 | {% else %}
19 | user = debian-sys-maint
20 | {% endif %}
21 | password = {{ mariadb_mysql_root_password }}
22 | socket = {{ mariadb_login_unix_socket }}
23 | [mysql_upgrade]
24 | host = localhost
25 | {% if ((ansible_distribution | lower == 'debian' and ansible_distribution_major_version | int >= 11) or
26 | (ansible_distribution | lower == 'ubuntu' and ansible_distribution_major_version | int >= 20)) %}
27 | user = root
28 | {% else %}
29 | user = debian-sys-maint
30 | {% endif %}
31 | password = {{ mariadb_mysql_root_password }}
32 | socket = {{ mariadb_login_unix_socket }}
33 | basedir = /usr
34 |
--------------------------------------------------------------------------------
/templates/etc/mysql/galeranotify.py2.j2:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | #
3 | # Script to send email notifications when a change in Galera cluster membership
4 | # occurs.
5 | #
6 | # Complies with http://www.codership.com/wiki/doku.php?id=notification_command
7 | #
8 | # Author: Gabe Guillen
9 | # Version: 1.5
10 | # Release: 3/5/2015
11 | # Use at your own risk. No warranties expressed or implied.
12 | #
13 |
14 | # {{ ansible_managed }}
15 |
16 | import os
17 | import sys
18 | import getopt
19 |
20 | import smtplib
21 |
22 | try: from email.mime.text import MIMEText
23 | except ImportError:
24 | # Python 2.4 (CentOS 5.x)
25 | from email.MIMEText import MIMEText
26 |
27 | import socket
28 | import email.utils
29 |
30 | # Change this to some value if you don't want your server hostname to show in
31 | # the notification emails
32 | THIS_SERVER = socket.gethostname()
33 |
34 | # Server hostname or IP address
35 | SMTP_SERVER = '{{ galera_notify_smtp_server }}'
36 | SMTP_PORT = {{ galera_notify_smtp_port }}
37 |
38 | # Set to True if you need SMTP over SSL
39 | SMTP_SSL = {{ galera_notify_smtp_ssl }}
40 |
41 | # Set to True if you need SMTP over TLS
42 | SMTP_STARTTLS = {{ galera_notify_smtp_starttls }}
43 |
44 | # Set to True if you need to authenticate to your SMTP server
45 | SMTP_AUTH = {{ galera_notify_smtp_auth }}
46 | # Fill in authorization information here if True above
47 | SMTP_USERNAME = '{{ galera_notify_smtp_username }}'
48 | SMTP_PASSWORD = '{{ galera_notify_smtp_password }}'
49 |
50 | # Takes a single sender
51 | MAIL_FROM = '{{ galera_notify_mail_from }}'
52 | # Takes a list of recipients
53 | # Need Date in Header for SMTP RFC Compliance
54 | DATE = email.utils.formatdate()
55 | MAIL_TO = ['{{ galera_notify_mail_to }}']
56 |
57 | # Edit below at your own risk
58 | ################################################################################
59 | def main(argv):
60 | str_status = ''
61 | str_uuid = ''
62 | str_primary = ''
63 | str_members = ''
64 | str_index = ''
65 | message = ''
66 |
67 | usage = "Usage: " + os.path.basename(sys.argv[0]) + " --status "
68 | usage += " --uuid --primary --members --index "
70 |
71 | try:
72 | opts, args = getopt.getopt(argv, "h", ["status=","uuid=",'primary=','members=','index='])
73 | except getopt.GetoptError:
74 | print usage
75 | sys.exit(2)
76 |
77 | if(len(opts) > 0):
78 | message_obj = GaleraStatus(THIS_SERVER)
79 |
80 | for opt, arg in opts:
81 | if opt == '-h':
82 | print usage
83 | sys.exit()
84 | elif opt in ("--status"):
85 | message_obj.set_status(arg)
86 | elif opt in ("--uuid"):
87 | message_obj.set_uuid(arg)
88 | elif opt in ("--primary"):
89 | message_obj.set_primary(arg)
90 | elif opt in ("--members"):
91 | message_obj.set_members(arg)
92 | elif opt in ("--index"):
93 | message_obj.set_index(arg)
94 | try:
95 | send_notification(MAIL_FROM, MAIL_TO, 'Galera Notification: ' + THIS_SERVER, DATE,
96 | str(message_obj), SMTP_SERVER, SMTP_PORT, SMTP_SSL, SMTP_STARTTLS, SMTP_AUTH,
97 | SMTP_USERNAME, SMTP_PASSWORD)
98 | except Exception, e:
99 | print "Unable to send notification: %s" % e
100 | sys.exit(1)
101 | else:
102 | print usage
103 | sys.exit(2)
104 |
105 | sys.exit(0)
106 |
107 | def send_notification(from_email, to_email, subject, date, message, smtp_server,
108 | smtp_port, use_ssl, use_starttls, use_auth, smtp_user, smtp_pass):
109 | msg = MIMEText(message)
110 |
111 | msg['From'] = from_email
112 | msg['To'] = ', '.join(to_email)
113 | msg['Subject'] = subject
114 | msg['Date'] = date
115 | msg['Message-ID'] = email.utils.make_msgid()
116 |
117 | if(use_ssl):
118 | mailer = smtplib.SMTP_SSL(smtp_server, smtp_port)
119 | else:
120 | mailer = smtplib.SMTP(smtp_server, smtp_port)
121 |
122 | if(use_starttls):
123 | mailer.starttls()
124 |
125 | if(use_auth):
126 | mailer.login(smtp_user, smtp_pass)
127 |
128 | mailer.sendmail(from_email, to_email, msg.as_string())
129 | mailer.close()
130 |
131 | class GaleraStatus:
132 | def __init__(self, server):
133 | self._server = server
134 | self._status = ""
135 | self._uuid = ""
136 | self._primary = ""
137 | self._members = ""
138 | self._index = ""
139 | self._count = 0
140 |
141 | def set_status(self, status):
142 | self._status = status
143 | self._count += 1
144 |
145 | def set_uuid(self, uuid):
146 | self._uuid = uuid
147 | self._count += 1
148 |
149 | def set_primary(self, primary):
150 | self._primary = primary.capitalize()
151 | self._count += 1
152 |
153 | def set_members(self, members):
154 | self._members = members.split(',')
155 | self._count += 1
156 |
157 | def set_index(self, index):
158 | self._index = index
159 | self._count += 1
160 |
161 | def __str__(self):
162 | message = "Galera running on " + self._server + " has reported the following"
163 | message += " cluster membership change"
164 |
165 | if(self._count > 1):
166 | message += "s"
167 |
168 | message += ":\n\n"
169 |
170 | if(self._status):
171 | message += "Status of this node: " + self._status + "\n\n"
172 |
173 | if(self._uuid):
174 | message += "Cluster state UUID: " + self._uuid + "\n\n"
175 |
176 | if(self._primary):
177 | message += "Current cluster component is primary: " + self._primary + "\n\n"
178 |
179 | if(self._members):
180 | message += "Current members of the component:\n"
181 |
182 | if(self._index):
183 | for i in range(len(self._members)):
184 | if(i == int(self._index)):
185 | message += "-> "
186 | else:
187 | message += "-- "
188 |
189 | message += self._members[i] + "\n"
190 | else:
191 | message += "\n".join((" " + str(x)) for x in self._members)
192 |
193 | message += "\n"
194 |
195 | if(self._index):
196 | message += "Index of this node in the member list: " + self._index + "\n"
197 |
198 | return message
199 |
200 | if __name__ == "__main__":
201 | main(sys.argv[1:])
202 |
--------------------------------------------------------------------------------
/templates/etc/mysql/galeranotify.py3.j2:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | #
3 | # Script to send email notifications when a change in Galera cluster membership
4 | # occurs.
5 | #
6 | # Complies with http://www.codership.com/wiki/doku.php?id=notification_command
7 | #
8 | # Author: Gabe Guillen
9 | # Version: 1.5
10 | # Release: 3/5/2015
11 | # Use at your own risk. No warranties expressed or implied.
12 | #
13 |
14 | # {{ ansible_managed }}
15 |
16 | import os
17 | import sys
18 | import getopt
19 |
20 | import smtplib
21 |
22 | try: from email.mime.text import MIMEText
23 | except ImportError:
24 | # Python 2.4 (CentOS 5.x)
25 | from email.MIMEText import MIMEText
26 |
27 | import socket
28 | import email.utils
29 |
30 | # Change this to some value if you don't want your server hostname to show in
31 | # the notification emails
32 | THIS_SERVER = socket.gethostname()
33 |
34 | # Server hostname or IP address
35 | SMTP_SERVER = '{{ galera_notify_smtp_server }}'
36 | SMTP_PORT = {{ galera_notify_smtp_port }}
37 |
38 | # Set to True if you need SMTP over SSL
39 | SMTP_SSL = {{ galera_notify_smtp_ssl }}
40 |
41 | # Set to True if you need SMTP over TLS
42 | SMTP_STARTTLS = {{ galera_notify_smtp_starttls }}
43 |
44 | # Set to True if you need to authenticate to your SMTP server
45 | SMTP_AUTH = {{ galera_notify_smtp_auth }}
46 | # Fill in authorization information here if True above
47 | SMTP_USERNAME = '{{ galera_notify_smtp_username }}'
48 | SMTP_PASSWORD = '{{ galera_notify_smtp_password }}'
49 |
50 | # Takes a single sender
51 | MAIL_FROM = '{{ galera_notify_mail_from }}'
52 | # Takes a list of recipients
53 | # Need Date in Header for SMTP RFC Compliance
54 | DATE = email.utils.formatdate()
55 | MAIL_TO = ['{{ galera_notify_mail_to }}']
56 |
57 | # Edit below at your own risk
58 | ################################################################################
59 | def main(argv):
60 | str_status = ''
61 | str_uuid = ''
62 | str_primary = ''
63 | str_members = ''
64 | str_index = ''
65 | message = ''
66 |
67 | usage = "Usage: " + os.path.basename(sys.argv[0]) + " --status "
68 | usage += " --uuid --primary --members --index "
70 |
71 | try:
72 | opts, args = getopt.getopt(argv, "h", ["status=","uuid=",'primary=','members=','index='])
73 | except getopt.GetoptError:
74 | print(usage)
75 | sys.exit(2)
76 |
77 | if(len(opts) > 0):
78 | message_obj = GaleraStatus(THIS_SERVER)
79 |
80 | for opt, arg in opts:
81 | if opt == '-h':
82 | print(usage)
83 | sys.exit()
84 | elif opt in ("--status"):
85 | message_obj.set_status(arg)
86 | elif opt in ("--uuid"):
87 | message_obj.set_uuid(arg)
88 | elif opt in ("--primary"):
89 | message_obj.set_primary(arg)
90 | elif opt in ("--members"):
91 | message_obj.set_members(arg)
92 | elif opt in ("--index"):
93 | message_obj.set_index(arg)
94 | try:
95 | send_notification(MAIL_FROM, MAIL_TO, 'Galera Notification: ' + THIS_SERVER, DATE,
96 | str(message_obj), SMTP_SERVER, SMTP_PORT, SMTP_SSL, SMTP_STARTTLS, SMTP_AUTH,
97 | SMTP_USERNAME, SMTP_PASSWORD)
98 | except Exception as e:
99 | print(f"Unable to send notification: {e}")
100 | sys.exit(1)
101 | else:
102 | print(usage)
103 | sys.exit(2)
104 |
105 | sys.exit(0)
106 |
107 | def send_notification(from_email, to_email, subject, date, message, smtp_server,
108 | smtp_port, use_ssl, use_starttls, use_auth, smtp_user, smtp_pass):
109 | msg = MIMEText(message)
110 |
111 | msg['From'] = from_email
112 | msg['To'] = ', '.join(to_email)
113 | msg['Subject'] = subject
114 | msg['Date'] = date
115 | msg['Message-ID'] = email.utils.make_msgid()
116 |
117 | if(use_ssl):
118 | mailer = smtplib.SMTP_SSL(smtp_server, smtp_port)
119 | else:
120 | mailer = smtplib.SMTP(smtp_server, smtp_port)
121 |
122 | if(use_starttls):
123 | mailer.starttls()
124 |
125 | if(use_auth):
126 | mailer.login(smtp_user, smtp_pass)
127 |
128 | mailer.sendmail(from_email, to_email, msg.as_string())
129 | mailer.close()
130 |
131 | class GaleraStatus:
132 | def __init__(self, server):
133 | self._server = server
134 | self._status = ""
135 | self._uuid = ""
136 | self._primary = ""
137 | self._members = ""
138 | self._index = ""
139 | self._count = 0
140 |
141 | def set_status(self, status):
142 | self._status = status
143 | self._count += 1
144 |
145 | def set_uuid(self, uuid):
146 | self._uuid = uuid
147 | self._count += 1
148 |
149 | def set_primary(self, primary):
150 | self._primary = primary.capitalize()
151 | self._count += 1
152 |
153 | def set_members(self, members):
154 | self._members = members.split(',')
155 | self._count += 1
156 |
157 | def set_index(self, index):
158 | self._index = index
159 | self._count += 1
160 |
161 | def __str__(self):
162 | message = "Galera running on " + self._server + " has reported the following"
163 | message += " cluster membership change"
164 |
165 | if(self._count > 1):
166 | message += "s"
167 |
168 | message += ":\n\n"
169 |
170 | if(self._status):
171 | message += "Status of this node: " + self._status + "\n\n"
172 |
173 | if(self._uuid):
174 | message += "Cluster state UUID: " + self._uuid + "\n\n"
175 |
176 | if(self._primary):
177 | message += "Current cluster component is primary: " + self._primary + "\n\n"
178 |
179 | if(self._members):
180 | message += "Current members of the component:\n"
181 |
182 | if(self._index):
183 | for i in range(len(self._members)):
184 | if(i == int(self._index)):
185 | message += "-> "
186 | else:
187 | message += "-- "
188 |
189 | message += self._members[i] + "\n"
190 | else:
191 | message += "\n".join((" " + str(x)) for x in self._members)
192 |
193 | message += "\n"
194 |
195 | if(self._index):
196 | message += "Index of this node in the member list: " + self._index + "\n"
197 |
198 | return message
199 |
200 | if __name__ == "__main__":
201 | main(sys.argv[1:])
202 |
--------------------------------------------------------------------------------
/templates/etc/mysql/my.cnf.j2:
--------------------------------------------------------------------------------
1 | # {{ ansible_managed }}
2 |
3 | [client]
4 | port = 3306
5 | socket = {{ mariadb_login_unix_socket }}
6 |
7 | [mysqld_safe]
8 | nice = 0
9 | socket = {{ mariadb_login_unix_socket }}
10 |
11 | [mysqld]
12 | basedir = /usr
13 | datadir = {{ mariadb_mysql_settings['datadir'] }}
14 | key_buffer_size = {{ mariadb_mysql_settings['key_buffer_size'] }}
15 | lc-messages-dir = /usr/share/mysql
16 | {% if mariadb_mysql_settings['log_error'] is defined -%}
17 | log_error = {{ mariadb_mysql_settings['log_error'] }}
18 | {%+ endif %}
19 | max_allowed_packet = {{ mariadb_mysql_settings['max_allowed_packet'] }}
20 | max_binlog_size = {{ mariadb_mysql_settings['max_binlog_size'] }}
21 | myisam-recover = BACKUP
22 | port = {{ mariadb_mysql_port }}
23 | {% if mariadb_mysql_settings['query_cache_limit'] is defined -%}
24 | query_cache_limit = {{ mariadb_mysql_settings['query_cache_limit'] }}
25 | {%+ endif %}
26 | {% if mariadb_mysql_settings['query_cache_size'] is defined -%}
27 | query_cache_size = {{ mariadb_mysql_settings['query_cache_size'] }}
28 | {%+ endif %}
29 | skip-external-locking
30 | socket = {{ mariadb_login_unix_socket }}
31 | thread_cache_size = {{ mariadb_mysql_settings['thread_cache_size'] }}
32 | tmpdir = /tmp
33 | user = mysql
34 |
35 | {% if mariadb_charset_server | default('auto') != 'auto' %}
36 | character-set-server = {{ mariadb_charset_server }}
37 | init-connect = 'SET NAMES {{ mariadb_charset_server }}'
38 | {% endif %}
39 | {% if mariadb_collation_server | default('auto') != 'auto' %}
40 | collation-server = {{ mariadb_collation_server }}
41 | {% endif %}
42 |
43 | {% if mariadb_innodb_buffer_pool_size | default('auto') != "auto" %}
44 | innodb_buffer_pool_size = {{ mariadb_innodb_buffer_pool_size }}
45 | {% endif %}
46 | {% if mariadb_innodb_lock_wait_timeout | default('50') != "50" %}
47 | innodb_lock_wait_timeout = {{ mariadb_innodb_lock_wait_timeout }}
48 | {% endif %}
49 | {% if mariadb_innodb_read_io_threads | default('auto') != "auto" %}
50 | innodb_read_io_threads = {{ mariadb_innodb_read_io_threads }}
51 | {% endif %}
52 | {% if mariadb_innodb_write_io_threads | default('auto') != "auto" %}
53 | innodb_write_io_threads = {{ mariadb_innodb_write_io_threads }}
54 | {% endif %}
55 | {% if mariadb_max_connections | default('auto') != "auto" %}
56 | max_connections = {{ mariadb_max_connections }}
57 | {% endif %}
58 | {% if mariadb_slow_query_log_enabled %}
59 | slow_query_log
60 | {% endif %}
61 | {% if mariadb_long_query_time | default('auto') != "auto" %}
62 | long_query_time = {{ mariadb_long_query_time }}
63 | {% endif %}
64 |
65 | {% if mariadb_tls_files and mariadb_tls_files|length == 3 %}
66 | ssl_ca = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.ca_cert.name }}
67 | ssl_cert = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.server_cert.name }}
68 | ssl_key = {{ mariadb_certificates_dir }}/{{ mariadb_tls_files.server_key.name }}
69 | {% endif %}
70 |
71 | [mysqldump]
72 | max_allowed_packet = 16M
73 | quick
74 | quote-names
75 |
76 | [mysql]
77 | default-character-set = {{ mariadb_charset_client }}
78 |
79 | [isamchk]
80 | key_buffer_size = 16M
81 |
82 | !includedir /etc/mysql/conf.d/
83 |
--------------------------------------------------------------------------------
/templates/etc/systemd/system/mariadb.service.d/max-open-files.conf.j2:
--------------------------------------------------------------------------------
1 |
2 | [Service]
3 | LimitNOFILE={{ mariadb_max_open_files }}
4 |
--------------------------------------------------------------------------------
/templates/etc/systemd/system/mariadb.service.d/oom-score-adjust.conf.j2:
--------------------------------------------------------------------------------
1 |
2 | [Service]
3 | OOMScoreAdjust={{ mariadb_oom_score_adjust }}
4 |
--------------------------------------------------------------------------------
/templates/etc/systemd/system/mariadb.service.d/timeout-start-sec.conf.j2:
--------------------------------------------------------------------------------
1 |
2 | [Service]
3 | # Override defualt timeout for starting service, due to long SST duration
4 | TimeoutStartSec={{ mariadb_timeout_start_sec }}
5 |
--------------------------------------------------------------------------------
/templates/root/my.cnf.j2:
--------------------------------------------------------------------------------
1 | [client]
2 | user=root
3 | password={{ mariadb_mysql_root_password }}
4 | socket={{ mariadb_login_unix_socket }}
5 |
--------------------------------------------------------------------------------
/vars/almalinux-8.yml:
--------------------------------------------------------------------------------
1 | ---
2 | mariadb_login_unix_socket: "/var/lib/mysql/mysql.sock"
3 | mariadb_pre_req_packages:
4 | - "epel-release"
5 | - "procps-ng"
6 | mariadb_packages:
7 | - "python3-mysql"
8 | - "MariaDB-server"
9 | - "galera-4"
10 | mariabackup_packages:
11 | - "MariaDB-backup"
12 | mariadb_certificates_dir: "/etc/my.cnf.d/certificates"
13 | mariadb_systemd_service_name: "mariadb.service"
14 | mariadb_confs:
15 | - name: "etc/my.cnf.d/server.cnf"
16 | mariadb_temp_confs:
17 | - "etc/my.cnf.d/server.cnf"
18 | galera_wsrep_provider: "/usr/lib64/galera-4/libgalera_smm.so"
19 |
--------------------------------------------------------------------------------
/vars/almalinux-9.yml:
--------------------------------------------------------------------------------
1 | ---
2 | mariadb_login_unix_socket: "/var/lib/mysql/mysql.sock"
3 | mariadb_redhat_repo: "https://yum.mariadb.org/{{ mariadb_version }}/rhel9-amd64"
4 | mariadb_pre_req_packages:
5 | - "epel-release"
6 | - "procps-ng"
7 | mariadb_packages:
8 | - "python3-mysqlclient"
9 | - "MariaDB-server"
10 | - "galera-4"
11 | mariabackup_packages:
12 | - "MariaDB-backup"
13 | mariadb_certificates_dir: "/etc/my.cnf.d/certificates"
14 | mariadb_systemd_service_name: "mariadb.service"
15 | mariadb_confs:
16 | - "etc/my.cnf.d/server.cnf"
17 | mariadb_temp_confs:
18 | - "etc/my.cnf.d/server.cnf"
19 | galera_wsrep_provider: "/usr/lib64/galera-4/libgalera_smm.so"
20 |
--------------------------------------------------------------------------------
/vars/centos-8.yml:
--------------------------------------------------------------------------------
1 | ---
2 | mariadb_login_unix_socket: "/var/lib/mysql/mysql.sock"
3 | mariadb_pre_req_packages:
4 | - "epel-release"
5 | - "procps-ng"
6 | mariadb_packages:
7 | - "python3-mysql"
8 | - "MariaDB-server"
9 | - "galera-4"
10 | mariabackup_packages:
11 | - "MariaDB-backup"
12 | mariadb_certificates_dir: "/etc/my.cnf.d/certificates"
13 | mariadb_systemd_service_name: "mariadb.service"
14 | mariadb_confs:
15 | - name: "etc/my.cnf.d/server.cnf"
16 | mariadb_temp_confs:
17 | - "etc/my.cnf.d/server.cnf"
18 | galera_wsrep_provider: "/usr/lib64/galera-4/libgalera_smm.so"
19 |
--------------------------------------------------------------------------------
/vars/centos-9.yml:
--------------------------------------------------------------------------------
1 | ---
2 | mariadb_login_unix_socket: "/var/lib/mysql/mysql.sock"
3 | mariadb_redhat_repo: "https://yum.mariadb.org/{{ mariadb_version }}/rhel9-amd64"
4 | mariadb_pre_req_packages:
5 | - "epel-release"
6 | - "procps-ng"
7 | mariadb_packages:
8 | - "python3-mysqlclient"
9 | - "MariaDB-server"
10 | - "galera-4"
11 | mariabackup_packages:
12 | - "MariaDB-backup"
13 | mariadb_certificates_dir: "/etc/my.cnf.d/certificates"
14 | mariadb_systemd_service_name: "mariadb.service"
15 | mariadb_confs:
16 | - "etc/my.cnf.d/server.cnf"
17 | mariadb_temp_confs:
18 | - "etc/my.cnf.d/server.cnf"
19 | galera_wsrep_provider: "/usr/lib64/galera-4/libgalera_smm.so"
20 |
--------------------------------------------------------------------------------
/vars/debian-11.yml:
--------------------------------------------------------------------------------
1 | ---
2 | mariadb_login_unix_socket: "/var/run/mysqld/mysqld.sock"
3 | mariadb_pre_req_packages:
4 | - "apt-transport-https"
5 | - "software-properties-common"
6 | - "python3-pymysql"
7 | - "rsync"
8 | - "gnupg"
9 | mariadb_debian_repo_key: "0xF1656F24C74CD1D8"
10 | mariadb_packages:
11 | - "mariadb-server"
12 | mariabackup_packages:
13 | - "mariadb-backup"
14 | mariadb_certificates_dir: "/etc/mysql/certificates"
15 | mariadb_systemd_service_name: "mariadb.service"
16 | mariadb_confs:
17 | - name: "etc/mysql/debian.cnf"
18 | mode: "0600"
19 | - name: "etc/mysql/my.cnf"
20 | - name: "etc/mysql/conf.d/galera.cnf"
21 | mariadb_temp_confs:
22 | - "etc/mysql/conf.d/galera.cnf"
23 | galera_wsrep_provider: "/usr/lib/galera/libgalera_smm.so"
24 |
--------------------------------------------------------------------------------
/vars/debian-12.yml:
--------------------------------------------------------------------------------
1 | ---
2 | mariadb_login_unix_socket: "/var/run/mysqld/mysqld.sock"
3 | mariadb_pre_req_packages:
4 | - "apt-transport-https"
5 | - "software-properties-common"
6 | - "python3-pymysql"
7 | - "rsync"
8 | - "gnupg"
9 | mariadb_debian_repo_key: "0xF1656F24C74CD1D8"
10 | mariadb_packages:
11 | - "mariadb-server"
12 | mariabackup_packages:
13 | - "mariadb-backup"
14 | mariadb_certificates_dir: "/etc/mysql/certificates"
15 | mariadb_systemd_service_name: "mariadb.service"
16 | mariadb_confs:
17 | - name: "etc/mysql/debian.cnf"
18 | mode: "0600"
19 | - name: "etc/mysql/my.cnf"
20 | - name: "etc/mysql/conf.d/galera.cnf"
21 | mariadb_temp_confs:
22 | - "etc/mysql/conf.d/galera.cnf"
23 | galera_wsrep_provider: "/usr/lib/galera/libgalera_smm.so"
24 |
--------------------------------------------------------------------------------
/vars/debian.yml:
--------------------------------------------------------------------------------
1 | ---
2 | mariadb_login_unix_socket: "/var/run/mysqld/mysqld.sock"
3 | mariadb_pre_req_packages:
4 | - "apt-transport-https"
5 | - "software-properties-common"
6 | - "python3-pymysql"
7 | - "rsync"
8 | - "gnupg"
9 | - "python-pymysql"
10 | mariadb_debian_repo_key: "0xF1656F24C74CD1D8"
11 | mariadb_packages:
12 | - "mariadb-server"
13 | mariabackup_packages:
14 | - "mariadb-backup"
15 | mariadb_certificates_dir: "/etc/mysql/certificates"
16 | mariadb_systemd_service_name: "mysql.service"
17 | mariadb_confs:
18 | - name: "etc/mysql/debian.cnf"
19 | mode: "0600"
20 | - name: "etc/mysql/my.cnf"
21 | - name: "etc/mysql/conf.d/galera.cnf"
22 | mariadb_temp_confs:
23 | - "etc/mysql/conf.d/galera.cnf"
24 | galera_wsrep_provider: "/usr/lib/galera/libgalera_smm.so"
25 |
--------------------------------------------------------------------------------
/vars/fedora.yml:
--------------------------------------------------------------------------------
1 | ---
2 | mariadb_login_unix_socket: "/var/lib/mysql/mysql.sock"
3 | mariadb_pre_req_packages: []
4 | mariadb_packages:
5 | - "python3-mysql"
6 | - "MariaDB-server"
7 | - "galera-4"
8 | mariabackup_packages:
9 | - "MariaDB-backup"
10 | mariadb_certificates_dir: "/etc/my.cnf.d/certificates"
11 | mariadb_systemd_service_name: "mariadb.service"
12 | mariadb_confs:
13 | - name: "etc/my.cnf.d/server.cnf"
14 | mariadb_temp_confs:
15 | - "etc/my.cnf.d/server.cnf"
16 | galera_wsrep_provider: "/usr/lib64/galera-4/libgalera_smm.so"
17 |
--------------------------------------------------------------------------------
/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for ansible-mariadb-galera-cluster
3 |
4 | galera_cluster_nodes: "\
5 | {% set _galera_cluster_nodes = [] %}\
6 | {% for host in groups[ galera_cluster_nodes_group ] %}\
7 | {{ _galera_cluster_nodes.append( host )|default('', True) }}\
8 | {% endfor %}\
9 | {{ _galera_cluster_nodes }}"
10 |
--------------------------------------------------------------------------------
/vars/redhat.yml:
--------------------------------------------------------------------------------
1 | ---
2 | mariadb_login_unix_socket: "/var/lib/mysql/mysql.sock"
3 | mariadb_pre_req_packages:
4 | - "MySQL-python"
5 | mariadb_packages:
6 | - "MariaDB-server"
7 | - "galera-4"
8 | mariabackup_packages:
9 | - "MariaDB-backup"
10 | mariadb_certificates_dir: "/etc/my.cnf.d/certificates"
11 | mariadb_systemd_service_name: "mysql.service"
12 | mariadb_confs:
13 | - name: "etc/my.cnf.d/server.cnf"
14 | mariadb_temp_confs:
15 | - "etc/my.cnf.d/server.cnf"
16 | galera_wsrep_provider: "/usr/lib64/galera-4/libgalera_smm.so"
17 |
--------------------------------------------------------------------------------
/vars/rocky-8.yml:
--------------------------------------------------------------------------------
1 | ---
2 | mariadb_login_unix_socket: "/var/lib/mysql/mysql.sock"
3 | mariadb_redhat_repo: "https://yum.mariadb.org/{{ mariadb_version }}/rhel8-amd64"
4 | mariadb_pre_req_packages:
5 | - "epel-release"
6 | - "procps-ng"
7 | mariadb_packages:
8 | - "python3-mysql"
9 | - "MariaDB-server"
10 | - "galera-4"
11 | mariabackup_packages:
12 | - "MariaDB-backup"
13 | mariadb_certificates_dir: "/etc/my.cnf.d/certificates"
14 | mariadb_systemd_service_name: "mariadb.service"
15 | mariadb_confs:
16 | - name: "etc/my.cnf.d/server.cnf"
17 | mariadb_temp_confs:
18 | - "etc/my.cnf.d/server.cnf"
19 | galera_wsrep_provider: "/usr/lib64/galera-4/libgalera_smm.so"
20 |
--------------------------------------------------------------------------------
/vars/rocky-9.yml:
--------------------------------------------------------------------------------
1 | ---
2 | mariadb_login_unix_socket: "/var/lib/mysql/mysql.sock"
3 | mariadb_redhat_repo: "https://yum.mariadb.org/{{ mariadb_version }}/rhel9-amd64"
4 | mariadb_pre_req_packages:
5 | - "epel-release"
6 | - "procps-ng"
7 | mariadb_packages:
8 | - "python3-mysqlclient"
9 | - "MariaDB-server"
10 | - "galera-4"
11 | mariabackup_packages:
12 | - "MariaDB-backup"
13 | mariadb_certificates_dir: "/etc/my.cnf.d/certificates"
14 | mariadb_systemd_service_name: "mariadb.service"
15 | mariadb_confs:
16 | - name: "etc/my.cnf.d/server.cnf"
17 | mariadb_temp_confs:
18 | - "etc/my.cnf.d/server.cnf"
19 | galera_wsrep_provider: "/usr/lib64/galera-4/libgalera_smm.so"
20 |
--------------------------------------------------------------------------------
/vars/ubuntu-20.yml:
--------------------------------------------------------------------------------
1 | ---
2 | mariadb_login_unix_socket: "/var/run/mysqld/mysqld.sock"
3 | mariadb_pre_req_packages:
4 | - "apt-transport-https"
5 | - "software-properties-common"
6 | - "python3-pymysql"
7 | - "rsync"
8 | mariadb_debian_repo_key: "0xF1656F24C74CD1D8"
9 | mariadb_packages:
10 | - "mariadb-server"
11 | mariabackup_packages:
12 | - "mariadb-backup"
13 | mariadb_certificates_dir: "/etc/mysql/certificates"
14 | mariadb_systemd_service_name: "mariadb.service"
15 | mariadb_confs:
16 | - name: "etc/mysql/debian.cnf"
17 | - name: "etc/mysql/my.cnf"
18 | - name: "etc/mysql/conf.d/galera.cnf"
19 | mariadb_temp_confs:
20 | - "etc/mysql/conf.d/galera.cnf"
21 | galera_wsrep_provider: "/usr/lib/galera/libgalera_smm.so"
22 |
--------------------------------------------------------------------------------
/vars/ubuntu-22.yml:
--------------------------------------------------------------------------------
1 | ---
2 | mariadb_login_unix_socket: "/var/run/mysqld/mysqld.sock"
3 | mariadb_pre_req_packages:
4 | - "apt-transport-https"
5 | - "software-properties-common"
6 | - "python3-pymysql"
7 | - "rsync"
8 | mariadb_debian_repo_key: "0xF1656F24C74CD1D8"
9 | mariadb_packages:
10 | - "mariadb-server"
11 | mariabackup_packages:
12 | - "mariadb-backup"
13 | mariadb_certificates_dir: "/etc/mysql/certificates"
14 | mariadb_systemd_service_name: "mariadb.service"
15 | mariadb_confs:
16 | - name: "etc/mysql/debian.cnf"
17 | - name: "etc/mysql/my.cnf"
18 | - name: "etc/mysql/conf.d/galera.cnf"
19 | mariadb_temp_confs:
20 | - "etc/mysql/conf.d/galera.cnf"
21 | galera_wsrep_provider: "/usr/lib/galera/libgalera_smm.so"
22 |
--------------------------------------------------------------------------------
/vars/ubuntu-24.yml:
--------------------------------------------------------------------------------
1 | ---
2 | mariadb_login_unix_socket: "/var/run/mysqld/mysqld.sock"
3 | mariadb_pre_req_packages:
4 | - "apt-transport-https"
5 | - "software-properties-common"
6 | - "python3-pymysql"
7 | - "rsync"
8 | mariadb_debian_repo_key: "0xF1656F24C74CD1D8"
9 | mariadb_packages:
10 | - "mariadb-server"
11 | mariabackup_packages:
12 | - "mariadb-backup"
13 | mariadb_certificates_dir: "/etc/mysql/certificates"
14 | mariadb_systemd_service_name: "mariadb.service"
15 | mariadb_confs:
16 | - name: "etc/mysql/debian.cnf"
17 | - name: "etc/mysql/my.cnf"
18 | - name: "etc/mysql/conf.d/galera.cnf"
19 | mariadb_temp_confs:
20 | - "etc/mysql/conf.d/galera.cnf"
21 | galera_wsrep_provider: "/usr/lib/galera/libgalera_smm.so"
22 |
--------------------------------------------------------------------------------