2.1 KiB

py-cookiecutter-templates

Project directory structure templates for the Python Cookiecutter package.

What's Cookiecutter?

The Python package Cookiecutter assists in creating directory structure for whatever purpose you need such as for example a new Python project, an Ansible role or a docker-compose project. If you've ever wanted to put project structure best practices into version control Cookiecutter's here to help.

Cookiecutter is governed by so-called Cookiecutter templates. Most of its magic inside Cookiecutter templates happens via the Jinja2 template engine so if you're familiar with Ansible you'll feel right at home.

Get started

Get Cookiecutter like so:

pip install cookiecutter

Execute a template like so, docker-compose as an example:

cookiecutter https://quico.space/Quico/py-cookiecutter-templates.git --directory 'docker-compose'

Cookiecutter prompts you for whatever info the template needs then generates files and directories.

This is Cookiecutter prompting for info:

info

The end result is a directory structure that has everything you need to hit the ground running.

.
└── grafana
    ├── build-context
    │   ├── grafana
    │   │   ├── docker-data
    │   │   │   └── .gitkeep
    │   │   ├── Dockerfile
    │   │   └── extras
    │   │       └── .gitkeep
    │   └── nginx
    │       ├── docker-data
    │       │   └── .gitkeep
    │       ├── Dockerfile
    │       └── extras
    │           └── .gitkeep
    ├── common-settings.yml
    ├── docker-compose.override.yml
    ├── docker-compose.yml
    └── env
        └── fully.qualified.domain.name.example

Each subdirectory in this repo is a Cookiecutter template, you'll recognize them from their telltale cookiecutter.json files. Directories usually have a readme file explaining a bit more about each individual template.