diff --git a/README.md b/README.md index 718955d..7420158 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ Using class { '::phantomjs': package_version => '1.9.7', - package_update => true, install_dir => '/usr/local/bin', source_dir => '/opt', timeout => 300 diff --git a/manifests/init.pp b/manifests/init.pp index 8b1c029..be57d15 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -4,7 +4,6 @@ $source_url = undef, $source_dir = '/opt', $install_dir = '/usr/local/bin', - $package_update = false, $timeout = 300 ) { @@ -56,6 +55,14 @@ default => $source_url, } + exec { 'remove phantomjs': + command => "/bin/rm -rf ${source_dir}/phantomjs", + onlyif => [ + "/usr/bin/test $(${install_dir}/phantomjs --version) != '${package_version}'", + "/usr/bin/test -d ${source_dir}/phantomjs" + ] + } + exec { 'get phantomjs': command => "/usr/bin/curl --silent --show-error --fail --location ${pkg_src_url} --output ${source_dir}/phantomjs.tar.bz2 \ && mkdir ${source_dir}/phantomjs \ @@ -65,16 +72,12 @@ timeout => $timeout } + Exec['remove phantomjs'] ~> Exec[ 'get phantomjs' ] + file { "${install_dir}/phantomjs": ensure => link, target => "${source_dir}/phantomjs/bin/phantomjs", force => true, } - if $package_update { - exec { 'remove phantomjs': - command => "/bin/rm -rf ${source_dir}/phantomjs", - notify => Exec[ 'get phantomjs' ] - } - } }