Defined Type: psick::network::route

Defined in:
manifests/network/route.pp

Overview

Definition: psick::network::route

Manages multiples routes on a single file Configures /etc/sysconfig/networking-scripts/route-$name on Rhel Adds 2 files on Debian: One under /etc/network/if-up.d and One in /etc/network/if-down.d

Is based on the legacy network::mroute define of version 3 of this module.

Parameters:

routes

Required parameter. Must be an hash of network-gateway pairs. Example: psick::network::route { ‘bond1’:

routes => {
  '99.99.228.0/24'   => 'bond1',
  '100.100.244.0/22' => '174.136.107.1',
}

}

ECMP route with two gateways example (works only with RedHat and Debian):

psick::network::route { ‘bond1’:

routes => {
  '99.99.228.0/24'   => 'bond1',
  '100.100.244.0/22' => ['174.136.107.1', '174.136.107.2'],
}

}

route_up_template

Template to use to manage route up setup. Default is defined according to $facts[‘family’]

route_down_template

Template to use to manage route down script. Used only on Debian family.

config_file_notify

String. Optional. Default: ‘class_default’ Defines the notify argument of the created file. The default special value implies the same behaviour of the main class configuration file. Set to undef to remove any notify, or set the name(s) of the resources to notify

Actions:

On Rhel Deploys the file /etc/sysconfig/network-scripts/route-$name.

On Debian Deploy 2 files 1 under /etc/network/if-up.d and 1 in /etc/network/if-down.d

On Suse Deploys the file /etc/sysconfig/network/ifroute-$name.

Parameters:

  • routes (Hash) (defaults to: {})
  • ipv6_routes (Hash) (defaults to: {})
  • interface (String) (defaults to: $title)
  • config_file_notify (Variant[Undef,Resource,String]) (defaults to: 'class_default')
  • ensure (Enum['present','absent']) (defaults to: 'present')
  • family (Enum['ipv4','ipv6']) (defaults to: 'ipv4')
  • route_up_template (Optional[String]) (defaults to: undef)
  • route_down_template (Optional[String]) (defaults to: undef)


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'manifests/network/route.pp', line 58

define psick::network::route (
  Hash $routes                = {},
  Hash $ipv6_routes           = {},
  String $interface                     = $title,
  Variant[Undef,Resource,String] $config_file_notify = 'class_default',
  Enum['present','absent'] $ensure      = 'present',
  Enum['ipv4','ipv6'] $family           = 'ipv4',
  Optional[String] $route_up_template   = undef,
  Optional[String] $route_down_template = undef,
) {
  include psick::network

  $real_config_file_notify = $config_file_notify ? {
    'class_default' => $psick::network::manage_config_file_notify,
    default         => $config_file_notify,
  }
  $real_route_up_template = $route_up_template ? {
    undef   => $facts['os']['family'] ? {
      'RedHat' => 'psick/network/route-RedHat.erb',
      'Debian' => 'psick/network/route_up-Debian.erb',
      'SuSE'   => 'psick/network/route-SuSE.erb',
    },
    default => $route_up_template,
  }
  $real_route_down_template = $route_down_template ? {
    undef   => $facts['os']['family'] ? {
      'Debian' => 'psick/network/route_down-Debian.erb',
      default  => undef,
    },
    default => $route_down_template,
  }
  if $facts['os']['family'] == 'SuSE' {
    $networks = keys($routes)
    psick::network::validate_gw { $networks:
      routes => $routes,
    }
  }

  case $facts['os']['family'] {
    'RedHat': {
      file { "route-${name}":
        ensure  => $ensure,
        mode    => '0644',
        owner   => 'root',
        group   => 'root',
        path    => "/etc/sysconfig/network-scripts/route-${name}",
        content => template($real_route_up_template),
        notify  => $real_config_file_notify,
      }
      if $ipv6_routes != {} {
        file { "route6-${name}":
          ensure  => $ensure,
          mode    => '0644',
          owner   => 'root',
          group   => 'root',
          path    => "/etc/sysconfig/network-scripts/route6-${name}",
          content => template('psick/network/route6-RedHat.erb'),
          notify  => $real_config_file_notify,
        }
      }
    }
    'Debian': {
      file { "routeup-${name}":
        ensure  => $ensure,
        mode    => '0755',
        owner   => 'root',
        group   => 'root',
        path    => "/etc/network/if-up.d/z90-route-${name}",
        content => template($real_route_up_template),
        notify  => $real_config_file_notify,
      }
      file { "routedown-${name}":
        ensure  => $ensure,
        mode    => '0755',
        owner   => 'root',
        group   => 'root',
        path    => "/etc/network/if-down.d/z90-route-${name}",
        content => template($real_route_down_template),
        notify  => $real_config_file_notify,
      }
    }
    'SuSE': {
      file { "ifroute-${name}":
        ensure  => $ensure,
        mode    => '0644',
        owner   => 'root',
        group   => 'root',
        path    => "/etc/sysconfig/network/ifroute-${name}",
        content => template($real_route_up_template),
        notify  => $real_config_file_notify,
      }
    }
    default: { fail('Operating system not supported') }
  }
}