mirror of
https://github.com/GeekOops/geekoops-collectd.git
synced 2024-05-19 20:12:22 +00:00
Add GitHub Actions
Adding GitHub Actions as CI
This commit is contained in:
parent
a5a9cbe73a
commit
16cd66fbea
42
.github/workflows/CI.yml
vendored
Normal file
42
.github/workflows/CI.yml
vendored
Normal 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'
|
|
@ -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
|
# geekoops-collectd
|
||||||
|
|
||||||
Easy ansible role to setup `collectd`. Currently only `influxdb` is supported by this role. This ansible role works with
|
Easy ansible role to setup `collectd`. Currently only `influxdb` is supported by this role. This ansible role works with
|
||||||
|
|
7
molecule/default/converge.yml
Normal file
7
molecule/default/converge.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
tasks:
|
||||||
|
- name: "Include geekoops-collectd"
|
||||||
|
include_role:
|
||||||
|
name: "geekoops-collectd"
|
29
molecule/default/molecule.yml
Normal file
29
molecule/default/molecule.yml
Normal 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 .
|
13
molecule/default/tests/test_default.py
Executable file
13
molecule/default/tests/test_default.py
Executable 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
|
|
@ -9,10 +9,24 @@
|
||||||
- name: Install collectd
|
- name: Install collectd
|
||||||
package:
|
package:
|
||||||
name: "{{ packages }}"
|
name: "{{ packages }}"
|
||||||
|
# Important: Leave state: present, as we will overwrite the existing config
|
||||||
|
# when this task changes!
|
||||||
state: present
|
state: present
|
||||||
register: install
|
register: install
|
||||||
tags: ['collectd']
|
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
|
- name: Ensure collectd is configured
|
||||||
template:
|
template:
|
||||||
src: collectd.conf.j2
|
src: collectd.conf.j2
|
||||||
|
@ -20,8 +34,9 @@
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0640
|
mode: 0640
|
||||||
force: "{{overwrite}} or install.changed"
|
force: "{{overwrite}}"
|
||||||
tags: ['collectd']
|
tags: ['collectd']
|
||||||
|
when: install.changed == false
|
||||||
notify: restart collectd
|
notify: restart collectd
|
||||||
|
|
||||||
- name: Ensure collectd is enabled
|
- name: Ensure collectd is enabled
|
||||||
|
@ -30,4 +45,3 @@
|
||||||
state: started
|
state: started
|
||||||
enabled: true
|
enabled: true
|
||||||
tags: ['collectd']
|
tags: ['collectd']
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
---
|
---
|
||||||
# vars file for geekoops-collectd
|
# vars file for geekoops-collectd
|
||||||
|
|
Loading…
Reference in a new issue