Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/robinwalterfit/docker-almalinux9-ansible

AlmaLinux 9 Docker container for Ansible playbook and role testing.
https://github.com/robinwalterfit/docker-almalinux9-ansible

alma-linux ansible centos docker linux molecule testing

Last synced: 4 days ago
JSON representation

AlmaLinux 9 Docker container for Ansible playbook and role testing.

Awesome Lists containing this project

README

        

Docker AlmaLinux 9 Ansible



AlmaLinux 9 Docker image for Ansible playbook and role testing.




Conventional Commits

License MIT

Contributor Covenant


AlmaLinux


Docker


Docker pulls


GitHub Actions


GitHub Actions - Build & Push Status


lefthook


Taskfile


MegaLinter

Table of Contents

- [Getting Started](#getting-started)
- [Tags](#tags)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Usage](#usage)
- [Development](#development)
- [Build the Project](#build-the-project)
- [Deployment](#deployment)
- [Notes](#notes)
- [Contributing](#contributing)
- [Links](#links)
- [License](#license)

## Getting Started

This project builds a minimal AlmaLinux OS 9 image for basic validation of
Ansible playbooks.

### Tags

- `latest`: Latest stable version of Ansible.

### Prerequisites

To make use of this image you (of course) need Docker installed on your
machine. You can find instructions on [how to install Docker for your platform](https://docs.docker.com/engine/install/)
according the instructions from this link.

Docker is also necessary if you want to extend the image. Otherwise you
won't be able to build the new image.

### Installation

The image will be built by a GitHub Action and pushed automatically to Docker
Hub. In order to install the image to create a new image, all you have to do is:

```bash
docker pull docker.io/robinwalterfit/docker-almalinux9-ansible:latest
```

### Usage

After you have pulled the image you can create a new container and run Ansible
inside.

```bash
docker run \
--cgroupns=host \
--detach \
--name docker-ansible \
--privileged \
--volume '/sys/fs/cgroup:/sys/fs/cgroup:rw' \
--volume "$PWD:/etc/ansible/roles/role_under_test:ro" \
docker.io/robinwalterfit/docker-almalinux9-ansible:latest
```

This will create a new container from the image and mount your current working
directory into the container. The container will be executed in the background,
so you can reuse your current terminal session. If you do not want to run the
container in the background, just remove the `--detach` flag.

If you do not need the container after you are done, you can also add the `--rm`
flag. This will remove the container after it has finished its execution.

Now you can attach to your running container and run Ansible inside it to test
your role:

```bash
docker exec --tty docker-ansible env TERM=xterm ansible --version

# or:

docker exec --tty docker-ansible env TERM=xterm ansible-playbook /path/to/ansible/playbook.yml --syntax-check
```

**[⬆️ Back to Top](#docker-ansible)**

## Development

In order to extend the functionallity of the image you must follow the
[prerequisites](#prerequisites) to install Docker.

It is recommended to use [Visual Studio Code](https://code.visualstudio.com/)
as editor. The repository recommends different VSCode extensions, however, none
of them are required. It is up to you what extensions you use.

There is only one Dockerfile that is used.

### Build the Project

This project uses [Taskfile](https://taskfile.dev/). Thanks to `task` building
the image locally is as convenient as `task build`.

There are more tasks defined. The `build` task builds the image for your current
architecture. The `cross-build` task will build the image for `linux/amd64` as
well as `linux/arm64`.

The `mega-linter` task will run [MegaLinter](https://megalinter.io) with the
help of `npx` and Docker.

### Deployment

A GitHub Action will automatically build and push the Docker image to Docker
Hub. No manual steps necessary.

**[⬆️ Back to Top](#docker-ansible)**

## Notes

The image is heavily inspired by [`docker-rockylinux9-ansible`](https://github.com/geerlingguy/docker-rockylinux9-ansible)
created by @geerlingguy.

The main (and only) purpose of this image is to test Ansible collections,
playbooks and roles with Docker on multiple OS'. The image can be used to run
theses tests in CI and locally.

Just as Jeff points out, please note:

> [!IMPORTANT]
> The image is for testing in an isolated environment - not for production - and
> the settings and configuration used may not be suitable for a secure and
> performant production environment. Use on production servers / in the wild at
> your own risk!

**[⬆️ Back to Top](#docker-ansible)**

## Contributing

You want to contribute to this project? Great! Please make sure to read
[CONTRIBUTING.md](./CONTRIBUTING.md) first.

**[⬆️ Back to Top](#docker-ansible)**

## Links

- Project Repository: [https://github.com/robinwalterfit/docker-almalinux9-ansible](https://github.com/robinwalterfit/docker-almalinux9-ansible)
- Issues / Feature Requests: [https://github.com/robinwalterfit/docker-almalinux9-ansible/issues](https://github.com/robinwalterfit/docker-almalinux9-ansible/issues)
- Additional links:
- AlmaLinux OS: [https://almalinux.org/](https://almalinux.org/)
- Ansible: [https://docs.ansible.com/](https://docs.ansible.com/)
- Codeowners Docs: [https://github.blog/2017-07-06-introducing-code-owners/](https://github.blog/2017-07-06-introducing-code-owners/)
- Collection of `.gitattributes` templates: [https://github.com/gitattributes/gitattributes](https://github.com/gitattributes/gitattributes)
- Commitizen: [https://commitizen-tools.github.io/commitizen/](https://commitizen-tools.github.io/commitizen/)
- Continue: [https://www.continue.dev/](https://www.continue.dev/)
- Contributor Covenant Code of Conduct: [https://www.contributor-covenant.org](https://www.contributor-covenant.org)
- Conventional Commits: [https://www.conventionalcommits.org/en/v1.0.0/](https://www.conventionalcommits.org/en/v1.0.0/)
- Docker: [https://www.docker.com/](https://www.docker.com/)
- `docker-rockylinux9-ansible`: [https://github.com/geerlingguy/docker-rockylinux9-ansible](https://github.com/geerlingguy/docker-rockylinux9-ansible)
- EditorConfig: [https://editorconfig.org/](https://editorconfig.org/)
- `.gitignore` Generator: [https://gitignore.io](https://gitignore.io)
- hadolint: [https://hadolint.github.io/hadolint/](https://hadolint.github.io/hadolint/)
- Lefthook: [https://github.com/evilmartians/lefthook](https://github.com/evilmartians/lefthook)
- MegaLinter: [https://megalinter.io](https://megalinter.io)
- README-Template.md: [https://gist.github.com/PurpleBooth/109311bb0361f32d87a2](https://gist.github.com/PurpleBooth/109311bb0361f32d87a2)
- Taskfile: [https://taskfile.dev/](https://taskfile.dev/)
- Visual Studio Code: [https://code.visualstudio.com/](https://code.visualstudio.com/)

**[⬆️ Back to Top](#docker-ansible)**

## License

Code: © 2024 - Present - Robin Walter <>.

MIT where applicable.

**[⬆️ Back to Top](#docker-ansible)**