diff --git a/doc/advanced-script-override.md b/doc/advanced-script-override.md index 7b3b4d4..d51b5e1 100644 --- a/doc/advanced-script-override.md +++ b/doc/advanced-script-override.md @@ -48,8 +48,4 @@ This is an explanation of the [existing scripts supplied by octocatalog-diff](/s - [`puppet.sh`](/scripts/puppet) - Runs puppet (with additional command line arguments), generally used to compile a catalog. - -- [`puppet-version.sh`](/scripts/puppet-version) - - Runs `puppet --version` to determine the version of Puppet being used. + Runs puppet (with additional command line arguments), generally used to compile a catalog or determine the Puppet version. diff --git a/lib/octocatalog-diff/util/puppetversion.rb b/lib/octocatalog-diff/util/puppetversion.rb index ab6a341..06fbd3e 100644 --- a/lib/octocatalog-diff/util/puppetversion.rb +++ b/lib/octocatalog-diff/util/puppetversion.rb @@ -18,9 +18,11 @@ module OctocatalogDiff raise ArgumentError, 'Puppet binary was not supplied' if puppet.nil? raise Errno::ENOENT, "Puppet binary #{puppet} doesn't exist" unless File.file?(puppet) + logger = options[:logger] || Logger.new(StringIO.new) + sr_opts = { - logger: Logger.new(StringIO.new), - default_script: 'puppet-version/puppet-version.sh', + logger: logger, + default_script: 'puppet/puppet.sh', override_script_path: options[:override_script_path] } @@ -29,6 +31,7 @@ module OctocatalogDiff sr_run_opts = { :working_dir => File.dirname(puppet), :pass_env_vars => options[:pass_env_vars], + :argv => '--version', 'OCD_PUPPET_BINARY' => puppet } diff --git a/scripts/puppet-version/puppet-version.sh b/scripts/puppet-version/puppet-version.sh deleted file mode 100644 index cb97241..0000000 --- a/scripts/puppet-version/puppet-version.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -# Script to determine the Puppet version. - -if [ -z "$OCD_PUPPET_BINARY" ]; then - echo "Error: PUPPET_BINARY must be set" - exit 255 -fi - -"$OCD_PUPPET_BINARY" --version diff --git a/scripts/puppet/puppet.sh b/scripts/puppet/puppet.sh new file mode 100644 index 0000000..0a2b6a7 --- /dev/null +++ b/scripts/puppet/puppet.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Script to run Puppet. The default implementation here is simply to pass +# through the command line arguments (which are likely to be numerous when +# compiling a catalog). + +if [ -z "$OCD_PUPPET_BINARY" ]; then + echo "Error: PUPPET_BINARY must be set" + exit 255 +fi + +"$OCD_PUPPET_BINARY" "$@"