Ansible Playbook Skeleton is a starter template designed to help you create Ansible playbooks with the recommended directory structure. This repository provides a solid foundation for organizing your playbooks and adhering to best practices, making your workflow more efficient and maintainable.
- Predefined directory layout based on Ansible best practices.
- Example files to guide you in setting up roles, tasks, and configurations.
- Ready-to-use structure for scalable and reusable playbooks.
The project follows the recommended Ansible directory structure:
ansible-playbook-skeleton/
├── roles/ # Directory for role definitions
│ ├── myproject/ # Example role
│ │ ├── tasks/ # Role tasks
│ │ ├── handlers/ # Role handlers
│ │ ├── templates/ # Jinja2 templates
│ │ ├── files/ # Static files
│ │ ├── vars/ # Role-specific variables
│ │ ├── defaults/ # Default variables
│ │ ├── meta/ # Role metadata
├── inventories/ # Inventory files (e.g., production, staging)
| ├── hosts
| ├── production
| ├── staging
├── group_vars/ # Group-specific variables
├── host_vars/ # Host-specific variables
├── playbooks/ # Playbook YAML files
├── ansible.cfg # Ansible configuration file
├── requirements.yml # Role dependencies
|── myproject.yml # Role dependencies
├── README.md # Project documentation
Ensure you have the following installed:
- Clone this repository:
git clone https://github.com/MehrdadLinux/ansible-playbook-skeleton.git
- Navigate to the project directory:
cd ansible-playbook-skeleton
- Customize the directory structure and example files to fit your project.
- Start writing your playbooks and roles!
Here’s an example of running a playbook:
ansible-playbook -i inventories/production playbooks/site.yml
ansible-playbook -i inventory/hosts myproject.yml -e "ansible_root=[Your_Path] project_name=[PlayBookName]"
example : ansible-playbook -i inventory/hosts myproject.yml -e "ansible_root=/tmp/1 project_name=ansible_project"
Contributions are welcome! If you have suggestions for improvements or want to report a bug, please open an issue or submit a pull request.
This project is licensed under the MIT License.
- Inspired by Ansible's Sample-directory-layout.
- And Inspired by Ansible's Best Practices.
- Thanks to the open-source community for providing guidance and feedback.
For questions or support, feel free to reach out to [MehrdadLinux@gmail.com] or create an issue in this repository.
Happy automating with Ansible! 🎉