Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
update build hooks
Browse files Browse the repository at this point in the history
- update github workflows
- add dependecy to ansible collections
   - bodsch.scm
   - bodsch.core
- update molecule config
- update doc
  • Loading branch information
bodsch committed May 10, 2023
1 parent 1d69045 commit c83e667
Show file tree
Hide file tree
Showing 26 changed files with 169 additions and 128 deletions.
35 changes: 29 additions & 6 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,45 @@
name: code linter

on:
schedule:
- cron: "40 0 * * 0"
workflow_dispatch:
pull_request:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
push:
branches:
- main
- testing
- feature/**
- 'main'
- 'feature/**'
- '!doc/**'
paths:
- "!Makefile"
- "!README.md"
- "tasks/**"
pull_request:
branches:
- 'main'
- 'feature/**'
- '!doc/**'
paths:
- "!Makefile"
- "!README.md"
- "tasks/**"

jobs:
lint:
name: linting
runs-on: ubuntu-latest
steps:
- name: 🛎 Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: lint
uses: docker://ghcr.io/github/super-linter:slim-v4
Expand Down
26 changes: 14 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@
name: CI

on:
schedule:
- cron: "0 1 * * 0"
workflow_dispatch:
workflow_run:
workflows:
- "code linter"
branches:
- main
- feature/**
types:
- completed

Expand All @@ -29,8 +23,9 @@ jobs:
image:
- archlinux:latest
ansible-version:
- '5.1'
- '6.1'
scenario:
- default

steps:
- name: check out the codebase.
Expand All @@ -50,8 +45,11 @@ jobs:
- name: test with tox
run: |
tox -e ansible_$(printf "${{ matrix.ansible-version }}") \
-- molecule test --scenario-name default
make \
test \
-e TOX_SCENARIO="${{ matrix.scenario }}" \
-e TOX_ANSIBLE="ansible_${{ matrix.ansible-version }}" \
-e DISTRIBUTION="${{ matrix.image }}"
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
Expand All @@ -69,8 +67,9 @@ jobs:
- debian:11
- ubuntu:20.04
ansible-version:
- '5.1'
- '6.1'
scenario:
- default

steps:
- name: check out the codebase.
Expand All @@ -90,8 +89,11 @@ jobs:
- name: test with tox
run: |
tox -e ansible_$(printf "${{ matrix.ansible-version }}") \
-- molecule test --scenario-name default
make \
test \
-e TOX_SCENARIO="${{ matrix.scenario }}" \
-e TOX_ANSIBLE="ansible_${{ matrix.ansible-version }}" \
-e DISTRIBUTION="${{ matrix.image }}"
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#
export TOX_SCENARIO ?= default
# export TOX_PYTHON ?= py310
export TOX_ANSIBLE ?= ansible_6.1

.PHONY: converge destroy verify lint
.PHONY: converge destroy verify test lint

default: converge

Expand All @@ -16,5 +15,8 @@ destroy:
verify:
@hooks/verify

test:
@hooks/test

lint:
@hooks/lint
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ This ansible role installs and configure Trickster.
[releases]: https://github.com/bodsch/ansible-trickster/releases
[quality]: https://galaxy.ansible.com/bodsch/trickster

## Requirements & Dependencies

Ansible Collections

- [bodsch.core](https://github.com/bodsch/ansible-collection-core)
- [bodsch.scm](https://github.com/bodsch/ansible-collection-scm)

```bash
ansible-galaxy collection install bodsch.core
ansible-galaxy collection install bodsch.scm
```
or
```bash
ansible-galaxy collection install --requirements-file collections.yml
```


## Usage

Expand Down
6 changes: 6 additions & 0 deletions collections.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---

collections:
- name: bodsch.core
version: ">=1.0.17"
- name: bodsch.scm
28 changes: 0 additions & 28 deletions filter_plugins/types.py

This file was deleted.

4 changes: 1 addition & 3 deletions hooks/converge
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env bash

. hooks/_tox_base

tox ${TOX_OPTS} -- molecule converge ${TOX_ARGS}
hooks/tox.sh "converge"
4 changes: 1 addition & 3 deletions hooks/destroy
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env bash

. hooks/_tox_base

tox ${TOX_OPTS} -- molecule destroy ${TOX_ARGS}
hooks/tox.sh "destroy"
4 changes: 1 addition & 3 deletions hooks/lint
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env bash

. hooks/_tox_base

tox ${TOX_OPTS} -- molecule lint ${TOX_ARGS}
hooks/tox.sh "lint"
File renamed without changes.
3 changes: 3 additions & 0 deletions hooks/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

hooks/tox.sh "test"
26 changes: 26 additions & 0 deletions hooks/tox.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

. hooks/molecule.rc

TOX_TEST="${1}"

if [ -f "./collections.yml" ]
then
for collection in $(grep -v "#" collections.yml | grep "^ - name: " | awk -F ': ' '{print $2}')
do
collections_installed="$(ansible-galaxy collection list | grep ${collection} 2> /dev/null)"

if [ -z "${collections_installed}" ]
then
echo "Install the required collection '${collection}'"
ansible-galaxy collection install ${collection}
else
collection_version=$(echo "${collections_installed}" | awk -F ' ' '{print $2}')

echo "The required collection '${collection}' is installed in version ${collection_version}."
fi
done
echo ""
fi

tox ${TOX_OPTS} -- molecule ${TOX_TEST} ${TOX_ARGS}
4 changes: 1 addition & 3 deletions hooks/verify
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env bash

. hooks/_tox_base

tox ${TOX_OPTS} -- molecule verify ${TOX_ARGS}
hooks/tox.sh "verify"
5 changes: 4 additions & 1 deletion molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
- hosts: instance

- name: converge
hosts: instance
any_errors_fatal: false
become: false

environment:
NETRC: ''
Expand Down
10 changes: 7 additions & 3 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ platforms:
docker_networks:
- name: prometheus
ipam_config:
- subnet: "10.11.0.0/16"
- subnet: "10.11.0.0/24"
gateway: "10.11.0.254"
networks:
- name: prometheus
Expand Down Expand Up @@ -57,12 +57,16 @@ provisioner:
name: ansible
ansible_args:
- --diff
# - -vv
- -v
config_options:
defaults:
deprecation_warnings: True
deprecation_warnings: true
stdout_callback: yaml
callbacks_enabled: profile_tasks
gathering: smart
fact_caching: jsonfile
fact_caching_timeout: 8640
fact_caching_connection: ansible_facts

scenario:
test_sequence:
Expand Down
34 changes: 24 additions & 10 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
---
- name: prepare container

- name: information
hosts: all
gather_facts: true

pre_tasks:
- name: arch- / artixlinux
when:
- ansible_distribution | lower == 'archlinux' or
ansible_os_family | lower == 'artix linux'
block:
- name: update pacman system
ansible.builtin.command: |
pacman --refresh --sync --sysupgrade --noconfirm
- name: create depends service
ansible.builtin.copy:
mode: 0755
dest: /etc/init.d/net
content: |
#!/usr/bin/openrc-run
true
when:
- ansible_os_family | lower == 'artix linux'

- name: update package cache
package:
become: true
ansible.builtin.package:
update_cache: true

- name: install netstat
package:
name: [ net-tools, iproute2 ]
state: present
when:
- ansible_os_family | lower in [ 'archlinux', 'debian' ]

- debug:
- name: environment
ansible.builtin.debug:
msg:
- "os family : {{ ansible_distribution }} ({{ ansible_os_family }})"
- "distribution version : {{ ansible_distribution_major_version }}"
Expand Down
4 changes: 2 additions & 2 deletions molecule/default/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

- name: prometheus
src: bodsch.prometheus
version: 1.1.3
version: 1.5.0

- name: redis
src: bodsch.redis
version: 1.2.0
version: 1.4.0

...
10 changes: 5 additions & 5 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
notify:
- reload trickster

- name: create local facts
ansible.builtin.template:
src: ansible_facts.j2
dest: /etc/ansible/facts.d/trickster.fact
mode: 0755
- name: create custom fact file
bodsch.core.facts:
name: trickster
facts:
version: "{{ trickster_version }}"

- name: create link to binary
ansible.builtin.file:
Expand Down
Loading

0 comments on commit c83e667

Please sign in to comment.