Add GitHub Actions

Adding GitHub Actions as CI
This commit is contained in:
felix.niederwanger@suse.com 2021-03-25 16:06:30 +01:00
parent a5a9cbe73a
commit 16cd66fbea
7 changed files with 110 additions and 3 deletions

42
.github/workflows/CI.yml vendored Normal file
View file

@ -0,0 +1,42 @@
---
name: Test deployment
'on':
pull_request:
push:
schedule:
# Run every Wednesday at 01:42
- cron: "42 1 * * 3"
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check out codebase
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: pip3 install yamllint
- name: Lint repository
run: yamllint .
molecule:
name: Molecule
runs-on: ubuntu-latest
steps:
- name: Check out the codebase
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: pip3 install ansible molecule[docker] docker pytest testinfra
- name: Run Molecule
run: molecule test
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'

View file

@ -1,3 +1,5 @@
[![Test deployment](https://github.com/GeekOops/geekoops-collectd/actions/workflows/CI.yml/badge.svg)](https://github.com/GeekOops/geekoops-collectd/actions/workflows/CI.yml)
# geekoops-collectd
Easy ansible role to setup `collectd`. Currently only `influxdb` is supported by this role. This ansible role works with

View file

@ -0,0 +1,7 @@
---
- name: Converge
hosts: all
tasks:
- name: "Include geekoops-collectd"
include_role:
name: "geekoops-collectd"

View file

@ -0,0 +1,29 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: leap15_2
image: grisu48/leap-ansible
pre_build_image: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
capabilities:
- SYS_ADMIN
tmpfs:
- /run
- /tmp
provisioner:
name: ansible
inventory:
host_vars:
leap15_2:
nodename: "jellyfish"
verifier:
name: testinfra
lint:
name: flake8
lint: |
set -e
yamllint .

View file

@ -0,0 +1,13 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import testinfra.utils.ansible_runner
import os
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_collectd(host):
# Just ensure, the collectd config file is overwritten
cmd = host.run("cat /etc/collectd.conf | grep Hostname | grep jellyfish")
assert cmd.succeeded

View file

@ -9,10 +9,24 @@
- name: Install collectd
package:
name: "{{ packages }}"
# Important: Leave state: present, as we will overwrite the existing config
# when this task changes!
state: present
register: install
tags: ['collectd']
- name: Perform collectd first config
template:
src: collectd.conf.j2
dest: /etc/collectd.conf
owner: root
group: root
mode: 0640
force: true
tags: ['collectd']
when: install.changed == true
notify: restart collectd
- name: Ensure collectd is configured
template:
src: collectd.conf.j2
@ -20,8 +34,9 @@
owner: root
group: root
mode: 0640
force: "{{overwrite}} or install.changed"
force: "{{overwrite}}"
tags: ['collectd']
when: install.changed == false
notify: restart collectd
- name: Ensure collectd is enabled
@ -30,4 +45,3 @@
state: started
enabled: true
tags: ['collectd']

View file

@ -1,2 +1,2 @@
---
# vars file for geekoops-collectd
# vars file for geekoops-collectd