try again, with puppetforge modules, correctly included now
[mirror/dsa-puppet.git] / 3rdparty / modules / neutron / manifests / plugins / midonet.pp
1 # == Class: midonet::neutron_plugin
2 #
3 # Install and configure Midonet Neutron Plugin. Please note that this manifest
4 # does not install the 'python-neutron-midonet-plugin' package, it only
5 # configures Neutron to do so needed for this deployment.  Check out the
6 # MidoNet module to do so.
7 #
8 # === Parameters
9 #
10 # [*midonet_api_ip*]
11 #   IP address of the MidoNet api service
12 # [*midonet_api_port*]
13 #   IP address of the MidoNet port service. MidoNet runs in a Tomcat, so 8080
14 #   is used by default.
15 # [*keystone_username*]
16 #   Username from which midonet api will authenticate against Keystone (neutron
17 #   service is desirable and defaulted)
18 # [*keystone_password*]
19 #   Password from which midonet api will authenticate against Keystone
20 # [*keystone_tenant*]
21 #   Tenant from which midonet api will authenticate against Keystone (services
22 #   tenant is desirable and defaulted)
23 # [*sync_db*]
24 #   Whether 'midonet-db-manage' should run to create and/or syncrhonize the database
25 #   with MidoNet specific tables. Defaults to false
26 #
27 # === Examples
28 #
29 # An example call would be:
30 #
31 #     class {'neutron:plugins::midonet':
32 #         midonet_api_ip    => '23.123.5.32',
33 #         midonet_api_port  => '8080',
34 #         keystone_username => 'neutron',
35 #         keystone_password => '32kjaxT0k3na',
36 #         keystone_tenant   => 'services',
37 #         sync_db           => true
38 #     }
39 #
40 # You can alternatively use the Hiera's yaml style:
41 #     neutron::plugin::midonet::midonet_api_ip: '23.213.5.32'
42 #     neutron::plugin::midonet::port: '8080'
43 #     neutron::plugin::midonet::keystone_username: 'neutron'
44 #     neutron::plugin::midonet::keystone_password: '32.kjaxT0k3na'
45 #     neutron::plugin::midonet::keystone_tenant: 'services'
46 #     neutron::plugin::midonet::sync_db: true
47 #
48 # === Authors
49 #
50 # Midonet (http://MidoNet.org)
51 #
52 # === Copyright
53 #
54 # Copyright (c) 2015 Midokura SARL, All Rights Reserved.
55 #
56 # Licensed under the Apache License, Version 2.0 (the "License");
57 # you may not use this file except in compliance with the License.
58 # You may obtain a copy of the License at
59 #
60 #    http://www.apache.org/licenses/LICENSE-2.0
61 #
62 # Unless required by applicable law or agreed to in writing, software
63 # distributed under the License is distributed on an "AS IS" BASIS,
64 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
65 # See the License for the specific language governing permissions and
66 # limitations under the License.
67 #
68 class neutron::plugins::midonet (
69   $midonet_api_ip    = '127.0.0.1',
70   $midonet_api_port  = '8080',
71   $keystone_username = 'neutron',
72   $keystone_password = undef,
73   $keystone_tenant   = 'services',
74   $sync_db           = false
75 ) {
76
77   include ::neutron::params
78
79   Neutron_plugin_midonet<||> ~> Service['neutron-server']
80
81   ensure_resource('file', '/etc/neutron/plugins/midonet', {
82     ensure => directory,
83     owner  => 'root',
84     group  => 'neutron',
85     mode   => '0640'}
86   )
87
88   # Ensure the neutron package is installed before config is set
89   # under both RHEL and Ubuntu
90   if ($::neutron::params::server_package) {
91     Package['neutron-server'] -> Neutron_plugin_midonet<||>
92   } else {
93     Package['neutron'] -> Neutron_plugin_midonet<||>
94   }
95
96   # Although this manifest does not install midonet plugin package because it
97   # is not available in common distro repos, this statement forces you to
98   # have an orchestrator/wrapper manifest that does that job.
99   Package[$::neutron::params::midonet_server_package] -> Neutron_plugin_midonet<||>
100
101   neutron_plugin_midonet {
102     'MIDONET/midonet_uri':  value => "http://${midonet_api_ip}:${midonet_api_port}/midonet-api";
103     'MIDONET/username':     value => $keystone_username;
104     'MIDONET/password':     value => $keystone_password, secret =>true;
105     'MIDONET/project_id':   value => $keystone_tenant;
106   }
107
108   if $::osfamily == 'Debian' {
109     file_line { '/etc/default/neutron-server:NEUTRON_PLUGIN_CONFIG':
110       path    => '/etc/default/neutron-server',
111       match   => '^NEUTRON_PLUGIN_CONFIG=(.*)$',
112       line    => "NEUTRON_PLUGIN_CONFIG=${::neutron::params::midonet_config_file}",
113       require => [ Package['neutron-server'], Package[$::neutron::params::midonet_server_package] ],
114       notify  => Service['neutron-server'],
115     }
116   }
117
118   # In RH, this link is used to start Neutron process but in Debian, it's used only
119   # to manage database synchronization.
120   if defined(File['/etc/neutron/plugin.ini']) {
121     File <| path == '/etc/neutron/plugin.ini' |> { target => $::neutron::params::midonet_config_file }
122   }
123   else {
124     file {'/etc/neutron/plugin.ini':
125       ensure  => link,
126       target  => $::neutron::params::midonet_config_file,
127       require => Package[$::neutron::params::midonet_server_package]
128     }
129   }
130
131   if $sync_db {
132
133     Package<| title == $::neutron::params::midonet_server_package |> ~> Exec['midonet-db-sync']
134
135     exec { 'midonet-db-sync':
136       command     => 'midonet-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head',
137       path        => '/usr/bin',
138       before      => Service['neutron-server'],
139       subscribe   => Neutron_config['database/connection'],
140       refreshonly => true
141     }
142   }
143 }
144