This repository serves as a template for Ansible projects, including features for CI, linting, and containerization.
- .github/workflows/: CI workflows for GitHub Actions
- group_vars/: Group variables
- host_vars/: Host variables
- roles/: Ansible roles
- inventories/: Inventory files
- Dockerfile: Dockerfile for containerizing Ansible
- playbooks/: Ansible playbooks
- tests/: Test playbooks
- ansible.cfg: Ansible configuration
- requirements.yml: Ansible Galaxy requirements
-
Clone the repository:
git clone https://github.com/TheDevOpsHub/ansible-template.git cd ansible-template
-
Build Docker image:
docker build -t ansible-playbook -f Dockerfile .
-
Run Ansible Playbook:
docker run --rm ansible-playbook playbooks/example_playbook.yaml
GitHub Actions are configured to lint and test your Ansible playbooks on each push or pull request.
Ansible Lint is used to ensure best practices in your Ansible playbooks. The linting is automatically run in the CI pipeline.
A Dockerfile is included to containerize Ansible, ensuring consistency across environments.
ansible-playbook playbooks/example_playbook.yml --tags example_tag
ansible-playbook playbooks/example_system_checks_role.yaml --tags system_checks_tag