-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathwicked.yml
More file actions
43 lines (39 loc) · 1.32 KB
/
wicked.yml
File metadata and controls
43 lines (39 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
---
# Wicked persistent DHCP caching implementation
# Used by: SUSE Linux Enterprise Server, openSUSE
- name: Detect primary network interface
ansible.builtin.set_fact:
primary_interface: "{{ ansible_default_ipv4.interface | default('eth0') }}"
- name: Create wicked extension for DHCP cache save
become: true
become_flags: "su - -c"
become_method: sudo
ansible.builtin.template:
src: wicked-extension.j2
dest: /etc/wicked/extensions/kdevops-dhcp-cache
mode: "0755"
owner: root
group: root
- name: Ensure lease cache directory exists
become: true
become_flags: "su - -c"
become_method: sudo
ansible.builtin.file:
path: /var/lib/wicked/cache
state: directory
mode: "0755"
owner: root
group: root
- name: Get current IP configuration via wicked
become: true
become_flags: "su - -c"
become_method: sudo
ansible.builtin.shell: |
wicked show {{ primary_interface }} | \
grep -E "addr.*inet|route.*default|DNS" | \
awk '{print}' > /var/lib/wicked/cache/{{ primary_interface }}.cached-config
echo "cache_timestamp=$(date +%s)" >> /var/lib/wicked/cache/{{ primary_interface }}.cached-config
chmod 644 /var/lib/wicked/cache/{{ primary_interface }}.cached-config
args:
creates: /var/lib/wicked/cache/{{ primary_interface }}.cached-config
changed_when: true