код по отключению udev/rules механизма управления сетевыми устройствами, характерного для noncloud образа Debian 11

This commit is contained in:
135
2023-09-11 19:17:43 +03:00
parent 762be6dd88
commit eae8ce0848
3 changed files with 66 additions and 4 deletions

View File

@@ -0,0 +1,33 @@
---
- name: Check and remove udev rules
block:
- name: Find udev rules files
find:
paths: /etc/udev/rules.d
patterns: "*-cloud-ifupdown.rules"
register: udev_rules_to_remove
- name: Get dynamically defined file path from udev rule
command: grep -oP 'RUN\+="\K[^"]*' "{{ run.path }}"
with_items: "{{ udev_rules_to_remove.files }}"
register: dynamic_file_paths
loop_control:
loop_var: run
- name: Remove dynamically defined file
file:
path: "{{ runf.stdout }}"
state: absent
with_items: "{{ dynamic_file_paths.results }}"
when: runf.stdout is defined and runf.stdout != ''
loop_control:
loop_var: runfile
- name: Remove udev rules
file:
path: "{{ rule.path }}"
state: absent
with_items: "{{ udev_rules_to_remove.files | default([]) }}"
when: udev_rules_to_remove.matched > 0
loop_control:
loop_var: rule