Skip to content

Commit e9c56b8

Browse files
committed
Add hifis.keepalived role
Signed-off-by: Norman Ziegner <[email protected]>
1 parent c1c2b9a commit e9c56b8

File tree

15 files changed

+1178
-6
lines changed

15 files changed

+1178
-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: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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-22.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: "Install modern podman"
56+
run: |
57+
sudo mkdir -p /etc/apt/keyrings
58+
curl -fsSL https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/xUbuntu_$(lsb_release -rs)/Release.key \
59+
| gpg --dearmor \
60+
| sudo tee /etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg > /dev/null
61+
echo \
62+
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg]\
63+
https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/xUbuntu_$(lsb_release -rs)/ /" \
64+
| sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list > /dev/null
65+
sudo apt-get update -qq
66+
sudo apt-get -qq -y install podman
67+
68+
- name: "Run Molecule tests."
69+
run: "pipenv run molecule test -s keepalived"
70+
env:
71+
MOLECULE_IMAGE: "${{ matrix.image }}"
72+
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.ssh_keys"
19+
20+
...

molecule/keepalived/molecule.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
dependency:
8+
name: "galaxy"
9+
driver:
10+
name: "podman"
11+
platforms:
12+
- name: "instancekeepalived"
13+
image: "${MOLECULE_IMAGE:-ghcr.io/hifis-net/ubuntu-systemd:22.04}"
14+
pre_build_image: true
15+
privileged: true
16+
systemd: "always"
17+
tty: true
18+
override_command: false
19+
provisioner:
20+
name: "ansible"
21+
config_options:
22+
defaults:
23+
stdout_callback: "yaml"
24+
playbooks:
25+
prepare: "prepare.yml"
26+
check: "converge.yml"
27+
converge: "converge.yml"
28+
verify: "verify.yml"
29+
verifier:
30+
name: "ansible"
31+
scenario:
32+
name: "default"
33+
test_sequence:
34+
- "destroy"
35+
- "dependency"
36+
- "syntax"
37+
- "create"
38+
- "prepare"
39+
- "check"
40+
- "converge"
41+
- "idempotence"
42+
- "check"
43+
- "side_effect"
44+
- "verify"
45+
- "destroy"
46+
47+
...

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+
# Play to install dependencies.
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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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: "Verify Keepalived"
8+
hosts: "all"
9+
tasks:
10+
- name: "Populate service facts."
11+
ansible.builtin.service_facts:
12+
register: "services_state"
13+
14+
- name: "Check that Keepalived is running on instance."
15+
ansible.builtin.assert:
16+
that:
17+
- "services_state.ansible_facts.services['keepalived.service'].state is search('running')"
18+
fail_msg: "Keepalived need to be running on instance."
19+
success_msg: "Keepalived is running on instance."
20+
21+
...

0 commit comments

Comments
 (0)