added gitea actions, debian12 support, moved to ansible for testing
All checks were successful
test / Linting (push) Successful in 29s
test / Molecule tests (default, ubuntu2004) (push) Successful in 1m12s
test / Molecule tests (default, debian12) (push) Successful in 1m28s
test / Molecule tests (default, debian11) (push) Successful in 1m39s
test / Molecule tests (default, ubuntu2204) (push) Successful in 1m7s
test / Molecule tests (with_custom_packages, debian11) (push) Successful in 1m19s
test / Molecule tests (with_custom_packages, debian12) (push) Successful in 1m33s
test / Molecule tests (with_custom_packages, ubuntu2004) (push) Successful in 1m24s
test / Molecule tests (with_custom_packages, ubuntu2204) (push) Successful in 1m28s
All checks were successful
test / Linting (push) Successful in 29s
test / Molecule tests (default, ubuntu2004) (push) Successful in 1m12s
test / Molecule tests (default, debian12) (push) Successful in 1m28s
test / Molecule tests (default, debian11) (push) Successful in 1m39s
test / Molecule tests (default, ubuntu2204) (push) Successful in 1m7s
test / Molecule tests (with_custom_packages, debian11) (push) Successful in 1m19s
test / Molecule tests (with_custom_packages, debian12) (push) Successful in 1m33s
test / Molecule tests (with_custom_packages, ubuntu2004) (push) Successful in 1m24s
test / Molecule tests (with_custom_packages, ubuntu2204) (push) Successful in 1m28s
This commit is contained in:
parent
0c293f260b
commit
9080afb28d
52
.gitea/workflows/test.yml
Normal file
52
.gitea/workflows/test.yml
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
---
|
||||||
|
name: test
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
name: Linting
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: git.ednz.fr/container-factory/ansible-runner:act-latest
|
||||||
|
credentials:
|
||||||
|
username: ${{ secrets.ACTIONS_USER }}
|
||||||
|
password: ${{ secrets.ACTIONS_TOKEN }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: "Ansible lint"
|
||||||
|
run: ansible-lint --force-color
|
||||||
|
working-directory: ${{ gitea.workspace }}
|
||||||
|
|
||||||
|
- name: "YAML lint"
|
||||||
|
run: yamllint . -f colored -c .yamllint
|
||||||
|
working-directory: ${{ gitea.workspace }}
|
||||||
|
|
||||||
|
molecule-test:
|
||||||
|
name: Molecule tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: lint
|
||||||
|
container:
|
||||||
|
image: git.ednz.fr/container-factory/ansible-runner:act-latest
|
||||||
|
credentials:
|
||||||
|
username: ${{ secrets.ACTIONS_USER }}
|
||||||
|
password: ${{ secrets.ACTIONS_TOKEN }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
test_os: [debian11, debian12, ubuntu2004, ubuntu2204]
|
||||||
|
scenario: [default, with_custom_packages]
|
||||||
|
env:
|
||||||
|
ANSIBLE_HOST_KEY_CHECKING: 'false'
|
||||||
|
ANSIBLE_FORCE_COLOR: 'true'
|
||||||
|
ANSIBLE_PYTHON_INTERPRETER: /usr/bin/python3
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: "Molecule test"
|
||||||
|
run: molecule test -s ${{ matrix.scenario }}
|
||||||
|
shell: bash
|
||||||
|
working-directory: ${{ gitea.workspace }}
|
||||||
|
env:
|
||||||
|
MOLECULE_TEST_OS: ${{ matrix.test_os }}
|
@ -1,82 +0,0 @@
|
|||||||
---
|
|
||||||
stages:
|
|
||||||
- verify
|
|
||||||
- test-default
|
|
||||||
- test-with-custom-packages
|
|
||||||
|
|
||||||
image:
|
|
||||||
name: registry.ednz.fr/forge/ansible-runner
|
|
||||||
|
|
||||||
variables:
|
|
||||||
ANSIBLE_HOST_KEY_CHECKING: 'false'
|
|
||||||
ANSIBLE_FORCE_COLOR: 'true'
|
|
||||||
ANSIBLE_PYTHON_INTERPRETER: /usr/bin/python3
|
|
||||||
DOCKER_AUTH_CONFIG: $CI_DOCKER_AUTH_CONFIG
|
|
||||||
|
|
||||||
.stage-test-default:
|
|
||||||
stage: test-default
|
|
||||||
|
|
||||||
.stage-test-with-custom-packages:
|
|
||||||
stage: test-with-custom-packages
|
|
||||||
|
|
||||||
.variables-ubuntu-2004:
|
|
||||||
variables:
|
|
||||||
MOLECULE_TEST_OS: "ubuntu2004"
|
|
||||||
|
|
||||||
.variables-ubuntu-2204:
|
|
||||||
variables:
|
|
||||||
MOLECULE_TEST_OS: "ubuntu2204"
|
|
||||||
|
|
||||||
.variables-debian-11:
|
|
||||||
variables:
|
|
||||||
MOLECULE_TEST_OS: "debian11"
|
|
||||||
|
|
||||||
.script-molecule-test-default:
|
|
||||||
script:
|
|
||||||
- molecule test
|
|
||||||
|
|
||||||
.script-molecule-test-with-custom-packages:
|
|
||||||
script:
|
|
||||||
- molecule test -s with_custom_packages
|
|
||||||
|
|
||||||
ansible-verify:
|
|
||||||
stage: verify
|
|
||||||
script:
|
|
||||||
- yamllint . -c .yamllint
|
|
||||||
- ansible-lint
|
|
||||||
|
|
||||||
ansible-test-ubuntu-2004-default:
|
|
||||||
extends:
|
|
||||||
- .stage-test-default
|
|
||||||
- .variables-ubuntu-2004
|
|
||||||
- .script-molecule-test-default
|
|
||||||
|
|
||||||
ansible-test-ubuntu-2204-default:
|
|
||||||
extends:
|
|
||||||
- .stage-test-default
|
|
||||||
- .variables-ubuntu-2204
|
|
||||||
- .script-molecule-test-default
|
|
||||||
|
|
||||||
ansible-test-debian-11-default:
|
|
||||||
extends:
|
|
||||||
- .stage-test-default
|
|
||||||
- .variables-debian-11
|
|
||||||
- .script-molecule-test-default
|
|
||||||
|
|
||||||
ansible-test-ubuntu-2004-with-custom-packages:
|
|
||||||
extends:
|
|
||||||
- .stage-test-with-custom-packages
|
|
||||||
- .variables-ubuntu-2004
|
|
||||||
- .script-molecule-test-with-custom-packages
|
|
||||||
|
|
||||||
ansible-test-ubuntu-2204-with-custom-packages:
|
|
||||||
extends:
|
|
||||||
- .stage-test-with-custom-packages
|
|
||||||
- .variables-ubuntu-2204
|
|
||||||
- .script-molecule-test-with-custom-packages
|
|
||||||
|
|
||||||
ansible-test-debian-11-with-custom-packages:
|
|
||||||
extends:
|
|
||||||
- .stage-test-with-custom-packages
|
|
||||||
- .variables-debian-11
|
|
||||||
- .script-molecule-test-with-custom-packages
|
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2017 Jeff Geerling
|
Copyright (c) 2017 Bertrand Lanson
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
this software and associated documentation files (the "Software"), to deal in
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
Manage apt packages
|
manage_apt_packages
|
||||||
=========
|
=========
|
||||||
> This repository is only a mirror. Development and testing is done on a private gitlab server.
|
> This repository is only a mirror. Development and testing is done on a private gitea server.
|
||||||
|
|
||||||
This role enables you to manage packages on **debian-based** distributions. It can be used on its own , or be called by other roles the install/remove packages on demand.
|
This role enables you to manage packages on **debian-based** distributions. It can be used on its own , or be called by other roles the install/remove packages on demand.
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ galaxy_info:
|
|||||||
- name: Debian
|
- name: Debian
|
||||||
versions:
|
versions:
|
||||||
- bullseye
|
- bullseye
|
||||||
|
- bookworm
|
||||||
galaxy_tags:
|
galaxy_tags:
|
||||||
- 'ubuntu'
|
- 'ubuntu'
|
||||||
- 'debian'
|
- 'debian'
|
||||||
|
@ -20,12 +20,11 @@
|
|||||||
|
|
||||||
- name: "Test: package vim"
|
- name: "Test: package vim"
|
||||||
block:
|
block:
|
||||||
- name: "Command apt list vim"
|
- name: "Get packages facts"
|
||||||
ansible.builtin.command: "apt list vim"
|
ansible.builtin.package_facts:
|
||||||
changed_when: false
|
manager: auto
|
||||||
register: apt_list_vim
|
|
||||||
|
|
||||||
- name: "Verify package vim"
|
- name: "Verify package vim"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "'[installed]' in apt_list_vim.stdout"
|
- "'{{ ansible_facts.packages['vim'][0]['name'] }}' == 'vim'"
|
||||||
|
@ -20,7 +20,7 @@ provisioner:
|
|||||||
defaults:
|
defaults:
|
||||||
remote_tmp: /tmp/.ansible
|
remote_tmp: /tmp/.ansible
|
||||||
verifier:
|
verifier:
|
||||||
name: testinfra
|
name: ansible
|
||||||
scenario:
|
scenario:
|
||||||
name: with_custom_packages
|
name: with_custom_packages
|
||||||
test_sequence:
|
test_sequence:
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
"""PyTest Fixtures."""
|
|
||||||
from __future__ import absolute_import
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
def pytest_runtest_setup(item):
|
|
||||||
"""Run tests only when under molecule with testinfra installed."""
|
|
||||||
try:
|
|
||||||
import testinfra
|
|
||||||
except ImportError:
|
|
||||||
pytest.skip("Test requires testinfra", allow_module_level=True)
|
|
||||||
if "MOLECULE_INVENTORY_FILE" in os.environ:
|
|
||||||
pytest.testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
|
||||||
os.environ["MOLECULE_INVENTORY_FILE"]
|
|
||||||
).get_hosts("all")
|
|
||||||
else:
|
|
||||||
pytest.skip(
|
|
||||||
"Test should run only from inside molecule.", allow_module_level=True
|
|
||||||
)
|
|
@ -1,19 +0,0 @@
|
|||||||
"""Role testing files using testinfra."""
|
|
||||||
|
|
||||||
|
|
||||||
def test_hosts_file(host):
|
|
||||||
"""Validate /etc/hosts file."""
|
|
||||||
etc_hosts = host.file("/etc/hosts")
|
|
||||||
assert etc_hosts.exists
|
|
||||||
assert etc_hosts.user == "root"
|
|
||||||
assert etc_hosts.group == "root"
|
|
||||||
|
|
||||||
def test_packages_is_installed(host):
|
|
||||||
"""Validate mariadb-server, apache2 and consul are installed"""
|
|
||||||
apt_package_mariadb = host.package("mariadb-server")
|
|
||||||
apt_package_apache2 = host.package("apache2")
|
|
||||||
apt_package_consul = host.package("consul")
|
|
||||||
assert apt_package_mariadb.is_installed
|
|
||||||
assert apt_package_apache2.is_installed
|
|
||||||
assert apt_package_consul.is_installed
|
|
||||||
assert apt_package_consul.version == "1.13.1-1"
|
|
@ -18,30 +18,16 @@
|
|||||||
- stat_etc_hosts.stat.pw_name == 'root'
|
- stat_etc_hosts.stat.pw_name == 'root'
|
||||||
- stat_etc_hosts.stat.gr_name == 'root'
|
- stat_etc_hosts.stat.gr_name == 'root'
|
||||||
|
|
||||||
- name: "Test: package mariadb-server, apache2, consul:1.13.1-1"
|
- name: "Test: packages mariadb-server, apache2, consul:1.13.1-1"
|
||||||
block:
|
block:
|
||||||
- name: "Command apt list mariadb-server"
|
- name: "Get packages facts"
|
||||||
ansible.builtin.command: "apt list mariadb-server"
|
ansible.builtin.package_facts:
|
||||||
changed_when: false
|
manager: auto
|
||||||
register: apt_list_mariadb_server
|
|
||||||
|
|
||||||
- name: "Command apt list apache2"
|
- name: "Verify packages mariadb-server, apache2, consul:1.13.1-1"
|
||||||
ansible.builtin.command: "apt list apache2"
|
|
||||||
changed_when: false
|
|
||||||
register: apt_list_apache2
|
|
||||||
|
|
||||||
- name: "Command apt list consul"
|
|
||||||
ansible.builtin.command: "apt-cache policy consul"
|
|
||||||
changed_when: false
|
|
||||||
register: apt_cache_policy_consul
|
|
||||||
|
|
||||||
- name: "Debug"
|
|
||||||
vars:
|
|
||||||
consul_yaml: "{{ (apt_cache_policy_consul.stdout|to_yaml|from_yaml) }}"
|
|
||||||
ansible.builtin.debug:
|
|
||||||
msg: "{{ consul_yaml|to_yaml }}"
|
|
||||||
|
|
||||||
- name: "Verify package vim"
|
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "'[installed]' in apt_list_vim.stdout"
|
- "'{{ ansible_facts.packages['mariadb-server'][0]['name'] }}' == 'mariadb-server'"
|
||||||
|
- "'{{ ansible_facts.packages['apache2'][0]['name'] }}' == 'apache2'"
|
||||||
|
- "'{{ ansible_facts.packages['consul'][0]['name'] }}' == 'consul'"
|
||||||
|
- "'{{ ansible_facts.packages['consul'][0]['version'] }}' == '1.13.1-1'"
|
||||||
|
Loading…
Reference in New Issue
Block a user