Composable Timezone service - CephStorage
[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 hiera('step') >= 4 {
24
25   file { ['/etc/libvirt/qemu/networks/autostart/default.xml',
26     '/etc/libvirt/qemu/networks/default.xml']:
27     ensure => absent,
28     before => Service['libvirt'],
29   }
30   # in case libvirt has been already running before the Puppet run, make
31   # sure the default network is destroyed
32   exec { 'libvirt-default-net-destroy':
33     command => '/usr/bin/virsh net-destroy default',
34     onlyif  => '/usr/bin/virsh net-info default | /bin/grep -i "^active:\s*yes"',
35     before  => Service['libvirt'],
36   }
37
38   # When utilising images for deployment, we need to reset the iSCSI initiator name to make it unique
39   exec { 'reset-iscsi-initiator-name':
40     command => '/bin/echo InitiatorName=$(/usr/sbin/iscsi-iname) > /etc/iscsi/initiatorname.iscsi',
41     onlyif  => '/usr/bin/test ! -f /etc/iscsi/.initiator_reset',
42   }->
43
44   file { '/etc/iscsi/.initiator_reset':
45     ensure => present,
46   }
47
48   $rbd_ephemeral_storage = hiera('nova::compute::rbd::ephemeral_storage', false)
49   $rbd_persistent_storage = hiera('rbd_persistent_storage', false)
50   if $rbd_ephemeral_storage or $rbd_persistent_storage {
51     if str2bool(hiera('ceph_ipv6', false)) {
52       $mon_host = hiera('ceph_mon_host_v6')
53     } else {
54       $mon_host = hiera('ceph_mon_host')
55     }
56     class { '::ceph::profile::params':
57       mon_host            => $mon_host,
58     }
59     include ::ceph::conf
60     include ::ceph::profile::client
61
62     $client_keys = hiera('ceph::profile::params::client_keys')
63     $client_user = join(['client.', hiera('tripleo::profile::base::cinder::volume::rbd::cinder_rbd_user_name')])
64     class { '::nova::compute::rbd':
65       libvirt_rbd_secret_key => $client_keys[$client_user]['secret'],
66     }
67   }
68
69   if hiera('cinder_enable_nfs_backend', false) {
70     if str2bool($::selinux) {
71       selboolean { 'virt_use_nfs':
72         value      => on,
73         persistent => true,
74       } -> Package['nfs-utils']
75     }
76
77     package { 'nfs-utils': } -> Service['nova-compute']
78   }
79
80   if str2bool(hiera('nova::use_ipv6', false)) {
81     $vncserver_listen = '::0'
82   } else {
83     $vncserver_listen = '0.0.0.0'
84   }
85
86   if $rbd_ephemeral_storage {
87     class { '::nova::compute::libvirt':
88       libvirt_disk_cachemodes => ['network=writeback'],
89       libvirt_hw_disk_discard => 'unmap',
90       vncserver_listen        => $vncserver_listen,
91     }
92   } else {
93     class { '::nova::compute::libvirt' :
94       vncserver_listen => $vncserver_listen,
95     }
96   }
97
98   nova_config {
99     'DEFAULT/my_ip': value => $ipaddress;
100     'DEFAULT/linuxnet_interface_driver': value => 'nova.network.linux_net.LinuxOVSInterfaceDriver';
101   }
102
103   if hiera('neutron::core_plugin') == 'midonet.neutron.plugin_v1.MidonetPluginV2' {
104     file { '/etc/libvirt/qemu.conf':
105       ensure  => present,
106       content => hiera('midonet_libvirt_qemu_data')
107     }
108   }
109   include ::nova::network::neutron
110   include ::neutron
111   include ::neutron::config
112
113   # If the value of core plugin is set to 'nuage',
114   # include nuage agent,
115   # If the value of core plugin is set to 'midonet',
116   # include midonet agent,
117   # else use the default value of 'ml2'
118   if hiera('neutron::core_plugin') == 'neutron.plugins.nuage.plugin.NuagePlugin' {
119     include ::nuage::vrs
120     include ::nova::compute::neutron
121
122     class { '::nuage::metadataagent':
123       nova_os_tenant_name => hiera('nova::api::admin_tenant_name'),
124       nova_os_password    => hiera('nova_password'),
125       nova_metadata_ip    => hiera('nova_metadata_node_ips'),
126       nova_auth_ip        => hiera('keystone_public_api_virtual_ip'),
127     }
128   }
129   elsif hiera('neutron::core_plugin') == 'midonet.neutron.plugin_v1.MidonetPluginV2' {
130
131     # TODO(devvesa) provide non-controller ips for these services
132     $zookeeper_node_ips = hiera('neutron_api_node_ips')
133     $cassandra_node_ips = hiera('neutron_api_node_ips')
134
135     class { '::tripleo::network::midonet::agent':
136       zookeeper_servers => $zookeeper_node_ips,
137       cassandra_seeds   => $cassandra_node_ips
138     }
139   }
140   elsif hiera('neutron::core_plugin') == 'neutron_plugin_contrail.plugins.opencontrail.contrail_plugin.NeutronPluginContrailCoreV2' {
141
142     include ::contrail::vrouter
143     # NOTE: it's not possible to use this class without a functional
144     # contrail controller up and running
145     #class {'::contrail::vrouter::provision_vrouter':
146     #  require => Class['contrail::vrouter'],
147     #}
148   }
149   elsif hiera('neutron::core_plugin') == 'networking_plumgrid.neutron.plugins.plugin.NeutronPluginPLUMgridV2' {
150     # forward all ipv4 traffic
151     # this is required for the vms to pass through the gateways public interface
152     sysctl::value { 'net.ipv4.ip_forward': value => '1' }
153
154     # ifc_ctl_pp needs to be invoked by root as part of the vif.py when a VM is powered on
155     file { '/etc/sudoers.d/ifc_ctl_sudoers':
156       ensure  => file,
157       owner   => root,
158       group   => root,
159       mode    => '0440',
160       content => "nova ALL=(root) NOPASSWD: /opt/pg/bin/ifc_ctl_pp *\n",
161     }
162   }
163   else {
164
165     # NOTE: this code won't live in puppet-neutron until Neutron OVS agent
166     # can be gracefully restarted. See https://review.openstack.org/#/c/297211
167     # In the meantime, it's safe to restart the agent on each change in neutron.conf,
168     # because Puppet changes are supposed to be done during bootstrap and upgrades.
169     # Some resource managed by Neutron_config (like messaging and logging options) require
170     # a restart of OVS agent. This code does it.
171     # In Newton, OVS agent will be able to be restarted gracefully so we'll drop the code
172     # from here and fix it in puppet-neutron.
173     Neutron_config<||> ~> Service['neutron-ovs-agent-service']
174
175     include ::neutron::plugins::ml2
176     include ::neutron::agents::ml2::ovs
177
178     if 'cisco_n1kv' in hiera('neutron::plugins::ml2::mechanism_drivers') {
179       class { '::neutron::agents::n1kv_vem':
180         n1kv_source  => hiera('n1kv_vem_source', undef),
181         n1kv_version => hiera('n1kv_vem_version', undef),
182       }
183     }
184
185     if 'bsn_ml2' in hiera('neutron::plugins::ml2::mechanism_drivers') {
186       include ::neutron::agents::bigswitch
187     }
188   }
189
190   include ::ceilometer
191   include ::ceilometer::config
192   include ::ceilometer::agent::compute
193   include ::ceilometer::agent::auth
194
195   hiera_include('compute_classes')
196 }
197
198 $package_manifest_name = join(['/var/lib/tripleo/installed-packages/overcloud_compute', hiera('step')])
199 package_manifest{$package_manifest_name: ensure => present}