From 8dc420f3114586086822a4cca75b313e7fbbb31d Mon Sep 17 00:00:00 2001 From: Spencer Krum Date: Mon, 14 Apr 2014 20:12:43 -0700 Subject: [PATCH] Make storyboard idempotent Previously the curl command was itself idempotent but this was transparent to Puppet, meaning the node reported as always changed. I have, somewhat akwardly, taught Puppet how to check for changed files on the remote server. It pulls only HTTP headers to save time/bandwidth. Change-Id: I539e67f0c82ad91450dd3720512b92518e70c122 --- modules/storyboard/manifests/init.pp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/storyboard/manifests/init.pp b/modules/storyboard/manifests/init.pp index 97f71f0b6d..ca0a482860 100644 --- a/modules/storyboard/manifests/init.pp +++ b/modules/storyboard/manifests/init.pp @@ -142,11 +142,12 @@ class storyboard ( group => 'storyboard', } - # Using -z here to only download when the tarball has changed. + # Checking last modified time versus mtime on the file exec { 'get-webclient': command => "curl ${storyboard_webclient_url} -z ./${tarball} -o ${tarball}", path => '/bin:/usr/bin', cwd => '/var/lib/storyboard', + onlyif => "curl -I ${storyboard_webclient_url} -z ./${tarball} | grep '200 OK'", require => [ File['/var/lib/storyboard'], Package['curl'], @@ -154,10 +155,11 @@ class storyboard ( } exec { 'unpack-webclient': - command => "tar -xzf ${tarball}", - path => '/bin:/usr/bin', - cwd => '/var/lib/storyboard', - require => Exec['get-webclient'], + command => "tar -xzf ${tarball}", + path => '/bin:/usr/bin', + cwd => '/var/lib/storyboard', + refreshonly => true, + subscribe => Exec['get-webclient'], } file { '/var/lib/storyboard/www':