Skip to content

Commit

Permalink
Add testing using GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitriy Rabotyagov committed Jun 15, 2022
1 parent 70d3c59 commit 45db22a
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 80 deletions.
1 change: 1 addition & 0 deletions .cache/roles/noonedeadpunk.pacemaker_corosync
52 changes: 52 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Molecule

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
molecule:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
fail-fast: false
matrix:
scenario:
- centos-systemd:stream8
- centos-systemd:stream9
- debian-systemd:11
- ubuntu-systemd:20.04
- ubuntu-systemd:22.04
python-version:
- 3.8
ansible-version:
- 2.12.6

steps:
- name: Checkout
uses: actions/checkout@v2
with:
path: "${{ github.repository }}"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r ${{ github.repository }}/test-requirements.txt
- name: Install ansible
run: |
python3 -m pip install ansible-core==${{ matrix.ansible-version }}
- name: Install ansible collections
run: |
ansible-galaxy install -r ${{ github.repository }}/test-requirements.yml
- name: Test with molecule
run: |
cd ${{ github.repository }}
export docker_image_tag="${{ matrix.scenario }}"
python3 -m molecule test
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
rules:
line-length: disable
truthy:
allowed-values:
- 'True'
Expand All @@ -8,3 +9,6 @@ rules:
- 'False'
- 'false'
- 'no'

ignore: |
.github/
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ansible-role-pacemaker_corosync [![Build Status](https://travis-ci.org/noonedeadpunk/ansible-role-pacemaker_corosync.svg?branch=master)](https://travis-ci.org/noonedeadpunk/ansible-role-pacemaker_corosync)
ansible-role-pacemaker_corosync [![Build Status](https://github.com/noonedeadpunk/ansible-pacemaker-corosync/actions/workflows/main.yml/badge.svg?branch=master)]

===============================

Deploys corosync/pacemaker
Expand Down
1 change: 1 addition & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies: []
galaxy_info:
author: Dmitriy Rabotyagov
company: ACME Corp
namespace: noonedeadpunk
role_name: pacemaker_corosync
description: Deploys pacemaker and corosync stack.
license: MIT
Expand Down
70 changes: 34 additions & 36 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,42 @@
---
- name: Converge
hosts: all
tasks:
- name: Apt update and install rsync, ping, iproute
apt:
update_cache: yes
name:
- rsync
- inetutils-ping
- iproute2
state: present
when: ansible_os_family == "Debian"
vars_files:
- "tests/pacemaker_corosync_local.yml"
pre_tasks:
- name: Apt update and install rsync, ping, iproute
apt:
update_cache: yes
name:
- rsync
- inetutils-ping
- iproute2
state: present
when: ansible_os_family == "Debian"

- name: Yum install iproute to fix undefined ansible_default_ipv4.address
yum:
name: iproute
state: present
when:
- ansible_distribution == "CentOS"
- ansible_distribution_major_version == "7"
- name: Yum install iproute to fix undefined ansible_default_ipv4.address
yum:
name: iproute
state: present
when:
- ansible_distribution == "CentOS"
- ansible_distribution_major_version == "7"

- name: Add a container to a network, leaving existing containers connected
delegate_to: localhost
community.general.docker_network:
name: pacemaker-network
connected:
- "{{ inventory_hostname }}"
appends: yes
- name: Add a container to a network, leaving existing containers connected
delegate_to: localhost
community.general.docker_network:
name: pacemaker-network
connected:
- "{{ inventory_hostname }}"
appends: yes

- name: Re-collect network facts required after installation iproute
setup:
gather_subset: network
- name: Re-collect network facts required after installation iproute
setup:
gather_subset: network

- name: Show ansible_interfaces
debug:
var: ansible_interfaces
- name: Show ansible_interfaces
debug:
var: ansible_interfaces

- name: Include keepalived vars
include_vars: "tests/pacemaker_corosync_local.yml"

- name: "Include ansible-role-pacemaker-corosync"
include_role:
name: "ansible-role-pacemaker_corosync"
roles:
- role: "{{ playbook_dir | dirname | dirname | basename }}"
33 changes: 5 additions & 28 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
lint: |
set -e
yamllint .
ansible-lint -vv --exclude=.tox -x 204,208
ansible-lint -vv --exclude=.tox --exclude=molecule/default/converge.yml -x 204,208
dependency:
name: galaxy
driver:
Expand All @@ -15,34 +15,11 @@ provisioner:
v: True
log: True
platforms:
- name: pacemaker-centos7
image: diodonfrost/ansible-centos:7
- name: pacemaker
image: "${docker_user:-quay.io/gotmax23}/${docker_image_tag:-ubuntu-systemd:focal}"
pre_build_image: true
groups:
- corosync
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro

- name: pacemaker-centos8
image: diodonfrost/ansible-centos:8
groups:
- corosync
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro

- name: pacemaker-bionic
image: travisci/ubuntu-systemd:18.04
groups:
- corosync
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro

- name: pacemaker-focal
image: travisci/ubuntu-systemd:20.04
privileged: true
groups:
- corosync
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- /sys/fs/cgroup:/sys/fs/cgroup:ro
3 changes: 3 additions & 0 deletions tasks/pacemaker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
file:
path: /var/log/corosync
state: directory
mode: "0775"
when: pacemaker_corosync_use_logfile | bool

- name: Adds logrotate config for corosync
Expand All @@ -151,6 +152,7 @@
file:
path: /etc/corosync/service.d/
state: directory
mode: "0755"

- name: Adds pacemaker service
copy:
Expand All @@ -164,6 +166,7 @@
template:
src: "ferm.j2"
dest: /etc/ferm/filter-input.d/60_corosync.conf
mode: "0640"
when: ferm_enabled | default(false)
tags: ferm
notify: Restart ferm
7 changes: 7 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
bashate>=0.2 # Apache-2.0
flake8<2.6.0,>=2.5.4 # MIT
docker==5.0.3
molecule==3.6.1
molecule-docker==1.1.0
ansible-lint==5.0.10
rich>=9.5.1,<11.0.0
5 changes: 5 additions & 0 deletions test-requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
collections:
- community.general
- community.docker
- ansible.netcommon
2 changes: 1 addition & 1 deletion vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---

_pacemaker_remote_group_exists: "{{ (pacemaker_remote_group is defined and pacemaker_remote_group in groups) }}"
_pacemaker_remote_group_exists: "{{ (pacemaker_remote_group is defined and pacemaker_remote_group in groups) }}"

0 comments on commit 45db22a

Please sign in to comment.