aboutsummaryrefslogtreecommitdiffstats
path: root/manifests
diff options
context:
space:
mode:
authorJiri Stransky <jistr@redhat.com>2016-10-20 19:26:16 +0200
committerJiri Stransky <jistr@redhat.com>2016-10-21 17:41:03 +0200
commitad4e331917a2da9f2fd8215369736896348244fd (patch)
tree3b64a8dbd7ed55ebb8ae68d0b553b94f3b42c542 /manifests
parente76a15ad54b79d3be7406d25199dc3a16ec5ca01 (diff)
NFS mounting for Glance file backend
Previously we did this with Pacemaker, but with move to NG HA architecture we lost the ability to use NFS mounts as image storage for Glance. This reimplements the mounting without utilizing Pacemaker. The mount is by default also written to /etc/fstab so that it persists over reboot, but this behavior can be disabled. This could also go to puppet-glance eventually, but not yet -- we need this backported to Newton because it's a TripleO regression. I don't think puppet-glance would allow backporting this to Newton, because from their point of view it would be a RFE rather than a regression. Change-Id: I45ad34c36587a8d695069368cf791f1efb68256c Related-Bug: #1635606
Diffstat (limited to 'manifests')
-rw-r--r--manifests/glance/nfs_mount.pp80
-rw-r--r--manifests/profile/base/glance/api.pp17
2 files changed, 93 insertions, 4 deletions
diff --git a/manifests/glance/nfs_mount.pp b/manifests/glance/nfs_mount.pp
new file mode 100644
index 0000000..035191d
--- /dev/null
+++ b/manifests/glance/nfs_mount.pp
@@ -0,0 +1,80 @@
+# Copyright 2016 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::glance::nfs_mount
+#
+# NFS mount for Glance image storage file backend
+#
+# === Parameters
+#
+# [*share*]
+# NFS share to mount, in 'IP:PATH' format.
+#
+# [*options*]
+# (Optional) NFS mount options. Defaults to
+# 'intr,context=system_u:object_r:glance_var_lib_t:s0'
+#
+# [*edit_fstab*]
+# (Optional) Whether to persist the mount info to fstab.
+# Defaults to true.
+#
+# [*fstab_fstype*]
+# (Optional) File system type to use in fstab for the mount.
+# Defaults to 'nfs4'.
+#
+# [*fstab_prepend_options*]
+# (Optional) Extra mount options for fstab (prepended to $options).
+# Defaults to 'bg', so that a potentially failed mount doesn't
+# prevent the machine from booting.
+#
+class tripleo::glance::nfs_mount (
+ $share,
+ $options = 'intr,context=system_u:object_r:glance_var_lib_t:s0',
+ $edit_fstab = true,
+ $fstab_fstype = 'nfs4',
+ $fstab_prepend_options = 'bg'
+) {
+
+ $images_dir = '/var/lib/glance/images'
+
+ if $options and $options != '' {
+ $options_part = "-o ${options}"
+ } else {
+ $options_part = ''
+ }
+
+ if $fstab_prepend_options and $fstab_prepend_options != '' {
+ $fstab_prepend_part = "${fstab_prepend_options},"
+ } else {
+ $fstab_prepend_part = ''
+ }
+
+ file { $images_dir:
+ ensure => directory,
+ } ->
+ exec { 'NFS mount for glance file backend':
+ path => ['/usr/sbin', '/usr/bin'],
+ command => "mount -t nfs '${share}' '${images_dir}' ${options_part}",
+ unless => "mount | grep ' ${images_dir} '",
+ }
+
+ if $edit_fstab {
+ file_line { 'NFS for glance in fstab':
+ ensure => present,
+ line => "${share} ${images_dir} ${fstab_fstype} ${fstab_prepend_part}${options} 0 0",
+ match => " ${images_dir} ",
+ path => '/etc/fstab',
+ }
+ }
+}
diff --git a/manifests/profile/base/glance/api.pp b/manifests/profile/base/glance/api.pp
index f3db396..a7d4487 100644
--- a/manifests/profile/base/glance/api.pp
+++ b/manifests/profile/base/glance/api.pp
@@ -22,6 +22,10 @@
# (Optional) Glance backend(s) to use.
# Defaults to downcase(hiera('glance_backend', 'swift'))
#
+# [*glance_nfs_enabled*]
+# (Optional) Whether to use NFS mount as 'file' backend storage location.
+# Defaults to false
+#
# [*step*]
# (Optional) The current step in deployment. See tripleo-heat-templates
# for more details.
@@ -36,12 +40,17 @@
# Defaults to hiera('glance::notify::rabbitmq::rabbit_port', 5672)
class tripleo::profile::base::glance::api (
- $glance_backend = downcase(hiera('glance_backend', 'swift')),
- $step = hiera('step'),
- $rabbit_hosts = hiera('rabbitmq_node_ips', undef),
- $rabbit_port = hiera('glance::notify::rabbitmq::rabbit_port', 5672),
+ $glance_backend = downcase(hiera('glance_backend', 'swift')),
+ $glance_nfs_enabled = false,
+ $step = hiera('step'),
+ $rabbit_hosts = hiera('rabbitmq_node_ips', undef),
+ $rabbit_port = hiera('glance::notify::rabbitmq::rabbit_port', 5672),
) {
+ if $step >= 1 and $glance_nfs_enabled {
+ include ::tripleo::glance::nfs_mount
+ }
+
if $step >= 4 {
case $glance_backend {
'swift': { $backend_store = 'glance.store.swift.Store' }