diff --git a/lib/puppet/provider/network_route/network_route.rb b/lib/puppet/provider/network_route/network_route.rb index f2fb5e32..2baa79eb 100644 --- a/lib/puppet/provider/network_route/network_route.rb +++ b/lib/puppet/provider/network_route/network_route.rb @@ -15,10 +15,10 @@ def routes_list routes end - def get(context) + def get(_context) instances = Array.new - routes_list.each { |route| + routes_list.map { |route| instances << self.class.routes_list_to_hash(route) #require 'pry'; binding.pry } @@ -32,18 +32,20 @@ def self.routes_list_to_hash(route) else false end - + { ensure: 'present', + prefix: route['prefix'], name: route['prefix'], default_route: default, - device: route['dev'], - protocol: route['proto'], - via: route['via'], + gateway: route['via'], + interface: route['dev'], metric: route['metric'], - scope: route['scope'], + table: route['table'], source: route['src'], + scope: route['scope'], + protocol: route['proto'], mtu: route['mtu'] - }.compact! + }.compact! end end diff --git a/lib/puppet/type/network_route.rb b/lib/puppet/type/network_route.rb index fa06c61c..54634407 100644 --- a/lib/puppet/type/network_route.rb +++ b/lib/puppet/type/network_route.rb @@ -11,30 +11,50 @@ desc: 'Whether the network route should be present or absent on the target system.', default: 'present', }, - name: { + prefix: { type: 'String', - desc: 'The name of the network route you want to manage.', + desc: 'The destination prefix/network of the route.', behaviour: :namevar, }, - network: { - type: 'String', - desc: 'The target network address.', - }, - netmask: { - type: 'String', - desc: 'The subnet mask to apply to the route.', + default_route: { + type: 'Optional[Boolean]', + desc: 'Whether the route is default or not.', }, gateway: { - type: 'IP', + type: 'Optional[String]', desc: 'The gateway to use for the route.', }, interface: { - type: 'String', + type: 'Optional[String]', desc: 'The interface to use for the route.', }, - options: { + metric: { + type: 'String', + desc: 'preference value of the route. NUMBER is an arbitrary 32bit number.', + default: '100', + }, + table: { type: 'String', - desc: 'Provider specific options to be passed to the provider.', + desc: 'table to add this route.', + default: 'local', + }, + source: { + type: 'Optional[String]', + desc: 'the source address to prefer using when sending to the destinations covered by route prefix.', + }, + scope: { + type: 'Enum["global", "nowhere", "host", "link", "site"]', + desc: 'scope of the destinations covered by the route prefix.', + default: 'global', + }, + protocol: { + type: 'String', + desc: 'routing protocol identifier of this route.', + default: 'boot', + }, + mtu: { + type: 'Optional[String]', + desc: 'the MTU along the path to destination.', }, }, )