Compare commits

...

6 Commits

Author SHA1 Message Date
7f5ff67e6e Merge pull request 'style 💎: Fix indentation in tasks/main.yml for notify section' (#1) from test into main
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 10s
Reviewed-on: #1
2025-12-24 08:02:17 +01:00
d43c413e0d style 💎: Fix indentation in tasks/main.yml for notify section
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 11s
ansible-lint / Ansible Lint (pull_request) Successful in 10s
Corrected the indentation of the 'notify' section within the `tasks/main.yml` file to ensure proper syntax and readability.
2025-12-24 08:00:58 +01:00
e5e4a07740 refactor ♻️: Refactor task to use handlers for reloading and triggering udev rules
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 11s
This refactoring improves the organization of tasks by using dedicated handlers for reloading udev rules and triggering network events, enhancing code readability and maintainability.
2025-12-24 07:59:35 +01:00
8c1f0b14d2 fix 🐛: Fix typo and add condition for bond0 backing
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
This commit fixes a typo in the `update_cache` value and adds a conditional check to ensure proper handling of `bond0` backing.
2025-12-24 07:37:56 +01:00
4b7e3bd74b chore 📦: Add .ansible-lint config to exclude paths and enable rules
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
This commit adds a new `.ansible-lint` configuration file to specify which paths to exclude from linting and enables specific rules for better code quality.
2025-12-24 07:34:00 +01:00
fb31e2aa53 feat : Add Ansible linting workflow
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
Introduce a new GitHub Actions workflow to automate Ansible linting, ensuring code quality and consistency.
2025-12-24 07:30:27 +01:00
4 changed files with 72 additions and 13 deletions

31
.ansible-lint Normal file
View File

@@ -0,0 +1,31 @@
---
# .ansible-lint
exclude_paths:
- .gitea
# Ansible-lint does not automatically load rules that have the 'opt-in' tag.
# You must enable opt-in rules by listing each rule 'id' below.
enable_list:
- args
- empty-string-compare # opt-in
- no-log-password # opt-in
- no-same-owner # opt-in
- name[prefix] # opt-in
- galaxy-version-incorrect # opt-in
# add yaml here if you want to avoid ignoring yaml checks when yamllint
# library is missing. Normally its absence just skips using that rule.
- yaml
# List of additional kind:pattern to be added at the top of the default
# match list, first match determines the file kind.
kinds:
- playbook: "**/playbooks/*.{yml,yaml}"
- roles: "**/roles/*.{yml,yaml}"
# - galaxy: "**/folder/galaxy.yml"
- tasks: "**/tasks/*.yml"
- vars: "**/*vars/*.yml"
- meta: "**/meta/main.yml"
- yaml: "**/*.yaml-too"

View File

@@ -0,0 +1,28 @@
# .github/workflows/ansible-lint.yml
name: ansible-lint
on: [pull_request, issues, push]
jobs:
build:
name: Ansible Lint # Naming the build is important to use it as a status check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
github-server-url: ${{ vars.GIT_SERVER_URL }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.14"
- name: Install ansible-lint
run: |
python -m pip install --upgrade pip
pip install ansible ansible-lint
- name: Run ansible-lint
run: |
ansible-lint

View File

@@ -5,3 +5,11 @@
daemon_reload: true
enabled: true
state: restarted
- name: Reload_udev_rules
ansible.builtin.command: udevadm control --reload
changed_when: false
- name: Trigger_udev_net
ansible.builtin.command: udevadm trigger --subsystem-match=net
changed_when: false

View File

@@ -6,7 +6,7 @@
ansible.builtin.apt:
name: ethtool
state: present
update_cache: yes
update_cache: true
# ============================================================
# Normalize and validate configuration
@@ -103,6 +103,7 @@
label: "{{ item }}"
- name: Check for bond0 backing
when: bond_info.rc == 0
block:
- name: Detect if any bridge is backed by bond0
ansible.builtin.set_fact:
@@ -115,7 +116,6 @@
(bond_info.stdout | regex_findall('Slave Interface: ([a-zA-Z0-9]+)')) | list
}}
when: wol_has_bond0 | default(false)
when: bond_info.rc == 0
# ============================================================
# Validate configuration and resolve to physical NICs
@@ -192,17 +192,9 @@
{% for rule in wol_udev_rules %}
{{ rule }}
{% endfor %}
register: udev_rules_changed
- name: Reload udev rules
ansible.builtin.command: udevadm control --reload
changed_when: false
when: udev_rules_changed is changed
- name: Trigger udev for network interfaces
ansible.builtin.command: udevadm trigger --subsystem-match=net
changed_when: false
when: udev_rules_changed is changed
notify:
- Reload_udev_rules
- Trigger_udev_net
# ============================================================
# Verification & Reporting