diff --git a/lib/puppet/provider/network_config/interfaces.rb b/lib/puppet/provider/network_config/interfaces.rb index a50f1e6..bf2c811 100644 --- a/lib/puppet/provider/network_config/interfaces.rb +++ b/lib/puppet/provider/network_config/interfaces.rb @@ -245,7 +245,7 @@ def self.parse_file(_filename, contents) end def self.interface_order(name, rules) - (rules['rules'].map{ |entry| if name.match(entry.first) then entry.last end } + [rules['default']]).compact.first + (rules['rules'].map { |entry| entry.last if name.match(entry.first) } + [rules['default']]).compact.first end # Generate an array of sections @@ -257,7 +257,7 @@ def self.format_file(_filename, providers) auto_interfaces = providers.select { |provider| provider.onboot == true } unless auto_interfaces.empty? stanza = [] - stanza << ('auto ' + auto_interfaces.sort_by{ |provider| interface_order(provider.name, provider.order_rules) }.map(&:name).join(' ')) + stanza << ('auto ' + auto_interfaces.sort_by { |provider| interface_order(provider.name, provider.order_rules) }.map(&:name).join(' ')) contents << stanza.join("\n") end @@ -265,12 +265,12 @@ def self.format_file(_filename, providers) hotplug_interfaces = providers.select { |provider| provider.hotplug == true } unless hotplug_interfaces.empty? stanza = [] - stanza << ('allow-hotplug ' + hotplug_interfaces.sort_by{ |provider| interface_order(provider.name, provider.order_rules) }.map(&:name).join(' ')) + stanza << ('allow-hotplug ' + hotplug_interfaces.sort_by { |provider| interface_order(provider.name, provider.order_rules) }.map(&:name).join(' ')) contents << stanza.join("\n") end # Build iface stanzas - providers.sort_by{ |provider| interface_order(provider.name, provider.order_rules) }.each do |provider| + providers.sort_by { |provider| interface_order(provider.name, provider.order_rules) }.each do |provider| # TODO: add validation method raise Puppet::Error, "#{provider.name} does not have a method." if provider.method.nil? raise Puppet::Error, "#{provider.name} does not have a family." if provider.family.nil?