From 2804934ecba7dfd52a222765174ad1c3018bab5f Mon Sep 17 00:00:00 2001 From: James Shubin Date: Fri, 7 Mar 2014 16:44:58 -0500 Subject: Add in a custom sponge utility to break the dependence on the EPEL repo. --- files/sponge.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ manifests/server.pp | 14 +++++++++++++- manifests/volume.pp | 4 ++-- 3 files changed, 59 insertions(+), 3 deletions(-) create mode 100755 files/sponge.py diff --git a/files/sponge.py b/files/sponge.py new file mode 100755 index 0000000..3ed44db --- /dev/null +++ b/files/sponge.py @@ -0,0 +1,44 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright (C) 2012-2013+ James Shubin +# Written by James Shubin +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +# This is meant to be a replacement for the excellent 'sponge' utility from the +# 'moreutils' package by Joey Hess. It doesn't do exactly what sponge does, but +# it does to the extent of what is used here for this Puppet-Gluster module. It +# is useful for environments that do not have the sponge package in their repo. + +import sys + +x = sys.stdin.readlines() +# TODO: can we be certain to sync here, and that the compiler doesn't optimize? + +if len(sys.argv) == 1: + # stdout + # TODO: untested + for l in x: sys.stdout.write(l) + sys.stdout.flush() + +elif len(sys.argv) == 2: + # file + f = open(sys.argv[1], 'w') + for l in x: f.write(l) + f.close() + +else: + sys.exit(1) + +# vim: ts=8 diff --git a/manifests/server.pp b/manifests/server.pp index 6f4d5c9..e4e40e8 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -31,6 +31,11 @@ class gluster::server( ) { $FW = '$FW' # make using $FW in shorewall easier + include gluster::vardir + + #$vardir = $::gluster::vardir::module_vardir # with trailing slash + $vardir = regsubst($::gluster::vardir::module_vardir, '\/$', '') + # if we use ::mount and ::server on the same machine, this could clash, # so we use the ensure_resource function to allow identical duplicates! $rname = "${version}" ? { @@ -44,9 +49,16 @@ class gluster::server( ensure_resource('gluster::repo', "${rname}", $params) } - package { 'moreutils': # for scripts needing: 'sponge' + # this is meant to be replace the excellent sponge utility by sponge.py + file { "${vardir}/sponge.py": # for scripts needing: 'sponge' + source => 'puppet:///modules/gluster/sponge.py', + owner => root, + group => nobody, + mode => 700, # u=rwx + backup => false, # don't backup to filebucket ensure => present, before => Package['glusterfs-server'], + require => File["${vardir}/"], } package { 'glusterfs-server': diff --git a/manifests/volume.pp b/manifests/volume.pp index 513a431..645c090 100644 --- a/manifests/volume.pp +++ b/manifests/volume.pp @@ -363,12 +363,12 @@ define gluster::volume( $stack_truncate = "${maxlength}" ? { '-1' => '', # unlimited #default => sprintf("&& /bin/sed -i '%d,$ d' ${stackfile}", inline_template('<%= @maxlength.to_i.abs+1 %>')), - default => sprintf(" && (/bin/grep -v '^$' ${stackfile} | /usr/bin/tail -n %d | /usr/bin/sponge ${stackfile})", inline_template('<%= @maxlength.to_i.abs %>')), + default => sprintf(" && (/bin/grep -v '^$' ${stackfile} | /usr/bin/tail -n %d | ${vardir}/sponge.py ${stackfile})", inline_template('<%= @maxlength.to_i.abs %>')), } $watch_truncate = "${maxlength}" ? { '-1' => '', # unlimited #default => sprintf("&& /bin/sed -i '%d,$ d' ${watchfile}", inline_template('<%= @maxlength.to_i.abs+1 %>')), - default => sprintf(" && (/bin/grep -v '^$' ${watchfile} | /usr/bin/tail -n %d | /usr/bin/sponge ${watchfile})", inline_template('<%= @maxlength.to_i.abs %>')), + default => sprintf(" && (/bin/grep -v '^$' ${watchfile} | /usr/bin/tail -n %d | ${vardir}/sponge.py ${watchfile})", inline_template('<%= @maxlength.to_i.abs %>')), } if $are_bricks_collected and ("${valid_input}" != '') { # ready or not? -- cgit