0b8175762a12748d9880afee173174827aa47f42
[genesis.git] / common / puppet-opnfv / manifests / compute.pp
1 #Copyright 2015 Open Platform for NFV Project, Inc. and its contributors
2 #
3 #   Licensed under the Apache License, Version 2.0 (the "License");
4 #   you may not use this file except in compliance with the License.
5 #   You may obtain a copy of the License at
6 #
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #
9 #   Unless required by applicable law or agreed to in writing, software
10 #   distributed under the License is distributed on an "AS IS" BASIS,
11 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 #   See the License for the specific language governing permissions and
13 #   limitations under the License.
14 #
15 #Provides a manifest to configure OpenStack compute node in HA or non-HA
16 #environment, with Ceph configured as Cinder backend storage.
17 #ha_flag set to true will use virtual IP addresses (VIPs provided by
18 #global params) as the provider to the compute node for HA
19
20 class opnfv::compute {
21   if ($odl_flag != '') and str2bool($odl_flag) {
22      $ml2_mech_drivers = ['opendaylight']
23      $this_agent = 'opendaylight'
24   }
25   else {
26     $ml2_mech_drivers = ['openvswitch','l2population']
27     $this_agent = 'ovs'
28   }
29
30   ##Common Parameters
31   if !$rbd_secret_uuid { $rbd_secret_uuid = '3b519746-4021-4f72-957e-5b9d991723be' }
32   if !$private_subnet { fail('private_subnet is empty')}
33   if !$ceph_public_network { $ceph_public_network = $private_subnet }
34   if !$ceph_fsid { $ceph_fsid = '904c8491-5c16-4dae-9cc3-6ce633a7f4cc' }
35   if !$ceph_images_key { $ceph_images_key = 'AQAfHBdUKLnUFxAAtO7WPKQZ8QfEoGqH0CLd7A==' }
36   if !$ceph_osd_journal_size { $ceph_osd_journal_size = '1000' }
37   if !$ceph_osd_pool_size { $ceph_osd_pool_size = '1' }
38   if !$ceph_volumes_key { $ceph_volumes_key = 'AQAfHBdUsFPTHhAAfqVqPq31FFCvyyO7oaOQXw==' }
39
40
41   ##Most users will only care about a single user/password for all services
42   ##so lets create one variable that can be used instead of separate usernames/passwords
43   if !$single_username { $single_username = 'octopus' }
44   if !$single_password { $single_password = 'octopus' }
45
46   if !$admin_password { $admin_password = $single_password }
47   if !$neutron_db_password  { $neutron_db_password = $single_password }
48   if !$neutron_user_password  { $neutron_user_password = $single_password }
49
50   if !$ceilometer_user_password { $ceilometer_user_password = $single_password }
51   if !$ceilometer_metering_secret { $ceilometer_metering_secret = $single_password }
52
53   ##HA Global params
54   if $ha_flag {
55      if $private_network == '' { fail('private_network is empty') }
56      if !$keystone_private_vip { fail('keystone_private_vip is empty') }
57      if !$glance_private_vip { fail('glance_private_vip is empty') }
58      if !$nova_private_vip { fail('nova_private_vip is empty') }
59      if !$nova_db_password { $nova_db_password = $single_password }
60      if !$nova_user_password { $nova_user_password = $single_password }
61      if !$controllers_ip_array { fail('controllers_ip_array is empty') }
62      if !$controllers_hostnames_array { fail('controllers_hostnames_array is empty') }
63      $controllers_ip_array = split($controllers_ip_array, ',')
64      $controllers_hostnames_array = split($controllers_hostnames_array, ',')
65      if !$odl_control_ip  { $odl_control_ip =  $controllers_ip_array[0] }
66      if !$db_vip { fail('db_vip is empty') }
67      $mysql_ip = $db_vip
68      if !$amqp_vip { fail('amqp_vip is empty') }
69      $amqp_ip = $amqp_vip
70      if !$amqp_username { $amqp_username = $single_username }
71      if !$amqp_password { $amqp_password = $single_password }
72      if !$ceph_mon_initial_members { $ceph_mon_initial_members = $controllers_hostnames_array }
73      if !$ceph_mon_host { $ceph_mon_host = $controllers_ip_array }
74      if !$neutron_private_vip { fail('neutron_private_vip is empty') }
75
76     ##Find private interface
77     $ovs_tunnel_if = get_nic_from_network("$private_network")
78
79   } else {
80   ##non HA params
81      if $ovs_tunnel_if == '' { fail('ovs_tunnel_if is empty') }
82      if !$private_ip { fail('private_ip is empty') }
83      $keystone_private_vip = $private_ip
84      $glance_private_vip   = $private_ip
85      $nova_private_vip     = $private_ip
86      $neutron_private_vip  = $private_ip
87      if !$nova_db_password { fail('nova_db_password is empty') }
88      if !$nova_user_password { fail('nova_user_password is empty') }
89      if !$odl_control_ip { $odl_control_ip = $private_ip }
90      if !$mysql_ip { $mysql_ip = $private_ip }
91      if !$amqp_ip { $amqp_ip = $private_ip }
92      if !$amqp_username { $amqp_username = 'guest' }
93      if !$amqp_password { $amqp_password = 'guest' }
94      if !$ceph_mon_host { $ceph_mon_host= ["$private_ip"] }
95      if !$ceph_mon_initial_members { $ceph_mon_initial_members = ["$::hostname"] }
96   }
97
98   class { "quickstack::neutron::compute":
99     auth_host                    => $keystone_private_vip,
100     glance_host                  => $glance_private_vip,
101     libvirt_images_rbd_pool      => 'volumes',
102     libvirt_images_rbd_ceph_conf => '/etc/ceph/ceph.conf',
103     libvirt_inject_password      => 'false',
104     libvirt_inject_key           => 'false',
105     libvirt_images_type          => 'rbd',
106     nova_host                    => $nova_private_vip,
107     nova_db_password             => $nova_db_password,
108     nova_user_password           => $nova_user_password,
109     private_network              => '',
110     private_iface                => $ovs_tunnel_if,
111     private_ip                   => '',
112     rbd_user                     => 'volumes',
113     rbd_secret_uuid              => $rbd_secret_uuid,
114     network_device_mtu           => $quickstack::params::network_device_mtu,
115
116     admin_password               => $admin_password,
117     ssl                          => false,
118
119     mysql_host                   => $mysql_ip,
120     mysql_ca                     =>  '/etc/ipa/ca.crt',
121     amqp_host                    => $amqp_ip,
122     amqp_username                => $amqp_username,
123     amqp_password                => $amqp_password,
124
125     ceilometer                   => 'false',
126     ceilometer_metering_secret   => $ceilometer_metering_secret,
127     ceilometer_user_password     => $ceilometer_user_password,
128
129     cinder_backend_gluster       => $quickstack::params::cinder_backend_gluster,
130     cinder_backend_rbd           => 'true',
131     glance_backend_rbd           => 'true',
132     ceph_cluster_network         => $ceph_public_network,
133     ceph_fsid                    => $ceph_fsid,
134     ceph_images_key              => $ceph_images_key,
135     ceph_mon_host                => $ceph_mon_host,
136     ceph_mon_initial_members     => $ceph_mon_initial_members,
137     ceph_osd_pool_default_size   => $ceph_osd_pool_size,
138     ceph_osd_journal_size        => $ceph_osd_journal_size,
139     ceph_volumes_key             => $ceph_volumes_key,
140
141     agent_type                   => $this_agent,
142     enable_tunneling             => true,
143
144     ml2_mechanism_drivers        => $ml2_mech_drivers,
145     odl_controller_ip            => $odl_control_ip,
146
147     neutron_db_password          => $neutron_db_password,
148     neutron_user_password        => $neutron_user_password,
149     neutron_host                 => $neutron_private_vip,
150
151     ovs_tunnel_iface             => $ovs_tunnel_if,
152     ovs_tunnel_network           => '',
153     ovs_l2_population            => 'false',
154
155     tenant_network_type          => 'vxlan',
156     tunnel_id_ranges             => '1:1000',
157     ovs_tunnel_types             => ['vxlan'],
158
159     verbose                      => 'true',
160     security_group_api           => 'neutron',
161
162   }
163 }