Skip to content

Commit

Permalink
Hardening Salt state
Browse files Browse the repository at this point in the history
... to prevent errors like:
```
FileNotFoundError: [Errno 2] No such file or directory: '/sys/class/net/eth0/addr_assign_type'
```

Signed-off-by: Volker Theile <votdev@gmx.de>
  • Loading branch information
votdev committed Mar 29, 2024
1 parent e1dcb3e commit 480bf1e
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{%- set dns_config = salt['omv_conf.get']('conf.system.network.dns') -%}
{%- set addr_assign_type_path = '/sys/class/net/' ~ interface.devicename ~ '/addr_assign_type' -%}
network:
ethernets:
{{ interface.devicename }}:
match:
{%- if salt['file.read']('/sys/class/net/' + interface.devicename + '/addr_assign_type') | int == 0 %}
{%- if salt['file.file_exists'](addr_assign_type_path) and (salt['file.read'](addr_assign_type_path) | int == 0) %}
macaddress: {{ salt['grains.get']('hwaddr_interfaces:' + interface.devicename) }}
{%- else %}
name: {{ interface.devicename }}
Expand Down

0 comments on commit 480bf1e

Please sign in to comment.