Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wayofdev/ansible-role-tpl

Ansible template for wayofdev roles.
https://github.com/wayofdev/ansible-role-tpl

ansible ansible-molecule ansible-role ansible-role-skeleton automation linux macos molecule

Last synced: about 2 months ago
JSON representation

Ansible template for wayofdev roles.

Awesome Lists containing this project

README

        








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](#-directory-tree-for-project)
* [IDE Support](#-ide-support)
* [Requirements](#-requirements)
* [Role Variables](#-role-variables)
* [Structure](#-structure)
* [Example Playbook](#-example-playbook)
* [Development](#-development)
* [Testing](#-testing)
* [on localhost](#-on-localhost)
* [over SSH](#-over-ssh)
* [Dependencies](#-dependencies)
* [for all](#-for-all)
* [only macOS](#-only-macos)
* [only Linux](#-only-linux)
* [Compatibility](#-compatibility)
* [License](#-license)
* [Author Information](#-author-information)
* [Credits and Resources](#-credits-and-resources)
* [Contributors](#-contributors)


## ๐ŸŒณ Directory Tree for Project

Repository uses default structure, sugested by [Ansible Documentation](https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html)

```
โ”œโ”€โ”€ ๐Ÿ“„ 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](https://plugins.jetbrains.com/plugin/12626-orchide--ansible-language-support).

> :warning: **Notice**: For ansible language support and autocompletion with [OrchidE](https://www.orchide.dev/pages/dokumentation) 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](#-compatibility) table.
* Role has dependencies on third-party roles on different operating systems. See `requirements.yml` and [dependencies](#-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

```yaml
---

tpl_key: value
```


## ๐Ÿ“— Example Playbook

```yaml
---

- 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](https://github.com/python-poetry/poetry) using [poetry-bin](https://github.com/gi0baro/poetry-bin) and all dev python dependencies:

```bash
$ make install
```

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

```bash
$ make install-deps
```

**Install** all git hooks:

```bash
$ make hooks
```

**Lint** all role files:

```bash
$ 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

> :warning: **Notice**: By defaut all tests are ran against your local machine!

```bash
# 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

```bash
# 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

- [ansible.community.general](https://docs.ansible.com/ansible/latest/collections/community/general/index.html)

### โ†’ only macOS

- [elliotweiser.osx-command-line-tools](https://galaxy.ansible.com/elliotweiser/osx-command-line-tools/)
- [wayofdev.homebrew](https://galaxy.ansible.com/wayofdev/homebrew)

### โ†’ only Linux

- [geerlingguy.git](https://galaxy.ansible.com/geerlingguy/git)


## ๐Ÿงฉ 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](https://img.shields.io/github/license/wayofdev/ansible-role-tpl.svg?style=for-the-badge&color=blue)](./LICENSE)


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

This role was created in **2022** by [lotyp / wayofdev](https://github.com/wayofdev).


## ๐Ÿงฑ Credits and Resources

**Inspired by:**

* Some resources goes here if needed...


## ๐Ÿซก Contributors