Skip to content

Commit

Permalink
Add molecule tests to collection (#42)
Browse files Browse the repository at this point in the history
* Add molecule tests to collection
* Update galaxy.yml

Fixes #41

For now we'll restrict tests to basic tasks only run on CentOS 7 to save resources. We might add more OS/versions and have more sophisticated tests in the future.

Co-authored-by: Thilo W <mkayontour@users.noreply.github.com>
  • Loading branch information
widhalmt and mkayontour authored Jul 4, 2021
1 parent d90545d commit 4523a79
Show file tree
Hide file tree
Showing 15 changed files with 125 additions and 52 deletions.
2 changes: 2 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
skip_list:
- 'yaml'
48 changes: 48 additions & 0 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
name: CI
on:
push:
tags:
- v*
branches:
- main
pull_request:

jobs:
build:
runs-on: ubuntu-latest

env:
COLLECTION_NAMESPACE: icinga
COLLECTION_NAME: icinga

strategy:
# max-parallel: 4
matrix:
distro: [centos7, centos8, debian10]
scenario: [default]

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements-test.txt
- name: Install collection
run: |
mkdir -p ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE
cp -a ../ansible-collection-$COLLECTION_NAME ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME
- name: Test with molecule
run: |
molecule test -s ${{ matrix.scenario }}
env:
MOLECULE_DISTRO: ${{ matrix.distro }}
2 changes: 2 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
extends: relaxed
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ansible-collection-icinga

[![CI](https://github.com/Icinga/ansible-collection-icinga/workflows/CI/badge.svg?event=push)](https://github.com/Icinga/ansible-collection-icinga/actions/workflows/molecule.yml/badge.svg)

Collection to setup and manage components of the Icinga software stack.

## Roles
Expand Down
57 changes: 10 additions & 47 deletions galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,21 @@
### REQUIRED

# The namespace of the collection. This can be a company/brand/organization or product namespace under which all
# content lives. May only contain alphanumeric lowercase characters and underscores. Namespaces cannot start with
# underscores or numbers and cannot contain consecutive underscores
namespace: icinga

# The name of the collection. Has the same character restrictions as 'namespace'
name: icinga

# The version of the collection. Must be compatible with semantic versioning
version: 0.1.0

# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md

# A list of the collection's content authors. Can be just the name or in the format 'Full Name <email> (url)
# @nicks:irc/im.site#channel'
authors:
- Lennart Betz <lennart.betz@netways.de>
- Thilo Wening <thilo.wening@netways.de>


### OPTIONAL but strongly recommended

# A short summary description of the collection
description: your collection description

# Either a single license or a list of licenses for content inside of a collection. Ansible Galaxy currently only
# accepts L(SPDX,https://spdx.org/licenses/) licenses. This key is mutually exclusive with 'license_file'
- Thomas Widhalm <thomas.widhalm@netways.de>
description: >
This collection manages all Icinga 2 Components.
Including the official repositories, server, satellite and agent installations.
Furthermore it can easily create and distribute monitoring configuration.
license:
- GPL-3.0-or-later

# The path to the license file for the collection. This path is relative to the root of the collection. This key is
# mutually exclusive with 'license'
license_file: 'LICENSE'

# A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character
# requirements as 'namespace' and 'name'
tags: []

# Collections that this collection requires to be installed for it to be usable. The key of the dict is the
# collection label 'namespace.name'. The value is a version range
# L(specifiers,https://python-semanticversion.readthedocs.io/en/latest/#requirement-specification). Multiple version
# range specifiers can be set and are separated by ','
tags: [ 'icinga2','monitoring','icingaweb2','agent','master','server','satellite']
dependencies: {}

# The URL of the originating SCM repository
repository: http://example.com/repository

# The URL to any online docs
documentation: http://docs.example.com

# The URL to the homepage of the collection/project
homepage: http://example.com

# The URL to the collection issue tracker
issues: http://example.com/issue/tracker
repository: https://github.com/Icinga/ansible-collection-icinga
documentation: https://github.com/Icinga/ansible-collection-icinga/tree/main/doc
homepage: http://icinga.com
issues: https://github.com/Icinga/ansible-collection-icinga/issues
13 changes: 13 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---

- name: Converge
hosts: all
collections:
icinga.icinga
tasks:
- name: "Include Icinga Repos"
include_role:
name: repos
- name: "Include Icinga 2"
include_role:
name: icinga2
21 changes: 21 additions & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: icinga-default
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
provisioner:
name: ansible
verifier:
name: ansible
lint: |
set -e
yamllint .
ansible-lint .
10 changes: 10 additions & 0 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Prepare
hosts: all
tasks:
- name: Install requirements for Debian
package:
name:
- gpg
- apt-transport-https
when: ansible_os_family == "Debian"
9 changes: 9 additions & 0 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---

- name: Verify
hosts: all
tasks:
- name: Check for running icinga2
service:
name: icinga2
state: started
4 changes: 4 additions & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ansible
ansible-lint
molecule
molecule-docker
2 changes: 1 addition & 1 deletion roles/icinga2/tasks/features/idomysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
loop: "{{ icinga2_dict_features.idomysql |dict2items }}"
loop_control:
loop_var: idx

- name: feature idomysql IdoMysqlConnection object
icinga2_object:
name: ido-mysql
Expand Down
2 changes: 1 addition & 1 deletion roles/icinga2/tasks/features/idopgsql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
loop: "{{ icinga2_dict_features.idopgsql |dict2items }}"
loop_control:
loop_var: idx

- name: feature idopgsql IdoPgsqlConnection object
icinga2_object:
name: ido-pgsql
Expand Down
2 changes: 1 addition & 1 deletion roles/icinga2/tasks/features/syslog.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---

- name: feature syslog SyslogLogger object
icinga2_object:
name: syslog
Expand Down
2 changes: 1 addition & 1 deletion roles/repos/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
# handlers file for icinga_repos
# handlers file for icinga_repos
1 change: 0 additions & 1 deletion roles/repos/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,3 @@ galaxy_info:
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.

0 comments on commit 4523a79

Please sign in to comment.