Skip to content

Add hifis.keepalived role #215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
# SPDX-License-Identifier: Apache-2.0

---
keepalived:
- changed-files:
- any-glob-to-any-file:
- "roles/keepalived/**"
- "molecule/keepalived/**"
- ".github/workflows/keepalived.yml"
ssh_keys:
- changed-files:
- any-glob-to-any-file:
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/keepalived.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# SPDX-FileCopyrightText: Helmholtz Centre for Environmental Research (UFZ)
# SPDX-FileCopyrightText: Helmholtz-Zentrum Dresden-Rossendorf (HZDR)
#
# SPDX-License-Identifier: Apache-2.0

---
name: "hifis.keepalived"

on:
pull_request:
paths:
- '.github/workflows/keepalived.yml'
- 'roles/keepalived/**'
- 'molecule/keepalived/**'
- 'Pipfile'
- 'Pipfile.lock'
push:
branches:
- "main"
tags:
- "v*.*.*"
paths:
- '.github/workflows/keepalived.yml'
- 'roles/keepalived/**'
- 'molecule/keepalived/**'
- 'Pipfile'
- 'Pipfile.lock'
schedule:
- cron: '0 0 * * *'

jobs:

test:
name: "Run Molecule tests."
runs-on: "ubuntu-24.04"
env:
PY_COLORS: 1
ANSIBLE_FORCE_COLOR: 1
strategy:
fail-fast: false
matrix:
image:
- "ghcr.io/hifis-net/ubuntu-systemd:22.04"
- "ghcr.io/hifis-net/ubuntu-systemd:20.04"

steps:
- name: "Check out the codebase."
uses: "actions/checkout@v4"
with:
path: "ansible_collections/hifis/toolkit"

- name: "Prepare the job environment."
uses: "./ansible_collections/hifis/toolkit/.github/workflows/prepare-action"

- name: "Run Molecule tests."
run: "pipenv run molecule test -s keepalived"
env:
MOLECULE_IMAGE: "${{ matrix.image }}"
working-directory: "ansible_collections/hifis/toolkit"
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ This collection provides production-ready Ansible roles used for providing servi
software engineers, but not exclusively. The following use cases are supported:

* DevOps platform:
* [GitLab](https://github.com/hifis-net/ansible-role-gitlab) (coming soon!)
* [GitLab-Runner](https://github.com/hifis-net/ansible-role-gitlab-runner) (coming soon!)
* [Redis](https://github.com/hifis-net/ansible-role-redis) (coming soon!)
* [GitLab](https://github.com/hifis-net/ansible-role-gitlab) (*coming soon!*)
* [GitLab-Runner](https://github.com/hifis-net/ansible-role-gitlab-runner) (*coming soon!*)
* [Redis](https://github.com/hifis-net/ansible-role-redis) (*coming soon!*)
* Help desk:
* [**Zammad**](roles/zammad)
* High Availability (HA) / Load Balancing:
* [HAProxy](https://github.com/hifis-net/ansible-role-haproxy) (coming soon!)
* [Keepalived](https://github.com/hifis-net/ansible-role-keepalived) (coming soon!)
* [HAProxy](https://github.com/hifis-net/ansible-role-haproxy) (*coming soon!*)
* [**Keepalived**](roles/keepalived)
* OS-related:
* [**unattended-upgrades**](roles/unattended_upgrades)
* [netplan](https://github.com/hifis-net/ansible-role-gitlab-netplan) (coming soon!)
* [netplan](https://github.com/hifis-net/ansible-role-gitlab-netplan) (*coming soon!*)
* distribute authorized [**SSH keys**](role/ssh_keys) to users

## Minimum required Ansible-version
Expand Down
20 changes: 20 additions & 0 deletions molecule/keepalived/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# SPDX-FileCopyrightText: Helmholtz Centre for Environmental Research (UFZ)
# SPDX-FileCopyrightText: Helmholtz-Zentrum Dresden-Rossendorf (HZDR)
#
# SPDX-License-Identifier: Apache-2.0

---

- name: "Converge"
hosts: "all"
vars:
keepalived_unicast_peers:
- "172.17.0.3"
- "172.17.0.4"
keepalived_virtual_ip_address: "172.17.0.20"
tasks:
- name: "Include keepalived role"
ansible.builtin.include_role:
name: "hifis.toolkit.keepalived"

...
48 changes: 48 additions & 0 deletions molecule/keepalived/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# SPDX-FileCopyrightText: Helmholtz Centre for Environmental Research (UFZ)
# SPDX-FileCopyrightText: Helmholtz-Zentrum Dresden-Rossendorf (HZDR)
#
# SPDX-License-Identifier: Apache-2.0

---

dependency:
name: "galaxy"
driver:
name: "podman"
platforms:
- name: "instancekeepalived"
image: "${MOLECULE_IMAGE:-ghcr.io/hifis-net/ubuntu-systemd:22.04}"
pre_build_image: true
privileged: true
systemd: "always"
tty: true
override_command: false
provisioner:
name: "ansible"
config_options:
defaults:
stdout_callback: "yaml"
playbooks:
prepare: "prepare.yml"
check: "converge.yml"
converge: "converge.yml"
verify: "verify.yml"
verifier:
name: "ansible"
scenario:
name: "keepalived"
test_sequence:
- "destroy"
- "dependency"
- "syntax"
- "create"
- "prepare"
- "check"
- "converge"
- "idempotence"
- "check"
- "side_effect"
- "verify"
- "destroy"

...
20 changes: 20 additions & 0 deletions molecule/keepalived/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# SPDX-FileCopyrightText: Helmholtz Centre for Environmental Research (UFZ)
# SPDX-FileCopyrightText: Helmholtz-Zentrum Dresden-Rossendorf (HZDR)
#
# SPDX-License-Identifier: Apache-2.0

---

- name: "Prepare"
hosts: "all"
tasks:
- name: "Install dependencies"
ansible.builtin.apt:
name:
- "sudo" # for `become` privilege escalation
- "iproute2" # for gathering network facts
- "psmisc" # provides `killall` command
state: "present"
update_cache: true

...
22 changes: 22 additions & 0 deletions molecule/keepalived/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SPDX-FileCopyrightText: Helmholtz Centre for Environmental Research (UFZ)
# SPDX-FileCopyrightText: Helmholtz-Zentrum Dresden-Rossendorf (HZDR)
#
# SPDX-License-Identifier: Apache-2.0

---

- name: "Verify Keepalived"
hosts: "all"
tasks:
- name: "Populate service facts."
ansible.builtin.service_facts:
register: "services_state"

- name: "Check that Keepalived is running on instance."
ansible.builtin.assert:
that:
- "services_state.ansible_facts.services['keepalived.service'].state is search('running')"
fail_msg: "Keepalived need to be running on instance."
success_msg: "Keepalived is running on instance."

...
1 change: 1 addition & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
collections:
- name: "ansible.posix"
- name: "community.crypto"
- name: "community.general"
Loading