Skip to content

Commit

Permalink
make role pretty
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Savin <jtprogru@gmail.com>
  • Loading branch information
jtprogru committed Apr 24, 2021
1 parent 3e272b1 commit 19eace0
Show file tree
Hide file tree
Showing 10 changed files with 197 additions and 67 deletions.
18 changes: 18 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
exclude_paths:
- ./molecule/
- ./.github/
# - ./last/excluded/directory/
parseable: true
quiet: true
# rulesdir:
# - ./rule/directory/
skip_list:
- '401'
- '204'
- '403'
- '702'
- '305'
# tags:
# - run_this_tag
use_default_rules: true
verbosity: 1
6 changes: 6 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# These are supported funding model platforms
---
github: jtprogru
patreon: jtprog
custom: [ "https://sobe.ru/na/jtprogru" ]

75 changes: 75 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
name: CI
'on':
pull_request:
push:
branches:
- develop

defaults:
run:
working-directory: 'jtprogru.sample_role'

jobs:

lint:
name: Lint
runs-on: ubuntu-20.04
steps:
- name: Check out the codebase.
uses: actions/checkout@v2
with:
path: 'jtprogru.sample_role'

- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Upgrade pip3.
run: pip3 install --upgrade pip

- name: Install test dependencies.
run: pip3 install yamllint ansible-lint ansible

- name: Lint code with yamllint.
run: yamllint .

- name: Lint code with ansible-lint.
run: ansible-lint

molecule:
name: Molecule
runs-on: ubuntu-latest
strategy:
matrix:
distro:
- ubuntu2004
- ubuntu1804
- debian10
- debian9
- centos7

steps:
- name: Check out the codebase.
uses: actions/checkout@v2
with:
path: 'jtprogru.sample_role'

- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Upgrade pip3.
run: pip3 install --upgrade pip

- name: Install test dependencies.
run: pip3 install ansible molecule[docker] docker

- name: Run Molecule tests.
run: molecule --debug test
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_DISTRO: ${{ matrix.distro }}
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Release
'on':
push:
tags:
- '*'

defaults:
run:
working-directory: 'jtprogru.sample_role'

jobs:

release:
name: Release
runs-on: ubuntu-20.04
steps:
- name: Check out the codebase.
uses: actions/checkout@v2
with:
path: 'jtprogru.sample_role'

- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install Ansible.
run: pip3 install ansible

- name: Trigger a new import on Galaxy.
run: ansible-galaxy role import --api-key ${{ secrets.ANSIBLE_GALAXY_API_KEY }} $(echo ${{ github.repository }} | cut -d/ -f1) $(echo ${{ github.repository }} | cut -d/ -f2)
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

20 changes: 14 additions & 6 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
---
# Based on ansible-lint config

ignore: |
.github/*
molecule/*

extends: default

rules:
Expand All @@ -19,15 +24,18 @@ rules:
comments-indentation: disable
document-start: disable
empty-lines:
max: 3
level: error
max: 2
max-start: 2
max-end: 2
hyphens:
level: error
indentation: disable
key-duplicates: enable
line-length: disable
new-line-at-end-of-file: disable
line-length:
max: 2480
level: warning
new-line-at-end-of-file: enable
new-lines:
type: unix
trailing-spaces: disable
truthy: disable
trailing-spaces: enable
truthy: enable
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
Role Name
=========
# jtprogru.sample_role

A brief description of the role goes here.
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/jtprogru/sample-role/CI?label=CI) ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/jtprogru/sample-role/Release?label=Release) ![GitHub](https://img.shields.io/github/license/jtprogru/sample-role) [![Ansible Role](https://img.shields.io/ansible/role/54364)](https://galaxy.ansible.com/jtprogru/sample-role/)

Requirements
------------
This is sample ansible role used me as boilerplate.

Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.

Role Variables
--------------
## Role Variables

A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.

Dependencies
------------
See [`defaults/main.yml`](defaults/main.yml).

A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.

Example Playbook
----------------
## Example Playbook

Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
Example playbook:
```yaml
---
- name: Sample play
hosts: all
become: true

- hosts: servers
roles:
- { role: username.rolename, x: 42 }
vars:
foo: bar

License
-------
roles:
- jtprogru.sample_role
```
BSD
## Author
Author Information
------------------
Michael Savin aka `@jtprogru`

An optional section for the role authors to include contact information, or a website (HTML is not allowed).
Twitter: [![Twitter Follow](https://img.shields.io/twitter/follow/jtprogru?color=gree&style=plastic)](https://twitter.com/jtprogru/)

## License

See [LICENSE](LICENSE.md)
11 changes: 6 additions & 5 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
galaxy_info:
author: your name
description: your role description
company: your company (optional)
role_name: sample_role
namespace: jtprogru
author: Michael Savin
description: This is sample ansible role used me as boilerplate
company: SysOps

# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
Expand All @@ -14,7 +16,7 @@ galaxy_info:
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc)
license: WTFPL

min_ansible_version: 2.9

Expand Down Expand Up @@ -50,4 +52,3 @@ galaxy_info:
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.

23 changes: 21 additions & 2 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
---
- name: Converge
hosts: all
debugger: always

pre_tasks:
- name: Update apt cache.
apt: update_cache=yes cache_valid_time=600
when: ansible_os_family == 'Debian'

- name: Wait for systemd to complete initialization. # noqa 303
command: systemctl is-system-running
register: systemctl_status
until: >
'running' in systemctl_status.stdout or
'degraded' in systemctl_status.stdout
retries: 30
delay: 5
when: ansible_service_mgr == 'systemd'
changed_when: false
failed_when: systemctl_status.rc > 1

tasks:
- name: "Include sample-role"
- name: "Include sample_role"
include_role:
name: "sample-role"
name: "sample_role"
2 changes: 1 addition & 1 deletion tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
- hosts: localhost
remote_user: root
roles:
- sample-role
- sample_role

0 comments on commit 19eace0

Please sign in to comment.