From e015a1fdf731bb7ea169b553daae1eb80a5bb40f Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 8 Sep 2014 14:24:29 -0400 Subject: [PATCH] Lack of idempotency with `ensure => 'absent'` Need to add an unless to the exec in the case we have `ensure => 'absent'` for the concat, otherwise the exec (of true) runs every time. --- manifests/init.pp | 4 +++- spec/unit/defines/concat_spec.rb | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index a9fa86a..77f9d5f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -223,10 +223,12 @@ define concat( default => '/bin:/usr/bin', } + # Need to have an unless here for idempotency. exec { "concat_${name}": alias => "concat_${fragdir}", command => $absent_exec_command, - path => $absent_exec_path + unless => $absent_exec_command, + path => $absent_exec_path, } } } diff --git a/spec/unit/defines/concat_spec.rb b/spec/unit/defines/concat_spec.rb index 5dfdfd2..e7be4d5 100644 --- a/spec/unit/defines/concat_spec.rb +++ b/spec/unit/defines/concat_spec.rb @@ -144,6 +144,7 @@ describe 'concat', :type => :define do should contain_exec("concat_#{title}").with({ :alias => "concat_#{fragdir}", :command => 'true', + :unless => 'true', :path => '/bin:/usr/bin', }) end