Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GHA Workflow in order to replace TravisCI #9

Merged
merged 58 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
1acc644
feat(linter): add molecule linter
chubchubsancho Apr 12, 2022
b4aabfd
fix(gha-linter): fix run command
chubchubsancho Apr 12, 2022
e9aba8f
fix(gha-lint): step fail on run command
chubchubsancho Apr 12, 2022
97bcb1f
fi(gha-lint): remove `-it`
chubchubsancho Apr 12, 2022
3469e4e
chore(ansible-lint): configure `ansible-lint`
chubchubsancho Apr 12, 2022
b7793ed
fix(linter): fix job
chubchubsancho Apr 22, 2022
72b8ce3
fix(linter): add step to lint job
chubchubsancho Apr 22, 2022
cb8f3ed
fix(linter): fix typo in command name
chubchubsancho Apr 22, 2022
037e00d
fix(linter):
chubchubsancho Apr 25, 2022
cdc8118
fix(linter):
chubchubsancho Apr 25, 2022
8777a59
debug()
chubchubsancho Apr 25, 2022
abe0f76
fix(linter): checkout in container
chubchubsancho Apr 25, 2022
c93ab7e
fix(linter): remove needs
chubchubsancho Apr 25, 2022
fcc4e20
chore(linter): fix some errors / warning
chubchubsancho Apr 25, 2022
24b86c6
chore(linter): ansible toolset is deprecated
chubchubsancho Apr 25, 2022
5426c54
chore(molecule): move linter config to default location
chubchubsancho Apr 26, 2022
860a223
chore(linter): add empty braces
chubchubsancho Apr 26, 2022
7b9c708
clean(molecule): remove yamllint
chubchubsancho Apr 26, 2022
9e44894
chore(molecul): use real role name
chubchubsancho Apr 26, 2022
46e80d7
clean(): remove comment
chubchubsancho Apr 26, 2022
e9f4b4b
feat(test): add molecule test workflow
chubchubsancho Apr 26, 2022
bace286
ix(test): fix workflow name
chubchubsancho Apr 26, 2022
af99f07
chore(test): dynamic job name
chubchubsancho Apr 26, 2022
934d995
debug(): debug fail on `destroy`
chubchubsancho Apr 26, 2022
94eec32
chore(molecule-test): don't use `creator-ee`
chubchubsancho May 2, 2022
c97662c
chore(molecule-test): add `molecule-docker driver
chubchubsancho May 2, 2022
b93e66b
chore(molecule): add molecule requirements
chubchubsancho May 2, 2022
11f3743
fix(): type in file name
chubchubsancho May 2, 2022
880b342
fix(molecule-test): fix dependencies
chubchubsancho May 2, 2022
721efb8
fix(molecule): use requirements-files
chubchubsancho May 2, 2022
8fc9aa1
fix(molecule): add role-file
chubchubsancho May 2, 2022
5c38b6f
fix(molecule): requirement are not installed
chubchubsancho May 2, 2022
357011c
fix(molecule): fix role name
chubchubsancho May 2, 2022
c9b8845
fix(test): add env
chubchubsancho May 2, 2022
786536a
clean(molecule): remove `requiremenets-file
chubchubsancho May 2, 2022
30ef649
fix()
chubchubsancho May 2, 2022
78846de
clean()
chubchubsancho May 3, 2022
607fa3c
debug()
chubchubsancho May 3, 2022
f10cf75
chore(molecule): move requirements on molecule directory
chubchubsancho May 3, 2022
70e4b53
chore(molecule): create ansible user
chubchubsancho May 3, 2022
0257a8c
chore(molecule): add platforms parameters
chubchubsancho May 3, 2022
e58f940
fix()
chubchubsancho May 3, 2022
388e095
fix(molecule): `wheel` group does not exist
chubchubsancho May 3, 2022
351d951
fix(molecule): fix Dockerfile
chubchubsancho May 3, 2022
9e41c43
fix(): remove host_vars `ansible_users`
chubchubsancho May 3, 2022
20f21be
fix(setupVars): fix dhcp_active test
chubchubsancho May 3, 2022
f66dfd5
fix(molecule): add `pytest` and start testinfra test
chubchubsancho May 4, 2022
7785d0e
chore(molecule): disable verifier
chubchubsancho May 4, 2022
b46f05f
chore(test): remove ubuntu:22.04 as pi-hole won't install
chubchubsancho May 4, 2022
54fcb9e
chore(gha-test): emove debug on molecule
chubchubsancho May 4, 2022
f5e41cb
chore(molecule-test): better matrix
chubchubsancho May 4, 2022
e5513dd
fix(molecule-test): fix matrix
chubchubsancho May 4, 2022
8ac16ee
chore(molecule-test): remove `centos`
chubchubsancho May 4, 2022
e4dccb5
chore(molecule): use deployer group as sudoer
chubchubsancho May 4, 2022
443b063
chore(galaxy): update meta
chubchubsancho May 9, 2022
afc1a41
chore(workflow): create release based on PR label
chubchubsancho May 9, 2022
e6198b0
fix()
chubchubsancho May 9, 2022
12ee55d
chore: update role meta
chubchubsancho May 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
exclude_paths:
- .cache/
- .github/
- .git/

use_default_rules: true

mock_roles:
- pi_hole
18 changes: 18 additions & 0 deletions .github/workflows/linter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: linter

on:
pull_request: {}

jobs:
lint:
runs-on: ubuntu-20.04
container:
image: quay.io/ansible/creator-ee:v0.4.2
env:
image: ubuntu
version: 20.04
steps:
- uses: actions/checkout@v2
- name: molecule lint
run: |
molecule lint
52 changes: 52 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: release
on:
push:
branches:
- master
tags:
- "v*.*.*"
pull_request:
types:
- labeled

jobs:
release:
if: github.event.action != 'labeled'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- id: bumpr
if: "!startsWith(github.ref, 'refs/tags/')"
uses: haya14busa/action-bumpr@v1

- uses: haya14busa/action-update-semver@v1
if: "!steps.bumpr.outputs.skip"
with:
github_token: ${{ secrets.github_token }}
tag: ${{ steps.bumpr.outputs.next_version }}

- id: tag
uses: haya14busa/action-cond@v1
with:
cond: "${{ startsWith(github.ref, 'refs/tags/') }}"
if_true: ${{ github.ref }}
if_false: ${{ steps.bumpr.outputs.next_version }}

- uses: actions/create-release@v1
if: "steps.tag.outputs.value != ''"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.value }}
release_name: Release ${{ steps.tag.outputs.value }}
body: ${{ steps.bumpr.outputs.message }}
draft: false
prerelease: false

release-check:
if: github.event.action == 'labeled'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: haya14busa/action-bumpr@v1
41 changes: 41 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: test

on:
pull_request: {}

jobs:
test:
name: molecule test on ${{ matrix.image }} ${{ matrix.version }}
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- image: ubuntu
version: "18.04"
- image: ubuntu
version: "20.04"
- image: ubuntu
version: "21.10"
- image: debian
version: "9"
- image: debian
version: "10"
- image: debian
version: "11"
- image: fedora
version: "33"
- image: fedora
version: "34"
steps:
- uses: actions/checkout@v2
- name: Setup Environment
run: |
python3 -m pip install --upgrade pip
python3 -m pip install molecule["docker"] ansible-lint yamllint
- name: molecule test
env:
image: ${{ matrix.image }}
version: ${{ matrix.version }}
run: |
molecule test
27 changes: 27 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
extends: default

rules:
braces:
forbid: non-empty
min-spaces-inside: 1
max-spaces-inside: 1
min-spaces-inside-empty: 0
max-spaces-inside-empty: 0
brackets:
forbid: non-empty
min-spaces-inside: 1
max-spaces-inside: 1
min-spaces-inside-empty: 0
max-spaces-inside-empty: 0
indentation:
spaces: 2
indent-sequences: consistent
line-length:
max: 160
level: warning
allow-non-breakable-inline-mappings: true
new-lines:
type: unix
ignore: |
.github/
2 changes: 1 addition & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# handlers file for ansible-pi-hole/
- name: Restart pihole-FTL
sysvinit:
ansible.builtin.sysvinit:
name: pihole-FTL
state: restarted
54 changes: 12 additions & 42 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,31 @@ galaxy_info:
role_name: pi_hole
description: An Ansible Role to install Pi-Hole
company: chubchubsancho
namespace: chubchubsancho

# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker

# Some suggested licenses:
# - BSD (default)
# - MIT
# - GPLv2
# - GPLv3
# - Apache
# - CC-BY
license: MIT

min_ansible_version: 2.4

# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
min_ansible_version: 2.7

# Optionally specify the branch Galaxy will use when accessing the GitHub
# repo for this role. During role install, if no tags are available,
# Galaxy will use this branch. During import Galaxy will access files on
# this branch. If Travis integration is configured, only notifications for this
# branch will be accepted. Otherwise, in all cases, the repo's default branch
# (usually master) will be used.
# github_branch:

#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
platforms:
- name: Debian
versions:
- stretch
- jessie
- buster
- bullseye
- name: Ubuntu
versions:
- xenial
- yakkety
- name: EL
- bionic
- focal
- impish
- name: Fedora
versions:
- 7
- 33
- 34


galaxy_tags:
- pihole
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
- dns

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
8 changes: 8 additions & 0 deletions molecule/default/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ RUN if [ $(command -v apt-get) ]; then apt-get update && DEBIAN_FRONTEND=noninte
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install /usr/bin/python3 /usr/bin/python3-config /usr/bin/dnf-3 sudo bash iproute systemd systemd-sysv && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y /usr/bin/python /usr/bin/python2-config sudo yum-plugin-ovl bash iproute systemd systemd-sysv && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
fi

ENV ANSIBLE_USER=ansible DEPLOY_GROUP=deployer
RUN set -xe \
&& groupadd -r ${ANSIBLE_USER} \
&& groupadd -r ${DEPLOY_GROUP} \
&& useradd -m -g ${ANSIBLE_USER} ${ANSIBLE_USER} \
&& usermod -aG ${DEPLOY_GROUP} ${ANSIBLE_USER} \
&& echo "%${DEPLOY_GROUP} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
25 changes: 10 additions & 15 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
dependency:
name: galaxy
options:
role-files: requirements.yml
role-file: molecule/resources/requirements.yml
requirements-file: molecule/resources/requirements.yml

driver:
name: docker

lint: |
set -e
yamllint -c ./molecule/resources/rules/yamllint.yaml .
ansible-lint .
ansible-lint -q .

platforms:
- name: "instance"
Expand All @@ -21,6 +21,11 @@ platforms:
container: docker
groups:
- "default"
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro

provisioner:
log: true
Expand All @@ -39,17 +44,7 @@ provisioner:

scenario:
name: default
test_sequence:
- destroy
- dependency
- syntax
- create
- prepare
- converge
- idempotence
# - side_effect
# - verify
# - destroy

verifier:
name: testinfra
name: ansible
enabled: False
7 changes: 0 additions & 7 deletions molecule/default/playbook.yml

This file was deleted.

8 changes: 3 additions & 5 deletions molecule/default/tests/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')


def test_hosts_file(host):
f = host.file('/etc/hosts')
def test_prerequisites_packages(host):
p = host.package('git')

assert f.exists
assert f.user == 'root'
assert f.group == 'root'
assert p.is_installed
2 changes: 1 addition & 1 deletion molecule/resources/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
tasks:
- name: "install pi-hole"
import_role:
name: ansible-pi-hole
name: chubchubsancho.pi_hole
16 changes: 16 additions & 0 deletions molecule/resources/requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
collections:
- name: amazon.aws
- name: ansible.posix
- name: ansible.windows
- name: awx.awx
- name: azure.azcollection
- name: community.docker
- name: community.vmware
- name: containers.podman
- name: google.cloud
- name: kubernetes.core
- name: openstack.cloud
- name: ovirt.ovirt
- name: redhatinsights.insights
- name: theforeman.foreman
1 change: 0 additions & 1 deletion molecule/resources/rules/ansible-lint.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions molecule/resources/rules/yamllint.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: configure pi-hole FTL
template:
ansible.builtin.template:
src: etc/pihole/pihole-FTL.conf.j2
dest: /etc/pihole/pihole-FTL.conf
mode: 0644
Expand All @@ -11,7 +11,7 @@
- configure

- name: configure pi-hole local DNS records
template:
ansible.builtin.template:
src: etc/pihole/custom.list.j2
dest: /etc/pihole/custom.list
mode: 0644
Expand Down
2 changes: 1 addition & 1 deletion tasks/debian-prerequisites.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: "install packages"
apt:
ansible.builtin.apt:
name: "{{ pi_hole_prerequisites }}"
state: present
update_cache: true
Expand Down
Loading