Class: PEBuild::Provisioner::PEBootstrap::PostInstall Private

Inherits:
Object
  • Object
show all
Includes:
OnMachine
Defined in:
lib/pe_build/provisioner/pe_bootstrap/post_install.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A sub-provisioner which applies post-install configuration.

This is an internal provisioner which is invoked by PEBuild::Provisioner::PEBootstrap.

Instance Method Summary collapse

Methods included from OnMachine

#on_machine

Constructor Details

#initialize(machine, config, work_dir) ⇒ PostInstall

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of PostInstall.



12
13
14
15
16
17
# File 'lib/pe_build/provisioner/pe_bootstrap/post_install.rb', line 12

def initialize(machine, config, work_dir)
  @machine, @config = machine, config

  @post_install_dir = Pathname.new(File.join(work_dir, 'post-install'))
  @post_install_manifest = @post_install_dir.join("#{@machine.name}.pp")
end

Instance Method Details

#runObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/pe_build/provisioner/pe_bootstrap/post_install.rb', line 21

def run
  if needs_post_install?
    @machine.ui.info I18n.t('pebuild.provisioner.pe_bootstrap.post_install')

    resources = []

    if PEBuild::Util::VersionString.compare(@config.version, '3.7.0') < 0 then
      resources << gen_httpd
    else
      resources << gen_puppetserver
    end
    resources << gen_relocate if @config.relocate_manifests
    resources << gen_autosign if @config.autosign

    manifest = resources.join("\n\n")
    write_manifest(manifest)

    if PEBuild::Util::VersionString.compare(@config.version, '2015.2.0') < 0 then
      puppet_apply  = "/opt/puppet/bin/puppet apply"
    else
      puppet_apply  = "/opt/puppetlabs/bin/puppet apply"
    end

    if @config.shared_installer
      manifest_path = "/vagrant/.pe_build/post-install/#{@machine.name}.pp"
    else
      @machine.communicate.upload(@post_install_manifest, "#{@machine.name}.pp")
      manifest_path = "#{@machine.name}.pp"
    end

    on_machine(@machine, "#{puppet_apply} #{manifest_path}")
  end
end