Skip to content
This repository has been archived by the owner on Jan 4, 2021. It is now read-only.

Commit

Permalink
Merge pull request #520 from ripienaar/65
Browse files Browse the repository at this point in the history
(#65) when not given use the puppet basemodulepath to find playbooks
  • Loading branch information
ripienaar committed Jul 11, 2018
2 parents 1287434 + 6c31787 commit 78270c6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
6 changes: 1 addition & 5 deletions lib/mcollective/application/playbook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,11 @@ def pre_parse_find_playbook
# @param plan [String] the name of a plan
# @return [Util::BoltSupport::PlanRunner]
def runner(plan, loglevel=nil)
unless configuration[:__modulepath]
configuration[:__modulepath] = File.expand_path("~/.puppetlabs/etc/code/modules")
end

require "mcollective/util/bolt_support"
runner = Util::BoltSupport::PlanRunner.new(
plan,
configuration[:__tmpdir],
configuration[:__modulepath] || Dir.pwd,
configuration[:__modulepath],
configuration[:__loglevel] || "info"
)

Expand Down
18 changes: 15 additions & 3 deletions lib/mcollective/util/bolt_support/plan_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,25 @@ def self.init_puppet

# @param plan [String] the name of the plan to use
# @param tmpdir [String] the path to an already existing temporary directory
# @param modulepath [String] a : seperated list of locations to look for modules
# @param modulepath [String,nil] a : seperated list of locations to look for modules, uses puppet basemodulepath if nil
# @param loglevel [debug, info, warn, err]
def initialize(plan, tmpdir, modulepath, loglevel)
@plan = plan
@loglevel = loglevel
@modulepath = modulepath.split(":")
@tmpdir = tmpdir

raise("A temporary directory could not be created") unless @tmpdir
raise("A temporary directory could not be created") unless File.directory?(@tmpdir)

@modulepath = modulepath

unless @modulepath
initialize_settings
@modulepath = Puppet.settings[:basemodulepath]
end

@modulepath = @modulepath.split(":")

Puppet[:log_level] = @loglevel
end

Expand Down Expand Up @@ -85,9 +93,13 @@ def facts
}
end

def initialize_settings
Puppet.initialize_settings(puppet_cli_options) unless Puppet.settings.global_defaults_initialized?
end

# Sets up a temporary environment
def in_environment
Puppet.initialize_settings(puppet_cli_options) unless Puppet.settings.global_defaults_initialized?
initialize_settings

Puppet::Pal.in_tmp_environment("choria", :modulepath => @modulepath, :facts => facts) do |env|
yield(env)
Expand Down

0 comments on commit 78270c6

Please sign in to comment.