код по отключению udev/rules механизма управления сетевыми устройствами, характерного для noncloud образа Debian 11
This commit is contained in:
@@ -1,2 +1,13 @@
|
|||||||
---
|
---
|
||||||
# handlers file for network-manager
|
# handlers file for network-manager
|
||||||
|
- name: Restart NetworkManager
|
||||||
|
systemd:
|
||||||
|
name: NetworkManager
|
||||||
|
state: restarted
|
||||||
|
|
||||||
|
- name: Reboot the system
|
||||||
|
reboot:
|
||||||
|
reboot_timeout: 180
|
||||||
|
async: 0
|
||||||
|
poll: 0
|
||||||
|
listen: "Notify the reboot handler"
|
||||||
33
tasks/check_udev_rules.yml
Normal file
33
tasks/check_udev_rules.yml
Normal 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
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
---
|
---
|
||||||
# tasks file for network-manager
|
# tasks file for network-manager
|
||||||
- name: "apt install NetworkManager {{ nm_version }} "
|
- name: "apt install NetworkManager {{ nm_version }} "
|
||||||
become: true
|
|
||||||
apt:
|
apt:
|
||||||
name: "network-manager{{ nm_version }}"
|
name: "network-manager{{ nm_version }}"
|
||||||
default_release: "{{ ansible_distribution_release }}-backports"
|
default_release: "{{ ansible_distribution_release }}-backports"
|
||||||
@@ -9,7 +8,6 @@
|
|||||||
update_cache: true
|
update_cache: true
|
||||||
|
|
||||||
- name: config globally managed devices
|
- name: config globally managed devices
|
||||||
become: true
|
|
||||||
template:
|
template:
|
||||||
src: "conf.d/10-globally-managed-devices.j2"
|
src: "conf.d/10-globally-managed-devices.j2"
|
||||||
dest: "{{ globally_managed_devices_path }}"
|
dest: "{{ globally_managed_devices_path }}"
|
||||||
@@ -19,8 +17,28 @@
|
|||||||
when: globally_managed_devices is true
|
when: globally_managed_devices is true
|
||||||
|
|
||||||
- name: cleanup globally managed devices
|
- name: cleanup globally managed devices
|
||||||
become: true
|
|
||||||
file:
|
file:
|
||||||
path: "{{ globally_managed_devices_path }}"
|
path: "{{ globally_managed_devices_path }}"
|
||||||
state: absent
|
state: absent
|
||||||
when: not globally_managed_devices
|
when: not globally_managed_devices
|
||||||
|
|
||||||
|
- name: Include tasks for checking and removing udev rules
|
||||||
|
include_tasks: check_udev_rules.yml
|
||||||
|
|
||||||
|
- name: Configure NetworkManager
|
||||||
|
community.general.nmcli:
|
||||||
|
conn_name: "{{ connection.con_name }}"
|
||||||
|
ifname: "{{ connection.ifname }}"
|
||||||
|
type: "{{ connection.type }}"
|
||||||
|
ip4: "{{ connection.ip4 }}"
|
||||||
|
gw4: "{{ connection.gw4 | default('') }}"
|
||||||
|
dns4: "{{ connection.dns4 | default([]) }}"
|
||||||
|
method6: "{{ connection.method6 | default('auto') }}"
|
||||||
|
state: present
|
||||||
|
with_items: "{{ network }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: connection
|
||||||
|
notify: Restart NetworkManager
|
||||||
|
|
||||||
|
- name: Notify the reboot handler
|
||||||
|
meta: flush_handlers
|
||||||
Reference in New Issue
Block a user