Skip to content

Latest commit

 

History

History

ansible

Contributors Forks Stargazers Issues GPL3 License LinkedIn Ask Me Anything


Logo

Molecule Cookiecutter Template

This is a template to be used with cookiecuter to create a molecule role
Explore the docs »
Report Bug · Request Feature

Table of Contents

About The Project

Built With

  • Cookiecutter
  • Molecule
  • Python
  • YAML
  • Ansible
  • JSON
  • Docker
  • Ansible-lint
  • Yamllint

Getting Started

Prerequisites

  • Ansible
  • ansible-lint
  • yamllint
  • cookiecutter
  • pre-commit
  • molecule-vagrant
  • molecule-docker
  • vagrant
  • docker

Installation

  • ansible ==> $ pip3 install ansible
  • ansible-lint ==> $ pip3 install ansible-lint
  • yamllint ==> $ pip3 install cookiecutter
  • cookiecutter ==> $ pip3 install cookiecutter
  • pre-commit ==> $ pip3 install pre-commit
  • molecule ==> $ pip3 install molecule
  • molecule-vagrant ==> $ pip3 install molecule-vagrant python-vagrant
  • molecule-docker ==> $ pip3 install molecule-docker
  • Vagrant ==> Official Documentation
  • Docker ==> Official Documentation

Usage

To initialize the role with cookiecuter

$ cookiecutter gh:stiliajohny/cookiecutter-collection --directory="ansible"

To test the default scenario docker

$ molecule test

To test the scenario with vagrant

$ molecule test -s vagrant


What this template provides?

  • Initialize a new git repo in the local machine
  • Add .yamllint config file (used by molecule)
  • Add .pre-commit-config.yaml used by pre-commit
  • Add .gitignore with common files I don't want to track in git
  • Add configuration for Molecule in the "molecule" folder
    • default molecule scenario runs on docker
    • There is another molecule scenario using Vagrant
    • The vagrant scenario requires pip install molecule-vagrant
  • Add a travis or Gitlab-CI config file (Optional. By default it's not added)
  • Populates, variables, tasks, handlers on demand
  • Checks role name validity

Directory structure

ansible-role-example/
├── defaults
│   └── main.yml
├── .gitignore
├── handlers
│   └── main.yml
├── meta
│   └── main.yml
├── molecule
│   ├── default
│   │   ├── converge.yml
│   │   ├── INSTALL.rst
│   │   ├── molecule.yml
│   │   └── verify.yml
│   ├── docker
│   │   ├── converge.yml
│   │   ├── INSTALL.rst
│   │   ├── molecule.yml
│   │   └── verify.yml
│   └── vagrant
│       ├── converge.yml
│       ├── INSTALL.rst
│       ├── molecule.yml
│       └── verify.yml
├── .pre-commit-config.yaml
├── README.md
├── tasks
│   └── main.yml
├── vars
│   └── main.yml
└── .yamllint

Roadmap

See the open issues for a list of proposed features (and known issues).


Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the GPL-3.0 License. See LICENSE for more information.

Contact

John Stilia - @john_stilia - stilia.johny@gmail.com


Acknowledgements