Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/wayofdev/ansible-role-tpl
- Owner: wayofdev
- License: gpl-3.0
- Created: 2022-05-15T19:12:58.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-07-08T12:51:07.000Z (over 2 years ago)
- Last Synced: 2023-03-04T01:07:53.768Z (almost 2 years ago)
- Topics: ansible, ansible-molecule, ansible-role, ansible-role-skeleton, automation, linux, macos, molecule
- Language: Makefile
- Homepage: https://wayof.dev
- Size: 132 KB
- Stars: 7
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# 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: localvars:
tpl_key: valueroles:
- 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