From ff3be522f475e110d67f453ae7b087b3518e3638 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Sat, 2 Apr 2016 09:02:39 +0200 Subject: [PATCH] #27 - check whether the configuration parameter is already applied before applying --- manifests/config/entry.pp | 9 +++++++++ spec/defines/composer_config_entry_spec.rb | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/manifests/config/entry.pp b/manifests/config/entry.pp index 229c0e1..b4f982d 100644 --- a/manifests/config/entry.pp +++ b/manifests/config/entry.pp @@ -38,10 +38,19 @@ default => "${cmd_template} --unset ${entry}" } + $unless = $ensure ? { + present => "/usr/bin/test `${cmd_template} ${entry}` = ${value}", + + # NOTE: in this case the parameter will be resetted to the default value so it cannot be checked properly + # when to execute the command to remove the command or not. + default => undef, + } + exec { "composer-config-entry-${entry}-${user}-${ensure}": command => $cmd, user => $user, require => Class['::composer'], environment => "HOME=${home_dir}", + unless => $unless } } diff --git a/spec/defines/composer_config_entry_spec.rb b/spec/defines/composer_config_entry_spec.rb index 052550c..a505078 100644 --- a/spec/defines/composer_config_entry_spec.rb +++ b/spec/defines/composer_config_entry_spec.rb @@ -15,7 +15,8 @@ it { should contain_exec('composer-config-entry-\'process-timeout\'-vagrant-present') \ .with_command('/usr/local/bin/composer config -g \'process-timeout\' 500') \ .with_user('vagrant') \ - .with_environment('HOME=/home/vagrant') + .with_environment('HOME=/home/vagrant') \ + .with_unless('/usr/bin/test `/usr/local/bin/composer config -g \'process-timeout\'` = 500') \ } end