/ansible-role-tpl

Ansible template for wayofdev roles.

Primary LanguageMakefileGNU General Public License v3.0GPL-3.0




Build Status Ansible Role Latest Version Ansible Quality Score Ansible Role Software License Commits since latest release

Ansible Role: Template

This is template, that is used to create roles for wayofdev project.

If you like/use this role, please consider starring it. Thanks!


๐Ÿ—‚ Table of Contents


๐ŸŒณ Directory Tree for Project

Repository uses default structure, sugested by Ansible Documentation

โ”œโ”€โ”€ ๐Ÿ“„ Makefile
โ”œโ”€โ”€ ๐Ÿ“„ README.md
โ”œโ”€โ”€ ๐Ÿ—‚ assets
โ”œโ”€โ”€ ๐Ÿ—‚ contrib
โ”‚   โ””โ”€โ”€ poetry-bin
โ”œโ”€โ”€ ๐Ÿ—‚ defaults
โ”‚   โ””โ”€โ”€ ๐Ÿ“„ main.yml
โ”œโ”€โ”€ ๐Ÿ—‚ files
โ”œโ”€โ”€ ๐Ÿ—‚ handlers
โ”‚   โ””โ”€โ”€ ๐Ÿ“„ main.yml
โ”œโ”€โ”€ ๐Ÿ—‚ meta
โ”‚   โ””โ”€โ”€ ๐Ÿ“„ main.yml
โ”œโ”€โ”€ ๐Ÿ—‚ molecule
โ”‚   โ”œโ”€โ”€ ๐Ÿ—‚ _partials
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ—‚ playbooks
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ converge.yml
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ—‚ defaults
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“„ verify.yml
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ ssh_config
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ—‚ tasks
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“„ setup.yml
โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ—‚ vars
โ”‚   โ”‚       โ””โ”€โ”€ ๐Ÿ“„ main.yml
โ”‚   โ”œโ”€โ”€ ๐Ÿ—‚ default
โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“„ molecule.yml
โ”‚   โ”œโ”€โ”€ ๐Ÿ—‚ default-macos-on-localhost
โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“„ molecule.yml
โ”‚   โ””โ”€โ”€ ๐Ÿ—‚ default-macos-over-ssh
โ”‚       โ””โ”€โ”€ ๐Ÿ“„ molecule.yml
โ”œโ”€โ”€ ๐Ÿ“„ pyproject.toml
โ”œโ”€โ”€ ๐Ÿ“„ requirements.yml
โ”œโ”€โ”€ ๐Ÿ—‚ tasks
โ”‚   โ””โ”€โ”€ ๐Ÿ“„ main.yml
โ”œโ”€โ”€ ๐Ÿ—‚ templates
โ””โ”€โ”€ ๐Ÿ—‚ vars
    โ””โ”€โ”€ ๐Ÿ“„ main.yml

๐Ÿ‘จโ€๐Ÿ’ป IDE Support

Jetbrains products has great ansible language support together with OrchidE plugin.

โš ๏ธ Notice: For ansible language support and autocompletion with OrchidE following additional File Type Patterns should be added.

Open Preferences โ†’ Languages & Frameworks โ†’ OrchidE โ†’ File Type Patterns:

Ansible Type Regex Pattern Pattern Type
RoleTask .*/tasks/.*\.ya?ml Include
RoleTask .*/handlers/.*\.ya?ml Include
Variable .*/tests/defaults/.*\.ya?ml Include
Variable .*/defaults/.*\.ya?ml Include
Variable .*/meta/.*\.ya?ml Include
Variable .*/vars/.*\.ya?ml Include

๐Ÿ“‘ Requirements

  • Up-to-date version of ansible. During maintenance/development, we stick to ansible versions and will use new features if they are available (and update meta/main.yml for the minimum version).
  • Compatible OS. See compatibility table.
  • Role has dependencies on third-party roles on different operating systems. See requirements.yml and dependencies section.

๐Ÿ”ง Role Variables

Available variables are listed below, along with example values (see defaults/main.yml). Additional variables are stored in vars/main.yml.


โ†’ Structure

---

tpl_key: value

๐Ÿ“— Example Playbook

---

- hosts: all
  connection: local

  vars:
    tpl_key: value

  roles:
    - wayofdev.homebrew
    - wayofdev.tpl

โš™๏ธ Development

To install dependencies and start development you can check contents of our Makefile

Install poetry using poetry-bin and all dev python dependencies:

$ make install

Install only python dependencies, assuming that you already have poetry:

$ make install-deps

Install all git hooks:

$ make hooks

Lint all role files:

$ make lint

๐Ÿงช Testing

You can check Makefile to get full list of commands for remote and local testing. For local testing you can use these comands to test whole role or separate tasks:

โ†’ on localhost

โš ๏ธ Notice: By defaut all tests are ran against your local machine!

# run molecule tests on localhost
$ poetry run molecule test --scenario-name default-macos-on-localhost -- -vvv

# or with make command
$ make m-local

# choose which tags will be included
$ export TASK_TAGS="tpl-install,tpl-update"; make m-local

# runs molecule with docker driver
$ poetry run molecule test --scenario-name default -- -vvv

# or with make file
$ make m-linux

โ†’ over SSH

# run molecule scenarios against remote machines over SSH
# this will need VM setup and configuration
$ poetry run molecule test --scenario-name default-macos-over-ssh -- -vvv

$ make m-remote

# tags also can be passed
$ export TASK_TAGS="tpl-install,tpl-update"
$ make m-remote

๐Ÿ“ฆ Dependencies

Installation handled by Makefile and requirments are defined in requirements.yml

โ†’ for all

โ†’ only macOS

โ†’ only Linux


๐Ÿงฉ Compatibility

This role has been tested on these systems:

system / container tag
macos monterey
macos big-sur
ubuntu jammy
ubuntu focal
debian bullseye
debian buster
fedora 36
fedora 35
centos 8
centos 7

๐Ÿค License

Licence


๐Ÿ™†๐Ÿผโ€โ™‚๏ธ Author Information

This role was created in 2022 by lotyp / wayofdev.


๐Ÿงฑ Credits and Resources

Inspired by:

  • Some resources goes here if needed...

๐Ÿซก Contributors