-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from tomeon/embedded-distro-tests
Add support for testing on embedded distributions
- Loading branch information
Showing
36 changed files
with
1,250 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Ignore files and directories when creating archives with `git archive`. | ||
# This will exclude matching files from the role as distributed on Ansible | ||
# Galaxy. | ||
|
||
/.github/ export-ignore | ||
/.github/** export-ignore | ||
/scripts/ export-ignore | ||
/scripts/** export-ignore | ||
/tmp/ export-ignore | ||
/tmp/** export-ignore | ||
/vagrant/ export-ignore | ||
/vagrant/** export-ignore | ||
|
||
# XXX do not exclude the `/tests/` hierarchy, as doing so breaks GitHub | ||
# Actions. That is, do not do this: | ||
# /tests/ export-ignore | ||
# /tests/** export-ignore | ||
|
||
*.nix export-ignore | ||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
.travis.yml export-ignore | ||
CONTRIBUTING.md export-ignore | ||
Vagrantfile export-ignore | ||
event.json export-ignore | ||
flake.lock export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
/.vagrant/ | ||
|
||
# Vagrant boxes | ||
*.box | ||
|
||
# Disk images | ||
*.img | ||
*.qcow2 | ||
|
||
# libvirt domain log files | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Changelog for `jose1711.kodi_ansible_role` | ||
|
||
This file lists all notable changes to this project. | ||
|
||
## Unreleased | ||
|
||
### Added | ||
|
||
- Support for Alpine Linux (#8). | ||
- Project contribution guide (#8). | ||
- Support `system` boolean and `gid` numeric attributes in `kodi_groups` | ||
entries, permitting greater end-user control over group creation logic (#8). | ||
- Add the new `kodi_service` variable for managing the Kodi service, | ||
emphasizing that this role supports both system and non-systemd service | ||
managers (#8). | ||
|
||
### Changed | ||
|
||
- Create (if necessary) all groups in `kodi_groups` (#8). | ||
- Use the `service` module rather than the `systemd` for managing the Kodi | ||
service, thus supporting (e.g.) OpenRC on Alpine Linux (#8). | ||
- Deprecate (but do not yet remove or ignore) the `kodi_systemd_service` | ||
variable in favor of using the newly-introduced `kodi_service` variable (#8). | ||
- Exclude testing- and development-only files from the role archive distributed | ||
via Ansible Galaxy (#8). | ||
|
||
### Fixed | ||
|
||
- Use `root` as `kodi_user` on LibreELEC (#8). | ||
- Use the `wait_for` module instead of the `pause` module; now it should be | ||
possible to apply this role under the `free` strategy (#8). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
[`tests/test.yml`]: /tests/test.yml | ||
[`.github/workflows/ci.yml`]: /.github/workflows/ci.yml | ||
[Nix development shell]: #nix-development-shell | ||
|
||
# Contributing to `jose1711.kodi_ansible_role` | ||
|
||
## Nix development shell | ||
|
||
This project includes a development environment using the [Nix package | ||
manager](https://nixos.org). The environment provides tools for working with | ||
the `jose1711.kodi-ansible-role` codebase, including Ansible itself, plus | ||
[Vagrant](#vagrant-environment) and helpers for executing [GitHub Actions | ||
jobs](#github-actions-suite). | ||
|
||
Please see [here](https://nixos.org/download#download-nix) for instructions on | ||
installing the Nix package manager, and see | ||
[here](https://nix.dev/tutorials/first-steps/) for a getting-started-with-Nix | ||
tutorial. | ||
|
||
Once you have installed the Nix package manager, you can enter the | ||
Nix development shell by running the following command from inside this | ||
project's working tree: | ||
|
||
```console | ||
$ nix --extra-experimental-features 'flakes nix-command' develop | ||
``` | ||
|
||
This will start a new shell with development tooling available (print the value | ||
of the `PATH` environment variable inside the shell for some of the gory | ||
details). | ||
|
||
When you are done with your development environment, you can exit the shell as | ||
usual (press `<ctrl-d>`, or run `exit`). | ||
|
||
## Vagrant environment | ||
|
||
This project includes a Vagrant environment for testing the | ||
`jose1711.kodi_ansible_role` Ansible role on several Linux distributions. As | ||
of this writing, those distributions are: | ||
|
||
1. Alpine Linux (3.19) | ||
2. Arch Linux | ||
3. Debian (12 (bookworm)) | ||
4. Ubuntu (22.04 LTS (Jammy Jellyfish)) | ||
5. LibreELEC (11.0.6) | ||
6. OSMC (20240205) | ||
|
||
This Vagrant environment supports the | ||
[`libvirt` provider](https://vagrant-libvirt.github.io/vagrant-libvirt/)[^provider-support]. | ||
|
||
[^provider-support]: Some of the Vagrant boxes employed in this environment may | ||
support other providers, but the LibreELEC and OSMC boxes | ||
support **only** `libvirt`. | ||
|
||
To use this Vagrant environment, you will need to install Vagrant itself, as | ||
well as the `vagrant-libvirt` provider plugin[^vagrant-in-nix-devshell]. Please | ||
see the [`vagrant-libvirt` installation instructions](https://vagrant-libvirt.github.io/vagrant-libvirt/installation.html) | ||
for guidance on installing and using the provider plugin. | ||
|
||
[^vagrant-in-nix-devshell]: The [Nix development shell][] provides the | ||
`vagrant` executable and the `vagrant-libvirt` | ||
provider plugin. | ||
|
||
Vagrant provisions its machines using the [`tests/test.yml`][] playbook, which | ||
installs the prerequisites for running Ansible against those machines and then | ||
applies this Ansible role. | ||
|
||
> [!IMPORTANT] | ||
> If you add support for a new distribution to this Ansible role, please try to | ||
> add a Vagrant guest that runs this distribution, and, if necessary, update | ||
> [`tests/test.yml`][] to install Ansible's dependencies on this guest. | ||
> Additionally, please add a description of the distribution to the list above. | ||
### Just-in-time Vagrant box builds | ||
|
||
The LibreELEC and OSMC machines use custom Vagrant boxes built with scripts | ||
that live in this project | ||
([`create-libreelec-box`](/scripts/create-libreelec-box) and | ||
[`create-osmc-box`](/scripts/create-osmc-box), respectively). The Vagrant | ||
environment is configured to build these boxes on-demand; effectively, the | ||
boxes are built upon `vagrant up` if they are not already installed. This | ||
means that, in order to run these machines, you'll need to ensure that all | ||
box-building prerequisites are available on your Vagrant host | ||
system[^box-building-in-nix-devshell]. | ||
|
||
[^box-building-in-nix-devshell]: The [Nix development shell][] provides all of | ||
these prerequisites. | ||
|
||
#### Using OSMC under Vagrant | ||
|
||
The OSMC box requires some special handling: | ||
|
||
1. OSMC publishes images for a small number of platforms and architectures | ||
([Raspberry Pi, Vero, and Apple TV](https://osmc.tv/download/)); there are | ||
no prebuilt `x86_64` images (as there are [for LibreELEC](https://archive.libreelec.tv/archive/)). | ||
2. The kernel included in OSMC images does not support certain modules required | ||
for proper operation under [QEMU's `virt` Generic Virtual Platform](https://www.qemu.org/docs/master/system/riscv/virt.html). | ||
|
||
To avoid having to run the OSMC guest under [QEMU's Raspberry Pi board emulation](https://www.qemu.org/docs/master/system/arm/raspi.html), | ||
which is effective but very slow, we instead build a custom kernel and initial | ||
RAM disk for the `aarch64` architecture and run the guest using the `virt` | ||
platform. This makes the OSMC guest run faster, but comes with some downsides: | ||
|
||
1. The kernel and initial RAM disk are built with [the NixOS module | ||
system](https://nix.dev/tutorials/module-system/module-system.html), and | ||
building the OSMC Vagrant box therefore requires installing and running the | ||
Nix package manager. | ||
2. If the `libvirt` daemon runs as an unprivileged user, it may not be able to | ||
load the kernel and initial RAM disk from the location under | ||
[`VAGRANT_HOME`](https://developer.hashicorp.com/vagrant/docs/other/environmental-variables#vagrant_home) | ||
where Vagrant extracted the `.box` file, so the OSMC box includes a | ||
`Vagrantfile` that, among other things, copies the kernel and initial RAM | ||
disk to a world-readable location before Vagrant boots the OSMC guest (and | ||
attempts to clean up these files before Vagrant exits). | ||
|
||
> [!WARNING] | ||
> There is a bug in Vagrant that may cause problems on the first boot of the | ||
> OSMC machine. If the first `vagrant up` (or `vagrant up osmc`) hangs or | ||
> crashes, please try re-running the command. | ||
## GitHub Actions suite | ||
|
||
This project uses [GitHub Actions](https://docs.github.com/en/actions) for | ||
automated testing. The main workflow definition is | ||
[`.github/workflows/ci.yml`][]. As of this writing, the workflow applies this | ||
Ansible role to containers based upon the following images: | ||
|
||
1. `alpine:3` | ||
2. `archlinux/archlinux` | ||
3. `debian:11` | ||
4. `debian:12` | ||
5. `ubuntu:22.04` | ||
6. `ubuntu:23.04` | ||
|
||
Please ensure that the workflow succeeds when run against your branch. | ||
|
||
You can run the GitHub Actions workflow locally using | ||
[`act`](https://github.com/nektos/act):[^act-in-nix-devshell] | ||
|
||
[^act-in-nix-devshell]: The [Nix development shell][] provides the `act` | ||
executable. | ||
|
||
```console | ||
$ act -j native | ||
``` | ||
|
||
This will run the `native` job from [`.github/workflows/ci.yml`][]. | ||
|
||
> [!IMPORTANT] | ||
> If you add support for a new distribution to this Ansible role, please try to | ||
> find a Docker image that uses this distribution and add it to the list of | ||
> images in [`.github/workflows/ci.yml`][], and, if necessary, update | ||
> [`tests/test.yml`][] to install Ansible's dependencies on containers using | ||
> this image. Additionally, please add the new image to the list above. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.