Skip to content

Commit 93a45a2

Browse files
Refactor role
1 parent 027779e commit 93a45a2

File tree

17 files changed

+323
-8
lines changed

17 files changed

+323
-8
lines changed

.aar-doc.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
output_file: README.md
3+
output_mode: replace
4+
output_template: |
5+
<!-- BEGIN_ANSIBLE_DOCS -->
6+
# {{ role }}
7+
8+
{{ metadata.galaxy_info.description }}
9+
10+
## Supported Operating Systems
11+
12+
- Debian 12
13+
- Ubuntu 24.04, 22.04
14+
- FreeBSD [Proserver](https://infrastructure.punkt.de/de/produkte/proserver.html)
15+
16+
## Role Arguments
17+
18+
{% for entrypoint in argument_specs.keys() %}
19+
20+
{% if "description" in argument_specs[entrypoint] %}
21+
{%- if argument_specs[entrypoint].description is string -%}
22+
{{ argument_specs[entrypoint].description }}
23+
{% else %}
24+
{%- for line in argument_specs[entrypoint].description -%}
25+
{{ line }}
26+
27+
{% endfor -%}
28+
{% endif -%}
29+
{% endif -%}
30+
31+
{% if entrypoint_options[entrypoint] | length > 1 -%}
32+
{% for path, options in entrypoint_options[entrypoint][1:] -%}
33+
#### Options for `{{ path | reject('eq', 'main') | join(".") }}`
34+
35+
|Option|Description|Type|Required|Default|
36+
|---|---|---|---|---|
37+
{%- for name, details in options.items() %}
38+
| `{{ name }}` | {{ details.display_description }} | {{ details.display_type }} | {{ details.display_required }} | {{ details.display_default }} |
39+
{%- endfor %}
40+
41+
{% endfor -%}
42+
43+
{% endif -%}
44+
45+
{% if entrypoint in entrypoint_choices -%}
46+
{% for path, choices in entrypoint_choices[entrypoint] -%}
47+
#### Choices for {{ path | join(" > ") }}
48+
49+
|Choice|
50+
|---|
51+
{%- for item in choices %}
52+
| {{ item }} |
53+
{%- endfor %}
54+
55+
{% endfor -%}
56+
{% endif -%}
57+
{% else -%}
58+
59+
This entrypoint has no options.
60+
61+
{% endfor -%}
62+
63+
## Dependencies
64+
65+
{%- if ("dependencies" in metadata) and (metadata.dependencies | length > 0) %}
66+
{%- for dependency in metadata.dependencies %}
67+
{%- if dependency.src %}
68+
- [{{ dependency.role }}]({{ dependency.src }})
69+
{%- else %}
70+
- {{ dependency.role }}
71+
{%- endif %}
72+
{%- if dependency.when %}
73+
- **Condition**: `{{ dependency.when }}`
74+
{%- endif %}
75+
{%- endfor %}
76+
{%- else %}
77+
None.
78+
{%- endif %}
79+
80+
## Installation
81+
Add this role to the requirements.yml of your playbook as follows:
82+
```yaml
83+
roles:
84+
- name: {{ role }}
85+
src: https://github.com/punktDe/ansible-wireguard
86+
```
87+
88+
Afterwards, install the role by running `ansible-galaxy install -r requirements.yml`
89+
90+
## Example Playbook
91+
92+
```yaml
93+
- hosts: all
94+
roles:
95+
- name: wireguard
96+
```
97+
98+
<!-- END_ANSIBLE_DOCS -->

.ansible-lint

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
skip_list:
3+
- meta-no-info
4+
- var-naming[no-role-prefix]
5+
- name[template]
6+
7+
warn_list:
8+
- no-handler
9+
- package-latest
10+
- risky-shell-pipe
11+
- unnamed-task
12+
13+
exclude_paths:
14+
- .ansible/

.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# EditorConfig: http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
11+
# 2 space indentation for YAML
12+
[{*.yml,*.yaml}]
13+
indent_style = space
14+
indent_size = 2

.envrc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
if [ -n "$DIRENV_DIFF" ]; then
3+
# Do not `set -e` unless we're being run from direnv
4+
set -e
5+
fi
6+
7+
if [ ! -f venv-ansible-wireguard/bin/activate ]; then
8+
echo "Creating a virtual Python environment"
9+
uv -q venv --allow-existing --seed venv-ansible-wireguard
10+
fi
11+
12+
echo "Activating the Python virtual environment"
13+
. venv-ansible-wireguard/bin/activate
14+
15+
echo "Installing Python requirements"
16+
uv -q pip install -r requirements.txt
17+
18+
export GITHUB_ACTIONS=maybe
19+
export ANSIBLE_HASH_BEHAVIOUR=merge

.github/workflows/test.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
name: Test
3+
run-name: Run molecule tests on the role
4+
on:
5+
push:
6+
workflow_dispatch:
7+
8+
env:
9+
ANSIBLE_ROLES_PATH: roles
10+
ANSIBLE_HASH_BEHAVIOUR: merge
11+
12+
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v5
21+
22+
- name: Set up Python
23+
run: uv python install
24+
25+
- name: Install dependencies
26+
run: |
27+
uv -q venv --allow-existing --seed .venv
28+
. .venv/bin/activate
29+
uv -q pip install -r requirements.txt
30+
31+
- name: Run ansible-lint
32+
run: |
33+
. .venv/bin/activate
34+
ansible-lint
35+
36+
molecule:
37+
strategy:
38+
matrix:
39+
os: [ubuntu-2204, ubuntu-2404, debian-12]
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v3
44+
45+
- name: Install uv
46+
uses: astral-sh/setup-uv@v5
47+
48+
- name: Set up Python
49+
run: uv python install
50+
51+
- name: Install dependencies.
52+
run: |
53+
uv -q venv --allow-existing --seed .venv
54+
. .venv/bin/activate
55+
uv -q pip install -r requirements.txt
56+
ansible-galaxy install -r requirements.yml
57+
58+
- name: Run molecule
59+
run: |
60+
. .venv/bin/activate
61+
molecule test -p ${{ matrix.os }}

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.DS_Store
2+
*.pyc
3+
__pycache__
4+
.idea
5+
.vscode
6+
/*.retry
7+
/.fact_cache
8+
/venv/
9+
debug.log
10+
id_ed25519*
11+
/venv*/
12+
.collections
13+
roles
14+
.roles
15+
.venv
16+
.ansible

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
repos:
3+
- repo: https://github.com/ansible/ansible-lint.git
4+
rev: v25.1.3
5+
hooks:
6+
- id: ansible-lint
7+
files: \.(yaml|yml)$

.yamllint

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
extends: default
3+
4+
rules:
5+
line-length: disable
6+
truthy:
7+
allowed-values: ['true', 'false', 'yes', 'no']
8+
comments:
9+
min-spaces-from-content: 1
10+
braces:
11+
min-spaces-inside: 0
12+
max-spaces-inside: 1
13+
14+
ignore: |
15+
.cache

defaults/main.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
---
12
wireguard:
23
wg_quick: {}

meta/main.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
galaxy_info:
3+
author: "punkt.de"
4+
license: "MIT"
5+
role_name: wireguard
6+
description: "Wireguard role for Linux"
7+
namespace: "punktde"
8+
min_ansible_version: "2.15"
9+
platforms: []

0 commit comments

Comments
 (0)