Module: Puppet::CloudPack::Installer
- Defined in:
- lib/puppet/cloudpack/installer.rb
Class Method Summary collapse
- .build_installer_template(name, options = {}) ⇒ Object
- .find_builtin_templates ⇒ Object
- .find_template(name) ⇒ Object
- .lib_script_dir ⇒ Object
Class Method Details
.build_installer_template(name, options = {}) ⇒ Object
8 9 10 11 |
# File 'lib/puppet/cloudpack/installer.rb', line 8 def build_installer_template(name, = {}) # binding is a kernel method ERB.new(File.read(find_template(name))).result(binding) end |
.find_builtin_templates ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/puppet/cloudpack/installer.rb', line 17 def find_builtin_templates templates_dir = lib_script_dir templates = [] Dir.open(templates_dir) do |dir| dir.each do |entry| next if File.directory?(File.join(templates_dir, entry)) if entry.length > '.erb'.length && entry.end_with?('.erb') templates << entry[0 .. -'.erb'.length-1] end end end templates end |
.find_template(name) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/puppet/cloudpack/installer.rb', line 31 def find_template(name) user_script = File.join(Puppet[:confdir], 'scripts', "#{name}.erb") return user_script if File.exists?(user_script) lib_script = File.join(lib_script_dir, "#{name}.erb") if File.exists?(lib_script) lib_script else raise ArgumentError, "Could not find installer script template for #{name}" end end |
.lib_script_dir ⇒ Object
13 14 15 |
# File 'lib/puppet/cloudpack/installer.rb', line 13 def lib_script_dir File.join(File.(File.dirname(__FILE__)), 'scripts') end |