compute: use new param for live_migration_tunnelled
[apex-tripleo-heat-templates.git] / puppet / manifests / overcloud_compute.pp
1 # Copyright 2014 Red Hat, Inc.
2 # All Rights Reserved.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License"); you may
5 # not use this file except in compliance with the License. You may obtain
6 # a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations
14 # under the License.
15
16 include ::tripleo::packages
17 include ::tripleo::firewall
18
19 create_resources(kmod::load, hiera('kernel_modules'), { })
20 create_resources(sysctl::value, hiera('sysctl_settings'), { })
21 Exec <| tag == 'kmod::load' |>  -> Sysctl <| |>
22
23 if count(hiera('ntp::servers')) > 0 {
24   include ::ntp
25 }
26
27 include ::timezone
28
29 if hiera('step') >= 4 {
30
31   file { ['/etc/libvirt/qemu/networks/autostart/default.xml',
32     '/etc/libvirt/qemu/networks/default.xml']:
33     ensure => absent,
34     before => Service['libvirt'],
35   }
36   # in case libvirt has been already running before the Puppet run, make
37   # sure the default network is destroyed
38   exec { 'libvirt-default-net-destroy':
39     command => '/usr/bin/virsh net-destroy default',
40     onlyif  => '/usr/bin/virsh net-info default | /bin/grep -i "^active:\s*yes"',
41     before  => Service['libvirt'],
42   }
43
44   # When utilising images for deployment, we need to reset the iSCSI initiator name to make it unique
45   exec { 'reset-iscsi-initiator-name':
46     command => '/bin/echo InitiatorName=$(/usr/sbin/iscsi-iname) > /etc/iscsi/initiatorname.iscsi',
47     onlyif  => '/usr/bin/test ! -f /etc/iscsi/.initiator_reset',
48   }->
49
50   file { '/etc/iscsi/.initiator_reset':
51     ensure => present,
52   }
53
54   include ::nova
55   include ::nova::config
56   include ::nova::compute
57
58   $rbd_ephemeral_storage = hiera('nova::compute::rbd::ephemeral_storage', false)
59   $rbd_persistent_storage = hiera('rbd_persistent_storage', false)
60   if $rbd_ephemeral_storage or $rbd_persistent_storage {
61     if str2bool(hiera('ceph_ipv6', false)) {
62       $mon_host = hiera('ceph_mon_host_v6')
63     } else {
64       $mon_host = hiera('ceph_mon_host')
65     }
66     class { '::ceph::profile::params':
67       mon_host            => $mon_host,
68     }
69     include ::ceph::conf
70     include ::ceph::profile::client
71
72     $client_keys = hiera('ceph::profile::params::client_keys')
73     $client_user = join(['client.', hiera('ceph_client_user_name')])
74     class { '::nova::compute::rbd':
75       libvirt_rbd_secret_key => $client_keys[$client_user]['secret'],
76     }
77   }
78
79   if hiera('cinder_enable_nfs_backend', false) {
80     if str2bool($::selinux) {
81       selboolean { 'virt_use_nfs':
82         value      => on,
83         persistent => true,
84       } -> Package['nfs-utils']
85     }
86
87     package { 'nfs-utils': } -> Service['nova-compute']
88   }
89
90   if str2bool(hiera('nova::use_ipv6', false)) {
91     $vncserver_listen = '::0'
92   } else {
93     $vncserver_listen = '0.0.0.0'
94   }
95
96   if $rbd_ephemeral_storage {
97     class { '::nova::compute::libvirt':
98       libvirt_disk_cachemodes => ['network=writeback'],
99       libvirt_hw_disk_discard => 'unmap',
100       vncserver_listen        => $vncserver_listen,
101     }
102   } else {
103     class { '::nova::compute::libvirt' :
104       vncserver_listen => $vncserver_listen,
105     }
106   }
107
108   nova_config {
109     'DEFAULT/my_ip': value => $ipaddress;
110     'DEFAULT/linuxnet_interface_driver': value => 'nova.network.linux_net.LinuxOVSInterfaceDriver';
111     'DEFAULT/host': value => $fqdn;
112   }
113
114   if hiera('neutron::core_plugin') == 'midonet.neutron.plugin_v1.MidonetPluginV2' {
115     file { '/etc/libvirt/qemu.conf':
116       ensure  => present,
117       content => hiera('midonet_libvirt_qemu_data')
118     }
119   }
120   include ::nova::network::neutron
121   include ::neutron
122   include ::neutron::config
123
124   # If the value of core plugin is set to 'nuage',
125   # include nuage agent,
126   # If the value of core plugin is set to 'midonet',
127   # include midonet agent,
128   # else use the default value of 'ml2'
129   if hiera('neutron::core_plugin') == 'neutron.plugins.nuage.plugin.NuagePlugin' {
130     include ::nuage::vrs
131     include ::nova::compute::neutron
132
133     class { '::nuage::metadataagent':
134       nova_os_tenant_name => hiera('nova::api::admin_tenant_name'),
135       nova_os_password    => hiera('nova_password'),
136       nova_metadata_ip    => hiera('nova_metadata_node_ips'),
137       nova_auth_ip        => hiera('keystone_public_api_virtual_ip'),
138     }
139   }
140   elsif hiera('neutron::core_plugin') == 'midonet.neutron.plugin_v1.MidonetPluginV2' {
141
142     # TODO(devvesa) provide non-controller ips for these services
143     $zookeeper_node_ips = hiera('neutron_api_node_ips')
144     $cassandra_node_ips = hiera('neutron_api_node_ips')
145
146     class { '::tripleo::network::midonet::agent':
147       zookeeper_servers => $zookeeper_node_ips,
148       cassandra_seeds   => $cassandra_node_ips
149     }
150   }
151   elsif hiera('neutron::core_plugin') == 'neutron_plugin_contrail.plugins.opencontrail.contrail_plugin.NeutronPluginContrailCoreV2' {
152
153     include ::contrail::vrouter
154     # NOTE: it's not possible to use this class without a functional
155     # contrail controller up and running
156     #class {'::contrail::vrouter::provision_vrouter':
157     #  require => Class['contrail::vrouter'],
158     #}
159   }
160   elsif hiera('neutron::core_plugin') == 'networking_plumgrid.neutron.plugins.plugin.NeutronPluginPLUMgridV2' {
161     # forward all ipv4 traffic
162     # this is required for the vms to pass through the gateways public interface
163     sysctl::value { 'net.ipv4.ip_forward': value => '1' }
164
165     # ifc_ctl_pp needs to be invoked by root as part of the vif.py when a VM is powered on
166     file { '/etc/sudoers.d/ifc_ctl_sudoers':
167       ensure  => file,
168       owner   => root,
169       group   => root,
170       mode    => '0440',
171       content => "nova ALL=(root) NOPASSWD: /opt/pg/bin/ifc_ctl_pp *\n",
172     }
173   }
174   else {
175
176     # NOTE: this code won't live in puppet-neutron until Neutron OVS agent
177     # can be gracefully restarted. See https://review.openstack.org/#/c/297211
178     # In the meantime, it's safe to restart the agent on each change in neutron.conf,
179     # because Puppet changes are supposed to be done during bootstrap and upgrades.
180     # Some resource managed by Neutron_config (like messaging and logging options) require
181     # a restart of OVS agent. This code does it.
182     # In Newton, OVS agent will be able to be restarted gracefully so we'll drop the code
183     # from here and fix it in puppet-neutron.
184     Neutron_config<||> ~> Service['neutron-ovs-agent-service']
185
186     include ::neutron::plugins::ml2
187     include ::neutron::agents::ml2::ovs
188
189     if 'cisco_n1kv' in hiera('neutron::plugins::ml2::mechanism_drivers') {
190       class { '::neutron::agents::n1kv_vem':
191         n1kv_source  => hiera('n1kv_vem_source', undef),
192         n1kv_version => hiera('n1kv_vem_version', undef),
193       }
194     }
195
196     if 'bsn_ml2' in hiera('neutron::plugins::ml2::mechanism_drivers') {
197       include ::neutron::agents::bigswitch
198     }
199   }
200
201   neutron_config {
202     'DEFAULT/host': value => $fqdn;
203   }
204
205   include ::ceilometer
206   include ::ceilometer::config
207   include ::ceilometer::agent::compute
208   include ::ceilometer::agent::auth
209
210   $snmpd_user = hiera('snmpd_readonly_user_name')
211   snmp::snmpv3_user { $snmpd_user:
212     authtype => 'MD5',
213     authpass => hiera('snmpd_readonly_user_password'),
214   }
215   class { '::snmp':
216     agentaddress => ['udp:161','udp6:[::1]:161'],
217     snmpd_config => [ join(['createUser ', hiera('snmpd_readonly_user_name'), ' MD5 "', hiera('snmpd_readonly_user_password'), '"']), join(['rouser ', hiera('snmpd_readonly_user_name')]), 'proc  cron', 'includeAllDisks  10%', 'master agentx', 'trapsink localhost public', 'iquerySecName internalUser', 'rouser internalUser', 'defaultMonitors yes', 'linkUpDownNotifications yes' ],
218   }
219
220   hiera_include('compute_classes')
221   package_manifest{ '/var/lib/tripleo/installed-packages/overcloud_compute': ensure => present }
222
223 }