memcached (openstack) is no longer in use
[mirror/dsa-puppet.git] / 3rdparty / modules / neutron / manifests / agents / ml2 / linuxbridge.pp
1 # == Class: neutron::agents::ml2::linuxbridge
2 #
3 # Setups Linuxbridge Neutron agent for ML2 plugin.
4 #
5 # === Parameters
6 #
7 # [*package_ensure*]
8 #   (optional) Package ensure state.
9 #   Defaults to 'present'.
10 #
11 # [*enabled*]
12 #   (required) Whether or not to enable the agent.
13 #   Defaults to true.
14 #
15 # [*tunnel_types*]
16 #   (optional) List of types of tunnels to use when utilizing tunnels.
17 #   Supported tunnel types are: vxlan.
18 #   Defaults to an empty list.
19 #
20 # [*local_ip*]
21 #   (optional) Local IP address to use for VXLAN endpoints.
22 #   Required when enabling tunneling.
23 #   Defaults to false.
24 #
25 # [*vxlan_group*]
26 #   (optional) Multicast group for vxlan interface. If unset, disables VXLAN
27 #   multicast mode. Should be an Multicast IP (v4 or v6) address.
28 #   Default to '224.0.0.1'.
29 #
30 # [*vxlan_ttl*]
31 #   (optional) TTL for vxlan interface protocol packets..
32 #   Default to undef.
33 #
34 # [*vxlan_tos*]
35 #   (optional) TOS for vxlan interface protocol packets..
36 #   Defaults to undef.
37 #
38 # [*polling_interval*]
39 #   (optional) The number of seconds the agent will wait between
40 #   polling for local device changes.
41 #   Defaults to 2.
42 #
43 # [*l2_population*]
44 #   (optional) Extension to use alongside ml2 plugin's l2population
45 #   mechanism driver. It enables the plugin to populate VXLAN forwarding table.
46 #   Defaults to false.
47 #
48 # [*physical_interface_mappings*]
49 #   (optional) List of <physical_network>:<physical_interface>
50 #   tuples mapping physical network names to agent's node-specific physical
51 #   network interfaces. Defaults to empty list.
52 #
53 # [*firewall_driver*]
54 #   (optional) Firewall driver for realizing neutron security group function.
55 #   Defaults to 'neutron.agent.linux.iptables_firewall.IptablesFirewallDriver'.
56 #
57 class neutron::agents::ml2::linuxbridge (
58   $package_ensure   = 'present',
59   $enabled          = true,
60   $tunnel_types     = [],
61   $local_ip         = false,
62   $vxlan_group      = '224.0.0.1',
63   $vxlan_ttl        = false,
64   $vxlan_tos        = false,
65   $polling_interval = 2,
66   $l2_population    = false,
67   $physical_interface_mappings = [],
68   $firewall_driver  = 'neutron.agent.linux.iptables_firewall.IptablesFirewallDriver'
69 ) {
70
71   validate_array($tunnel_types)
72   validate_array($physical_interface_mappings)
73
74   include neutron::params
75
76   Package['neutron-plugin-linuxbridge-agent'] -> Neutron_plugin_linuxbridge<||>
77   Neutron_plugin_linuxbridge<||> ~> Service['neutron-plugin-linuxbridge-agent']
78
79   if ('vxlan' in $tunnel_types) {
80
81     if ! $local_ip {
82       fail('The local_ip parameter is required when vxlan tunneling is enabled')
83     }
84
85     if $vxlan_group {
86       neutron_plugin_linuxbridge { 'vxlan/vxlan_group': value => $vxlan_group }
87     } else {
88       neutron_plugin_linuxbridge { 'vxlan/vxlan_group': ensure => absent }
89     }
90
91     if $vxlan_ttl {
92       neutron_plugin_linuxbridge { 'vxlan/vxlan_ttl': value => $vxlan_ttl }
93     } else {
94       neutron_plugin_linuxbridge { 'vxlan/vxlan_ttl': ensure => absent }
95     }
96
97     if $vxlan_tos {
98       neutron_plugin_linuxbridge { 'vxlan/vxlan_tos': value => $vxlan_tos }
99     } else {
100       neutron_plugin_linuxbridge { 'vxlan/vxlan_tos': ensure => absent }
101     }
102
103     neutron_plugin_linuxbridge {
104       'vxlan/enable_vxlan':  value => true;
105       'vxlan/local_ip':      value => $local_ip;
106       'vxlan/l2_population': value => $l2_population;
107     }
108   } else {
109     neutron_plugin_linuxbridge {
110       'vxlan/enable_vxlan':  value  => false;
111       'vxlan/local_ip':      ensure => absent;
112       'vxlan/vxlan_group':   ensure => absent;
113       'vxlan/l2_population': ensure => absent;
114     }
115   }
116
117   neutron_plugin_linuxbridge {
118     'agent/polling_interval':                   value => $polling_interval;
119     'linux_bridge/physical_interface_mappings': value => join($physical_interface_mappings, ',');
120   }
121
122   if $firewall_driver {
123     neutron_plugin_linuxbridge { 'securitygroup/firewall_driver': value => $firewall_driver }
124   } else {
125     neutron_plugin_linuxbridge { 'securitygroup/firewall_driver': ensure => absent }
126   }
127
128   if $::neutron::params::linuxbridge_agent_package {
129     package { 'neutron-plugin-linuxbridge-agent':
130       ensure  => $package_ensure,
131       name    => $::neutron::params::linuxbridge_agent_package,
132     }
133   } else {
134     # Some platforms (RedHat) do not provide a separate
135     # neutron plugin linuxbridge agent package.
136     if ! defined(Package['neutron-plugin-linuxbridge-agent']) {
137       package { 'neutron-plugin-linuxbridge-agent':
138         ensure  => $package_ensure,
139         name    => $::neutron::params::linuxbridge_server_package,
140       }
141     }
142   }
143
144   if $enabled {
145     $service_ensure = 'running'
146   } else {
147     $service_ensure = 'stopped'
148   }
149
150   service { 'neutron-plugin-linuxbridge-agent':
151     ensure  => $service_ensure,
152     name    => $::neutron::params::linuxbridge_agent_service,
153     enable  => $enabled,
154     require => Class['neutron']
155   }
156 }