From fb31e2aa5372bb13dae9f0fe758e3731faee9143 Mon Sep 17 00:00:00 2001 From: Jose Date: Wed, 24 Dec 2025 07:30:27 +0100 Subject: [PATCH 1/5] =?UTF-8?q?feat=20=E2=9C=A8:=20Add=20Ansible=20linting?= =?UTF-8?q?=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce a new GitHub Actions workflow to automate Ansible linting, ensuring code quality and consistency. --- .gitea/workflows/ansible-lint.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .gitea/workflows/ansible-lint.yml diff --git a/.gitea/workflows/ansible-lint.yml b/.gitea/workflows/ansible-lint.yml new file mode 100644 index 0000000..d94cb89 --- /dev/null +++ b/.gitea/workflows/ansible-lint.yml @@ -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 \ No newline at end of file From 4b7e3bd74b7b271e3ad1d17a34b0773fe81be7e5 Mon Sep 17 00:00:00 2001 From: Jose Date: Wed, 24 Dec 2025 07:34:00 +0100 Subject: [PATCH 2/5] =?UTF-8?q?chore=20=F0=9F=93=A6:=20Add=20.ansible-lint?= =?UTF-8?q?=20config=20to=20exclude=20paths=20and=20enable=20rules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .ansible-lint | 31 +++++++++++++++++++++++++++++++ .gitea/workflows/ansible-lint.yml | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 .ansible-lint diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 0000000..5b52ff6 --- /dev/null +++ b/.ansible-lint @@ -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" diff --git a/.gitea/workflows/ansible-lint.yml b/.gitea/workflows/ansible-lint.yml index d94cb89..d089d74 100644 --- a/.gitea/workflows/ansible-lint.yml +++ b/.gitea/workflows/ansible-lint.yml @@ -25,4 +25,4 @@ jobs: - name: Run ansible-lint run: | - ansible-lint \ No newline at end of file + ansible-lint From 8c1f0b14d2be93e0dddaf10acca308b288aec98e Mon Sep 17 00:00:00 2001 From: Jose Date: Wed, 24 Dec 2025 07:37:56 +0100 Subject: [PATCH 3/5] =?UTF-8?q?fix=20=F0=9F=90=9B:=20Fix=20typo=20and=20ad?= =?UTF-8?q?d=20condition=20for=20bond0=20backing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes a typo in the `update_cache` value and adds a conditional check to ensure proper handling of `bond0` backing. --- tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 9a66d90..633c119 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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 From e5e4a077400c075ee18346633348dcb60ccbc1a6 Mon Sep 17 00:00:00 2001 From: Jose Date: Wed, 24 Dec 2025 07:59:35 +0100 Subject: [PATCH 4/5] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Refactor?= =?UTF-8?q?=20task=20to=20use=20handlers=20for=20reloading=20and=20trigger?= =?UTF-8?q?ing=20udev=20rules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This refactoring improves the organization of tasks by using dedicated handlers for reloading udev rules and triggering network events, enhancing code readability and maintainability. --- handlers/main.yml | 8 ++++++++ tasks/main.yml | 14 +++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index 714e830..e7515de 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -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 diff --git a/tasks/main.yml b/tasks/main.yml index 633c119..e605227 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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 From d43c413e0dd11e339165107360d6a113f2eb8bc4 Mon Sep 17 00:00:00 2001 From: Jose Date: Wed, 24 Dec 2025 08:00:58 +0100 Subject: [PATCH 5/5] =?UTF-8?q?style=20=F0=9F=92=8E:=20Fix=20indentation?= =?UTF-8?q?=20in=20tasks/main.yml=20for=20notify=20section?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrected the indentation of the 'notify' section within the `tasks/main.yml` file to ensure proper syntax and readability. --- tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index e605227..8004dec 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -193,8 +193,8 @@ {{ rule }} {% endfor %} notify: - - Reload_udev_rules - - Trigger_udev_net + - Reload_udev_rules + - Trigger_udev_net # ============================================================ # Verification & Reporting