Method: R10K::Puppetfile#add_module

Defined in:
lib/r10k/puppetfile.rb

#add_module(name, args) ⇒ Object

Parameters:

  • name (String)
  • args (*Object)


121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/r10k/puppetfile.rb', line 121

def add_module(name, args)
  if args.is_a?(Hash) && install_path = args.delete(:install_path)
    install_path = resolve_install_path(install_path)
    validate_install_path(install_path, name)
  else
    install_path = @moduledir
  end

  if args.is_a?(Hash) && @default_branch_override != nil
    args[:default_branch] = @default_branch_override
  end

  # Keep track of all the content this Puppetfile is managing to enable purging.
  @managed_content[install_path] = Array.new unless @managed_content.has_key?(install_path)

  mod = R10K::Module.new(name, install_path, args, @environment)
  mod.origin = 'Puppetfile'

  @managed_content[install_path] << mod.name
  @modules << mod
end