An Ansible role that installs and configures nginx with a Hello World page, tested with Molecule using Docker containers.
- Python 3.10+
- Docker
Ensure your user is in the docker group:
sudo usermod -aG docker $USER
newgrp dockerClone the repository and create a virtual environment:
git clone git@github.com:bkowens/ansible-molecule.git
cd ansible-molecule
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtRun the full Molecule test lifecycle (create container, converge, verify, destroy):
molecule testIndividual steps can be run separately:
molecule create # Create the Docker container
molecule converge # Run the Ansible playbook
molecule verify # Run TestInfra tests
molecule destroy # Tear down the containerThe TestInfra tests validate:
- nginx package is installed
- nginx service is running and enabled
- Port 80 is listening
- The default page returns "Hello World"
| Variable | Default | Description |
|---|---|---|
nginx_hello_message |
Hello World |
Message displayed on the landing page |
Add this role to a playbook:
- hosts: webservers
become: true
roles:
- ansible-molecule