diff --git a/build/rubygem-simp-cli.spec b/build/rubygem-simp-cli.spec index 7f53350d..82f8b65f 100644 --- a/build/rubygem-simp-cli.spec +++ b/build/rubygem-simp-cli.spec @@ -129,7 +129,9 @@ EOM %doc %{gemdir}/doc %changelog -* Wed Jun 22 2020 Trevor Vaughan - 6.0.0 +* Thu Aug 13 2020 Trevor Vaughan - 6.0.0 +- Allow users to set the SIMP_ENVIRONMENT environment variable to change the + initial environment from 'production' to a custom value - Fixed an issue where --dry-run would prompt the user to apply instead of simply skipping to the (skipped) action items and then writing the ~/.simp/simp_conf.yaml file diff --git a/lib/simp/cli/commands/bootstrap.rb b/lib/simp/cli/commands/bootstrap.rb index c72864aa..041e40ff 100755 --- a/lib/simp/cli/commands/bootstrap.rb +++ b/lib/simp/cli/commands/bootstrap.rb @@ -56,6 +56,7 @@ def run(args) pupcmd = "puppet agent --onetime --no-daemonize --no-show_diff --verbose" + " --no-splay --agent_disabled_lockfile=#{agent_lockfile}" + + " --environment=#{Simp::Cli::BOOTSTRAP_PUPPET_ENV}" + " --masterport=#{@initial_puppetserver_port} --ca_port=#{@initial_puppetserver_port}" num_tagged_runs = 3 @@ -89,6 +90,7 @@ def run(args) num_runs = 4 info("Running puppet agent without tags #{num_runs} times...", 'cyan') pupcmd = 'puppet agent --onetime --no-daemonize --no-show_diff --verbose --no-splay' + + " --environment=#{Simp::Cli::BOOTSTRAP_PUPPET_ENV}" + " --agent_disabled_lockfile=#{agent_lockfile}" # This is ugly, but until we devise an intelligent way to determine when your system # is 'bootstrapped', we're going to run puppet in a loop. diff --git a/lib/simp/cli/defaults.rb b/lib/simp/cli/defaults.rb index b922c190..31b55c11 100644 --- a/lib/simp/cli/defaults.rb +++ b/lib/simp/cli/defaults.rb @@ -7,7 +7,7 @@ class Simp::Cli # Git to access SIMP asset files, such as those for the # simp-environment-skeleton. SIMP_CLI_HOME = "#{ENV['HOME']}/.simp" - BOOTSTRAP_PUPPET_ENV = 'production' + BOOTSTRAP_PUPPET_ENV = ENV.fetch('SIMP_ENVIRONMENT', 'production') BOOTSTRAP_START_LOCK_FILE = File.join(SIMP_CLI_HOME, 'simp_bootstrap_start_lock') CONFIG_ANSWERS_OUTFILE = File.join(SIMP_CLI_HOME, 'simp_conf.yaml') CONFIG_GLOBAL_HIERA_FILENAME = 'simp_config_settings.yaml'