Commit f34dafb3 authored by m.pausch's avatar m.pausch
Browse files

Fix bugs, remove unmanaged files from /etc/systemd/network

parent f712f756
node['sys']['networkd'] = {}
default_unless['sys']['networkd'] = {}
......@@ -19,12 +19,43 @@
if node['platform_version'].to_i >= 9 && !node['sys']['networkd'].empty?
delete = Dir.glob('/etc/systemd/network/*')
keep = []
node['sys']['networkd']['rename'].each do |_, name|
keep << "00-#{name}.link"
end
node['sys']['networkd']['netdev'].each do |name, config|
number_prefix = ''
unless name.match(/^[0-9]{2}-/)
number_prefix = '10-'
end
keep << "#{number_prefix}#{name}.netdev"
end
node['sys']['networkd']['network'].each do |name, config|
number_prefix = ''
unless name.match(/^[0-9]{2}-/)
number_prefix = '20-'
end
keep << "#{number_prefix}#{name}.network"
end
keep.map!{|e| "/etc/systemd/network/#{e}"}
(delete - keep).each do |f|
file f do
action :delete
end
end
node['sys']['networkd']['rename'].each do |mac, name|
template "/etc/systemd/network/00-#{name}.link" do
source "systemd_networkd_generic.erb"
helpers(Sys::Harry)
mode "0644"
vars(:sections => {'Match' => {'MACAddress' => mac}, 'Link' => {'Name' => name}})
variables(:sections => {'Match' => {'MACAddress' => mac}, 'Link' => {'Name' => name}})
end
end
......@@ -37,7 +68,7 @@ if node['platform_version'].to_i >= 9 && !node['sys']['networkd'].empty?
source "systemd_networkd_generic.erb"
helpers(Sys::Harry)
mode "0644"
vars(:sections => config)
variables(:sections => config)
end
end
......@@ -50,7 +81,7 @@ if node['platform_version'].to_i >= 9 && !node['sys']['networkd'].empty?
source "systemd_networkd_generic.erb"
helpers(Sys::Harry)
mode "0644"
vars(:sections => config)
variables(:sections => config)
end
end
end
<%= generate_harry_config(@sections) %>
\ No newline at end of file
<%= generate_harry_config(@sections) %>
<%= generate_harry_config(@sections, 0, {:spaces_around_separator => false}) %>
\ No newline at end of file
<%= generate_harry_config(@sections, 0, {:spaces_around_separator => false, :alignment => false}) %>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment