Compare commits
4 Commits
9eb580b841
...
0b871998aa
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b871998aa | |||
| 6117f168aa | |||
| ac7cb1bc44 | |||
| eae8ce0848 |
@@ -1,8 +1,13 @@
|
|||||||
---
|
---
|
||||||
# handlers file for systemd-timesyncd
|
# handlers file for network-manager
|
||||||
- name: restart network-manager
|
- name: Restart NetworkManager
|
||||||
become: true
|
systemd:
|
||||||
service:
|
name: NetworkManager
|
||||||
name: NetworkManager.service
|
|
||||||
state: restarted
|
state: restarted
|
||||||
listen: network-manager configuration changed
|
|
||||||
|
- name: Reboot the system
|
||||||
|
reboot:
|
||||||
|
reboot_timeout: 180
|
||||||
|
async: 0
|
||||||
|
poll: 0
|
||||||
|
listen: "Notify the reboot handler"
|
||||||
34
tasks/check_udev_rules.yml
Normal file
34
tasks/check_udev_rules.yml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
- 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
|
||||||
|
notify: Notify the reboot handler
|
||||||
@@ -1,8 +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"
|
||||||
@@ -10,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 }}"
|
||||||
@@ -18,27 +15,34 @@
|
|||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: 0644
|
||||||
when: globally_managed_devices is true
|
when: globally_managed_devices is true
|
||||||
notify: network-manager configuration changed
|
|
||||||
|
|
||||||
- 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
|
||||||
|
notify: Restart NetworkManager
|
||||||
|
|
||||||
|
- name: Include tasks for checking and removing udev rules
|
||||||
|
include_tasks: check_udev_rules.yml
|
||||||
|
|
||||||
- name: Configure NetworkManager
|
- name: Configure NetworkManager
|
||||||
become: true
|
|
||||||
community.general.nmcli:
|
community.general.nmcli:
|
||||||
conn_name: "{{ net_item.con_name }}"
|
autoconnect: "{{ connection.autoconnect | default('true') }}"
|
||||||
ifname: "{{ net_item.ifname }}"
|
conn_name: "{{ connection.con_name }}"
|
||||||
type: "{{ net_item.type }}"
|
ifname: "{{ connection.ifname }}"
|
||||||
ip4: "{{ net_item.ip4 }}"
|
type: "{{ connection.type }}"
|
||||||
gw4: "{{ net_item.gw4 | default('') }}"
|
ip4: "{{ connection.ip4 | default('') }}"
|
||||||
dns4: "{{ net_item.dns4 | default([]) }}"
|
gw4: "{{ connection.gw4 | default('') }}"
|
||||||
method6: "{{ net_item.method6 | default('auto') }}"
|
dns4: "{{ connection.dns4 | default([]) }}"
|
||||||
|
routes4: "{{ connection.routes4 | default([]) }}"
|
||||||
|
method4: "{{ connection.method4 | default('manual') }}"
|
||||||
|
method6: "{{ connection.method6 | default('auto') }}"
|
||||||
state: present
|
state: present
|
||||||
with_items: "{{ network }}"
|
with_items: "{{ network }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: net_item
|
loop_var: connection
|
||||||
notify: network-manager configuration changed
|
notify: Restart NetworkManager
|
||||||
|
|
||||||
|
- name: Notify the reboot handler
|
||||||
|
meta: flush_handlers
|
||||||
Reference in New Issue
Block a user