ac967ca65fdf6654bc0e4f9e763da956053ea9e3
[mirror/dsa-puppet.git] / 3rdparty / modules / neutron / manifests / agents / lbaas.pp
1 # == Class: neutron::agents:lbaas:
2 #
3 # Setups Neutron Load Balancing agent.
4 #
5 # === Parameters
6 #
7 # [*package_ensure*]
8 #   (optional) Ensure state for package. Defaults to 'present'.
9 #
10 # [*enabled*]
11 #   (optional) Enable state for service. Defaults to 'true'.
12 #
13 # [*manage_service*]
14 #   (optional) Whether to start/stop the service
15 #   Defaults to true
16 #
17 # [*debug*]
18 #   (optional) Show debugging output in log. Defaults to false.
19 #
20 # [*interface_driver*]
21 #   (optional) Defaults to 'neutron.agent.linux.interface.OVSInterfaceDriver'.
22 #
23 # [*device_driver*]
24 #   (optional) Defaults to 'neutron.services.loadbalancer.drivers.haproxy.namespace_driver.HaproxyNSDriver'.
25 #
26 # [*use_namespaces*]
27 #   (optional) Allow overlapping IP (Must have kernel build with
28 #   CONFIG_NET_NS=y and iproute2 package that supports namespaces).
29 #   Defaults to true.
30 #
31 # [*user_group*]
32 #   (optional) The user group.
33 #   Defaults to $::neutron::params::nobody_user_group
34 #
35 # [*manage_haproxy_package*]
36 #   (optional) Whether to manage the haproxy package.
37 #   Disable this if you are using the puppetlabs-haproxy module
38 #   Defaults to true
39 #
40 class neutron::agents::lbaas (
41   $package_ensure         = present,
42   $enabled                = true,
43   $manage_service         = true,
44   $debug                  = false,
45   $interface_driver       = 'neutron.agent.linux.interface.OVSInterfaceDriver',
46   $device_driver          = 'neutron.services.loadbalancer.drivers.haproxy.namespace_driver.HaproxyNSDriver',
47   $use_namespaces         = true,
48   $user_group             = $::neutron::params::nobody_user_group,
49   $manage_haproxy_package = true,
50 ) {
51
52   include neutron::params
53
54   Neutron_config<||>             ~> Service['neutron-lbaas-service']
55   Neutron_lbaas_agent_config<||> ~> Service['neutron-lbaas-service']
56
57   case $device_driver {
58     /\.haproxy/: {
59       Package <| title == $::neutron::params::haproxy_package |> -> Package <| title == 'neutron-lbaas-agent' |>
60       if $manage_haproxy_package {
61         ensure_packages([$::neutron::params::haproxy_package])
62       }
63     }
64     default: {
65       fail("Unsupported device_driver ${device_driver}")
66     }
67   }
68
69   # The LBaaS agent loads both neutron.ini and its own file.
70   # This only lists config specific to the agent.  neutron.ini supplies
71   # the rest.
72   neutron_lbaas_agent_config {
73     'DEFAULT/debug':              value => $debug;
74     'DEFAULT/interface_driver':   value => $interface_driver;
75     'DEFAULT/device_driver':      value => $device_driver;
76     'DEFAULT/use_namespaces':     value => $use_namespaces;
77     'haproxy/user_group':         value => $user_group;
78   }
79
80   if $::neutron::params::lbaas_agent_package {
81     Package['neutron']            -> Package['neutron-lbaas-agent']
82     Package['neutron-lbaas-agent'] -> Neutron_config<||>
83     Package['neutron-lbaas-agent'] -> Neutron_lbaas_agent_config<||>
84     package { 'neutron-lbaas-agent':
85       ensure  => $package_ensure,
86       name    => $::neutron::params::lbaas_agent_package,
87     }
88   } else {
89     # Some platforms (RedHat) do not provide a neutron LBaaS agent package.
90     # The neutron LBaaS agent config file is provided by the neutron package.
91     Package['neutron'] -> Neutron_lbaas_agent_config<||>
92   }
93
94   if $manage_service {
95     if $enabled {
96       $service_ensure = 'running'
97     } else {
98       $service_ensure = 'stopped'
99     }
100   }
101
102   service { 'neutron-lbaas-service':
103     ensure  => $service_ensure,
104     name    => $::neutron::params::lbaas_agent_service,
105     enable  => $enabled,
106     require => Class['neutron'],
107   }
108 }