Puppet Class: tripleo::profile::pacemaker::manila::share_bundle

Defined in:
manifests/profile/pacemaker/manila/share_bundle.pp

Overview

Copyright 2017 Red Hat, Inc.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Class: tripleo::profile::pacemaker::manila::share_bundle

Containerized Redis Pacemaker HA profile for tripleo

Parameters

ceph_nfs_enabled

(Optional) Whether or not the ceph_nfs service is enabled Defaults to lookup(‘ceph_nfs_enabled’, undef, undef, false)

manila_share_docker_image

(Optional) The docker image to use for creating the pacemaker bundle Defaults to undef,

docker_volumes

(Optional) The list of volumes to be mounted in the docker container Defaults to []

docker_environment

(Optional) List or Hash of environment variables set in the docker container Defaults to => ‘COPY_ALWAYS’

pcs_tries

(Optional) The number of times pcs commands should be retried. Defaults to lookup(‘pcs_tries’, undef, undef, 20)

bootstrap_node

(Optional) The hostname of the node responsible for bootstrapping tasks Defaults to lookup(‘redis_short_bootstrap_node_name’)

step

(Optional) The current step in deployment. See tripleo-heat-templates for more details. Defaults to Integer(lookup(‘step’))

container_backend

(optional) Container backend to use when creating the bundle Defaults to ‘podman’

ceph_conf_path

(optional) The path where the Ceph Cluster config files are stored on the host Defaults to ‘/etc/ceph’

log_driver

(optional) Container log driver to use. Defaults to ‘k8s-file’

log_file

(optional) Container log file to use. Only relevant when log_driver is set to ‘k8s-file’. Defaults to ‘/var/log/containers/stdouts/openstack-manila-share.log’

tls_priorities

(optional) Sets PCMK_tls_priorities in /etc/sysconfig/pacemaker when set Defaults to lookup(‘tripleo::pacemaker::tls_priorities’, undef, undef, undef)

bundle_user

(optional) Set the –user= switch to be passed to pcmk Defaults to ‘root’

Parameters:

  • bootstrap_node (Any) (defaults to: lookup('manila_share_short_bootstrap_node_name'))
  • manila_share_docker_image (Any) (defaults to: undef)
  • docker_volumes (Any) (defaults to: [])
  • docker_environment (Any) (defaults to: {'KOLLA_CONFIG_STRATEGY' => 'COPY_ALWAYS'})
  • ceph_nfs_enabled (Any) (defaults to: lookup('ceph_nfs_enabled', undef, undef, false))
  • container_backend (Any) (defaults to: 'podman')
  • ceph_conf_path (Any) (defaults to: '/etc/ceph')
  • tls_priorities (Any) (defaults to: lookup('tripleo::pacemaker::tls_priorities', undef, undef, undef))
  • bundle_user (Any) (defaults to: 'root')
  • log_driver (Any) (defaults to: 'k8s-file')
  • log_file (Any) (defaults to: '/var/log/containers/stdouts/openstack-manila-share.log')
  • pcs_tries (Any) (defaults to: lookup('pcs_tries', undef, undef, 20))
  • step (Any) (defaults to: Integer(lookup('step')))


75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# File 'manifests/profile/pacemaker/manila/share_bundle.pp', line 75

class tripleo::profile::pacemaker::manila::share_bundle (
  $bootstrap_node             = lookup('manila_share_short_bootstrap_node_name'),
  $manila_share_docker_image  = undef,
  $docker_volumes             = [],
  $docker_environment         = {'KOLLA_CONFIG_STRATEGY' => 'COPY_ALWAYS'},
  $ceph_nfs_enabled           = lookup('ceph_nfs_enabled', undef, undef, false),
  $container_backend          = 'podman',
  $ceph_conf_path             = '/etc/ceph',
  $tls_priorities             = lookup('tripleo::pacemaker::tls_priorities', undef, undef, undef),
  $bundle_user                = 'root',
  $log_driver                 = 'k8s-file',
  $log_file                   = '/var/log/containers/stdouts/openstack-manila-share.log',
  $pcs_tries                  = lookup('pcs_tries', undef, undef, 20),
  $step                       = Integer(lookup('step')),
) {
  if $bootstrap_node and $::hostname == downcase($bootstrap_node) {
    $pacemaker_master = true
  } else {
    $pacemaker_master = false
  }

  if $log_driver == 'k8s-file' {
    $log_file_real = " --log-opt path=${log_file}"
  } else {
    $log_file_real = ''
  }
  include tripleo::profile::base::manila::share

  if $step >= 2 and $pacemaker_master {
    $manila_share_short_node_names = lookup('manila_share_short_node_names')

    if (lookup('pacemaker_short_node_names_override', undef, undef, undef)) {
      $pacemaker_short_node_names = lookup('pacemaker_short_node_names_override')
    } else {
      $pacemaker_short_node_names = lookup('pacemaker_short_node_names')
    }

    $pcmk_cinder_volume_nodes = intersection($manila_share_short_node_names, $pacemaker_short_node_names)
    $pcmk_cinder_volume_nodes.each |String $node_name| {
      pacemaker::property { "manila-share-role-${node_name}":
        property => 'manila-share-role',
        value    => true,
        tries    => $pcs_tries,
        node     => downcase($node_name),
        before   => Pacemaker::Resource::Bundle[$::manila::params::share_service],
      }
    }
  }

  if $step >= 5 {
    if $pacemaker_master {
      $manila_cephfs_protocol_helper_type = lookup('manila::backend::cephfs::cephfs_protocol_helper_type', undef, undef, '')
      $docker_vol_arr = delete(any2array($docker_volumes), '').flatten()

      unless empty($docker_vol_arr) {
        $storage_maps = docker_volumes_to_storage_maps($docker_vol_arr, 'manila-share')
      } else {
        notice('Using fixed list of docker volumes for manila-share bundle')
        # Default to previous hard-coded list
        $default_storage_maps = {
          'manila-share-cfg-files'               => {
            'source-dir' => '/var/lib/kolla/config_files/manila_share.json',
            'target-dir' => '/var/lib/kolla/config_files/config.json',
            'options'    => 'ro',
          },
          'manila-share-cfg-data'                => {
            'source-dir' => '/var/lib/config-data/puppet-generated/manila/',
            'target-dir' => '/var/lib/kolla/config_files/src',
            'options'    => 'ro',
          },
          'manila-share-hosts'                   => {
            'source-dir' => '/etc/hosts',
            'target-dir' => '/etc/hosts',
            'options'    => 'ro',
          },
          'manila-share-localtime'               => {
            'source-dir' => '/etc/localtime',
            'target-dir' => '/etc/localtime',
            'options'    => 'ro',
          },
          'manila-share-dev'                     => {
            'source-dir' => '/dev',
            'target-dir' => '/dev',
            'options'    => 'rw',
          },
          'manila-share-run'                     => {
            'source-dir' => '/run',
            'target-dir' => '/run',
            'options'    => 'rw',
          },
          'manila-share-sys'                     => {
            'source-dir' => '/sys',
            'target-dir' => '/sys',
            'options'    => 'rw',
          },
          'manila-share-lib-modules'             => {
            'source-dir' => '/lib/modules',
            'target-dir' => '/lib/modules',
            'options'    => 'ro',
          },
          'manila-share-var-lib-manila'          => {
            'source-dir' => '/var/lib/manila',
            'target-dir' => '/var/lib/manila',
            'options'    => 'rw,z',
          },
          'manila-share-pki-extracted'           => {
            'source-dir' => '/etc/pki/ca-trust/extracted',
            'target-dir' => '/etc/pki/ca-trust/extracted',
            'options'    => 'ro',
          },
          'manila-share-pki-ca-bundle-crt'       => {
            'source-dir' => '/etc/pki/tls/certs/ca-bundle.crt',
            'target-dir' => '/etc/pki/tls/certs/ca-bundle.crt',
            'options'    => 'ro',
          },
          'manila-share-pki-ca-bundle-trust-crt' => {
            'source-dir' => '/etc/pki/tls/certs/ca-bundle.trust.crt',
            'target-dir' => '/etc/pki/tls/certs/ca-bundle.trust.crt',
            'options'    => 'ro',
          },
          'manila-share-pki-cert'                => {
            'source-dir' => '/etc/pki/tls/cert.pem',
            'target-dir' => '/etc/pki/tls/cert.pem',
            'options'    => 'ro',
          },
          'manila-share-var-log'                 => {
            'source-dir' => '/var/log/containers/manila',
            'target-dir' => '/var/log/manila',
            'options'    => 'rw,z',
          },
          'manila-share-ceph-cfg-dir'            => {
            'source-dir' => $ceph_conf_path,
            'target-dir' => '/etc/ceph',
            'options'    => 'ro',
          },
        }

        # if ceph-nfs backend is used, then DBus is used for dynamic
        # creation of NFS exports and DBus socket has to be mounted
        # both to manila-share and ganesha containers so they can talk
        # to each other
        if $ceph_nfs_enabled {
          $extra_storage_maps = {
            'manila-share-dbus-docker' => {
              'source-dir' => '/var/run/dbus/system_bus_socket',
              'target-dir' => '/var/run/dbus/system_bus_socket',
              'options'    => 'rw',
            },
            'manila-share-etc-ganesha' => {
              'source-dir' => '/etc/ganesha',
              'target-dir' => '/etc/ganesha',
              'options'    => 'rw',
            },
          }
        } else {
          $extra_storage_maps = {}
        }

        $storage_maps = merge($default_storage_maps, $extra_storage_maps)
      }

      if $docker_environment =~ Hash {
        $docker_env = join($docker_environment.map |$index, $value| { "-e ${index}=${value}" }, ' ')
      } else {
        $docker_env_arr = delete(any2array($docker_environment), '').flatten()
        $docker_env = join($docker_env_arr.map |$var| { "-e ${var}" }, ' ')
      }

      if $tls_priorities != undef {
        $tls_priorities_real = " -e PCMK_tls_priorities=${tls_priorities}"
      } else {
        $tls_priorities_real = ''
      }
      pacemaker::resource::bundle { $::manila::params::share_service:
        image             => $manila_share_docker_image,
        replicas          => 1,
        location_rule     => {
          resource_discovery => 'exclusive',
          score              => 0,
          expression         => ['manila-share-role eq true'],
        },
        container_options => 'network=host',
        # lint:ignore:140chars
        options           => "--ipc=host --privileged=true --user=${bundle_user} --log-driver=${log_driver}${log_file_real} ${docker_env}${tls_priorities_real}",
        # lint:endignore
        run_command       => '/bin/bash /usr/local/bin/kolla_start',
        storage_maps      => $storage_maps,
        container_backend => $container_backend,
      }

      if $ceph_nfs_enabled {
        pacemaker::constraint::order { 'ceph-nfs-then-manila-share':
          first_resource    => 'ceph-nfs',
          second_resource   => 'openstack-manila-share',
          first_action      => 'start',
          second_action     => 'start',
          constraint_params => 'kind=Optional',
          tries             => $pcs_tries,
          tag               => 'pacemaker_constraint',
        }

        pacemaker::constraint::colocation { 'openstack-manila-share-with-ceph-nfs':
          source => 'openstack-manila-share',
          target => 'ceph-nfs',
          score  => 'INFINITY',
          tries  => $pcs_tries,
          tag    => 'pacemaker_constraint',
        }

        Pacemaker::Resource::Bundle['openstack-manila-share']
          -> Pacemaker::Constraint::Colocation['openstack-manila-share-with-ceph-nfs']
            -> Pacemaker::Constraint::Order['ceph-nfs-then-manila-share']
      }
    }
  }
}