Skip to content

Commit e91fe9d

Browse files
authored
Merge pull request #215 from Normo/214-add-keepalived-role
Add hifis.keepalived role
2 parents fe464d1 + 1e26272 commit e91fe9d

File tree

16 files changed

+1172
-6
lines changed

16 files changed

+1172
-6
lines changed

.github/labeler.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
# SPDX-License-Identifier: Apache-2.0
55

66
---
7+
keepalived:
8+
- changed-files:
9+
- any-glob-to-any-file:
10+
- "roles/keepalived/**"
11+
- "molecule/keepalived/**"
12+
- ".github/workflows/keepalived.yml"
713
ssh_keys:
814
- changed-files:
915
- any-glob-to-any-file:

.github/workflows/keepalived.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# SPDX-FileCopyrightText: Helmholtz Centre for Environmental Research (UFZ)
2+
# SPDX-FileCopyrightText: Helmholtz-Zentrum Dresden-Rossendorf (HZDR)
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
---
7+
name: "hifis.keepalived"
8+
9+
on:
10+
pull_request:
11+
paths:
12+
- '.github/workflows/keepalived.yml'
13+
- 'roles/keepalived/**'
14+
- 'molecule/keepalived/**'
15+
- 'Pipfile'
16+
- 'Pipfile.lock'
17+
push:
18+
branches:
19+
- "main"
20+
tags:
21+
- "v*.*.*"
22+
paths:
23+
- '.github/workflows/keepalived.yml'
24+
- 'roles/keepalived/**'
25+
- 'molecule/keepalived/**'
26+
- 'Pipfile'
27+
- 'Pipfile.lock'
28+
schedule:
29+
- cron: '0 0 * * *'
30+
31+
jobs:
32+
33+
test:
34+
name: "Run Molecule tests."
35+
runs-on: "ubuntu-24.04"
36+
env:
37+
PY_COLORS: 1
38+
ANSIBLE_FORCE_COLOR: 1
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
image:
43+
- "ghcr.io/hifis-net/ubuntu-systemd:22.04"
44+
- "ghcr.io/hifis-net/ubuntu-systemd:20.04"
45+
46+
steps:
47+
- name: "Check out the codebase."
48+
uses: "actions/checkout@v4"
49+
with:
50+
path: "ansible_collections/hifis/toolkit"
51+
52+
- name: "Prepare the job environment."
53+
uses: "./ansible_collections/hifis/toolkit/.github/workflows/prepare-action"
54+
55+
- name: "Run Molecule tests."
56+
run: "pipenv run molecule test -s keepalived"
57+
env:
58+
MOLECULE_IMAGE: "${{ matrix.image }}"
59+
working-directory: "ansible_collections/hifis/toolkit"

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ This collection provides production-ready Ansible roles used for providing servi
1818
software engineers, but not exclusively. The following use cases are supported:
1919

2020
* DevOps platform:
21-
* [GitLab](https://github.com/hifis-net/ansible-role-gitlab) (coming soon!)
22-
* [GitLab-Runner](https://github.com/hifis-net/ansible-role-gitlab-runner) (coming soon!)
23-
* [Redis](https://github.com/hifis-net/ansible-role-redis) (coming soon!)
21+
* [GitLab](https://github.com/hifis-net/ansible-role-gitlab) (*coming soon!*)
22+
* [GitLab-Runner](https://github.com/hifis-net/ansible-role-gitlab-runner) (*coming soon!*)
23+
* [Redis](https://github.com/hifis-net/ansible-role-redis) (*coming soon!*)
2424
* Help desk:
2525
* [**Zammad**](roles/zammad)
2626
* High Availability (HA) / Load Balancing:
27-
* [HAProxy](https://github.com/hifis-net/ansible-role-haproxy) (coming soon!)
28-
* [Keepalived](https://github.com/hifis-net/ansible-role-keepalived) (coming soon!)
27+
* [HAProxy](https://github.com/hifis-net/ansible-role-haproxy) (*coming soon!*)
28+
* [**Keepalived**](roles/keepalived)
2929
* OS-related:
3030
* [**unattended-upgrades**](roles/unattended_upgrades)
31-
* [netplan](https://github.com/hifis-net/ansible-role-gitlab-netplan) (coming soon!)
31+
* [netplan](https://github.com/hifis-net/ansible-role-gitlab-netplan) (*coming soon!*)
3232
* distribute authorized [**SSH keys**](role/ssh_keys) to users
3333

3434
## Minimum required Ansible-version

molecule/keepalived/converge.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# SPDX-FileCopyrightText: Helmholtz Centre for Environmental Research (UFZ)
2+
# SPDX-FileCopyrightText: Helmholtz-Zentrum Dresden-Rossendorf (HZDR)
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
---
7+
8+
- name: "Converge"
9+
hosts: "all"
10+
vars:
11+
keepalived_unicast_peers:
12+
- "172.17.0.3"
13+
- "172.17.0.4"
14+
keepalived_virtual_ip_address: "172.17.0.20"
15+
tasks:
16+
- name: "Include keepalived role"
17+
ansible.builtin.include_role:
18+
name: "hifis.toolkit.keepalived"
19+
20+
...

molecule/keepalived/molecule.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# SPDX-FileCopyrightText: Helmholtz Centre for Environmental Research (UFZ)
2+
# SPDX-FileCopyrightText: Helmholtz-Zentrum Dresden-Rossendorf (HZDR)
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
---
7+
8+
dependency:
9+
name: "galaxy"
10+
driver:
11+
name: "podman"
12+
platforms:
13+
- name: "instancekeepalived"
14+
image: "${MOLECULE_IMAGE:-ghcr.io/hifis-net/ubuntu-systemd:22.04}"
15+
pre_build_image: true
16+
privileged: true
17+
systemd: "always"
18+
tty: true
19+
override_command: false
20+
provisioner:
21+
name: "ansible"
22+
config_options:
23+
defaults:
24+
stdout_callback: "yaml"
25+
playbooks:
26+
prepare: "prepare.yml"
27+
check: "converge.yml"
28+
converge: "converge.yml"
29+
verify: "verify.yml"
30+
verifier:
31+
name: "ansible"
32+
scenario:
33+
name: "keepalived"
34+
test_sequence:
35+
- "destroy"
36+
- "dependency"
37+
- "syntax"
38+
- "create"
39+
- "prepare"
40+
- "check"
41+
- "converge"
42+
- "idempotence"
43+
- "check"
44+
- "side_effect"
45+
- "verify"
46+
- "destroy"
47+
48+
...

molecule/keepalived/prepare.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# SPDX-FileCopyrightText: Helmholtz Centre for Environmental Research (UFZ)
2+
# SPDX-FileCopyrightText: Helmholtz-Zentrum Dresden-Rossendorf (HZDR)
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
---
7+
8+
- name: "Prepare"
9+
hosts: "all"
10+
tasks:
11+
- name: "Install dependencies"
12+
ansible.builtin.apt:
13+
name:
14+
- "sudo" # for `become` privilege escalation
15+
- "iproute2" # for gathering network facts
16+
- "psmisc" # provides `killall` command
17+
state: "present"
18+
update_cache: true
19+
20+
...

molecule/keepalived/verify.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# SPDX-FileCopyrightText: Helmholtz Centre for Environmental Research (UFZ)
2+
# SPDX-FileCopyrightText: Helmholtz-Zentrum Dresden-Rossendorf (HZDR)
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
---
7+
8+
- name: "Verify Keepalived"
9+
hosts: "all"
10+
tasks:
11+
- name: "Populate service facts."
12+
ansible.builtin.service_facts:
13+
register: "services_state"
14+
15+
- name: "Check that Keepalived is running on instance."
16+
ansible.builtin.assert:
17+
that:
18+
- "services_state.ansible_facts.services['keepalived.service'].state is search('running')"
19+
fail_msg: "Keepalived need to be running on instance."
20+
success_msg: "Keepalived is running on instance."
21+
22+
...

requirements.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
collections:
99
- name: "ansible.posix"
1010
- name: "community.crypto"
11+
- name: "community.general"

0 commit comments

Comments
 (0)