memcached (openstack) is no longer in use
[mirror/dsa-puppet.git] / 3rdparty / modules / neutron / manifests / agents / vpnaas.pp
1 #
2 # Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
3 #
4 # Author: Emilien Macchi <emilien.macchi@enovance.com>
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License"); you may
7 # not use this file except in compliance with the License. You may obtain
8 # a copy of the License at
9 #
10 #      http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 # License for the specific language governing permissions and limitations
16 # under the License.
17 #
18 # == Class: neutron::agents:vpnaas
19 #
20 # Setups Neutron VPN agent.
21 #
22 # === Parameters
23 #
24 # [*package_ensure*]
25 #   (optional) Ensure state for package. Defaults to 'present'.
26 #
27 # [*enabled*]
28 #   (optional) Enable state for service. Defaults to 'true'.
29 #
30 # [*manage_service*]
31 #   (optional) Whether to start/stop the service
32 #   Defaults to true
33 #
34 # [*vpn_device_driver*]
35 #   (optional) Defaults to 'neutron.services.vpn.device_drivers.ipsec.OpenSwanDriver'.
36 #
37 # [*interface_driver*]
38 #  (optional) Defaults to 'neutron.agent.linux.interface.OVSInterfaceDriver'.
39 #
40 # [*external_network_bridge]
41 #  (optional) Defaults to undef
42 #
43 # [*ipsec_status_check_interval*]
44 #   (optional) Status check interval. Defaults to '60'.
45 #
46 class neutron::agents::vpnaas (
47   $package_ensure              = present,
48   $enabled                     = true,
49   $manage_service              = true,
50   $vpn_device_driver           = 'neutron.services.vpn.device_drivers.ipsec.OpenSwanDriver',
51   $interface_driver            = 'neutron.agent.linux.interface.OVSInterfaceDriver',
52   $external_network_bridge     = undef,
53   $ipsec_status_check_interval = '60'
54 ) {
55
56   include neutron::params
57
58   Neutron_config<||>              ~> Service['neutron-vpnaas-service']
59   Neutron_vpnaas_agent_config<||> ~> Service['neutron-vpnaas-service']
60
61   case $vpn_device_driver {
62     /\.OpenSwan/: {
63       Package['openswan'] -> Package<| title == 'neutron-vpnaas-agent' |>
64       package { 'openswan':
65         ensure => present,
66         name   => $::neutron::params::openswan_package,
67       }
68     }
69     default: {
70       fail("Unsupported vpn_device_driver ${vpn_device_driver}")
71     }
72   }
73
74   # The VPNaaS agent loads both neutron.ini and its own file.
75   # This only lists config specific to the agent.  neutron.ini supplies
76   # the rest.
77   neutron_vpnaas_agent_config {
78     'vpnagent/vpn_device_driver':        value => $vpn_device_driver;
79     'ipsec/ipsec_status_check_interval': value => $ipsec_status_check_interval;
80     'DEFAULT/interface_driver':          value => $interface_driver;
81   }
82
83   if ($external_network_bridge) {
84     neutron_vpnaas_agent_config {
85       'DEFAULT/external_network_bridge': value => $external_network_bridge;
86     }
87   } else {
88     neutron_vpnaas_agent_config {
89       'DEFAULT/external_network_bridge': ensure => absent;
90     }
91   }
92
93   if $::neutron::params::vpnaas_agent_package {
94     Package['neutron']            -> Package['neutron-vpnaas-agent']
95     Package['neutron-vpnaas-agent'] -> Neutron_vpnaas_agent_config<||>
96     package { 'neutron-vpnaas-agent':
97       ensure  => $package_ensure,
98       name    => $::neutron::params::vpnaas_agent_package,
99     }
100   } else {
101     Package['neutron'] -> Neutron_vpnaas_agent_config<||>
102   }
103
104   if $manage_service {
105     if $enabled {
106       $service_ensure = 'running'
107     } else {
108       $service_ensure = 'stopped'
109     }
110   }
111
112   service { 'neutron-vpnaas-service':
113     ensure  => $service_ensure,
114     name    => $::neutron::params::vpnaas_agent_service,
115     enable  => $enabled,
116     require => Class['neutron'],
117   }
118 }