Add host exclusion and improve UFW task reliability
Add `excluded` host group and skip offline hosts Fix UFW service initialization command for Alpine Linux
This commit is contained in:
18
homelab.yml
18
homelab.yml
@@ -1,8 +1,24 @@
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/playbook.json
|
||||
---
|
||||
- name: Homelab alignment
|
||||
hosts: managed
|
||||
hosts: managed:!excluded
|
||||
become: true
|
||||
gather_facts: false
|
||||
environment:
|
||||
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
pre_tasks:
|
||||
- name: Test connectivity
|
||||
ansible.builtin.ping:
|
||||
ignore_unreachable: true
|
||||
register: ping_result
|
||||
|
||||
- name: Skip offline hosts
|
||||
ansible.builtin.meta: end_host
|
||||
when: ping_result.unreachable | default(false)
|
||||
|
||||
- name: Gather facts
|
||||
ansible.builtin.setup:
|
||||
|
||||
roles:
|
||||
- role: ufw
|
||||
|
||||
Reference in New Issue
Block a user