Class: CemAcpt::Bootstrap::Bootstrapper
- Inherits:
-
Object
- Object
- CemAcpt::Bootstrap::Bootstrapper
- Includes:
- OperatingSystem
- Defined in:
- lib/cem_acpt/bootstrap/bootstrapper.rb
Overview
This class runs bootstrapping commands on the VM after it is provisioned. This can include installing repos, installing Puppet, installing other programs, starting services, and running other commands.
Constant Summary collapse
- STATE_ORDER =
[:repo, :package, :service, :command, :complete].freeze
- STATE_ACTIONS =
{ repo: :run_repo_installs, package: :run_package_installs, service: :run_service_starts, command: :run_commands, }.freeze
- UNIVERSAL_DEPS =
[ 'git', 'curl', 'puppet-agent', ].freeze
Instance Method Summary collapse
- #commands ⇒ Object
-
#initialize(instance_name, instance_image, cmd, collection: 'puppet7', repos: [], packages: [], services: [], commands: []) ⇒ Bootstrapper
constructor
A new instance of Bootstrapper.
- #instance_available? ⇒ Boolean
- #packages ⇒ Object
- #repos ⇒ Object
- #ruby_version ⇒ Object
- #run ⇒ Object
- #services ⇒ Object
Methods included from OperatingSystem
Constructor Details
#initialize(instance_name, instance_image, cmd, collection: 'puppet7', repos: [], packages: [], services: [], commands: []) ⇒ Bootstrapper
Returns a new instance of Bootstrapper.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/cem_acpt/bootstrap/bootstrapper.rb', line 26 def initialize(instance_name, instance_image, cmd, collection: 'puppet7', repos: [], packages: [], services: [], commands: []) os, major_version = instance_image.split('-') use_os(os) @instance_name = instance_name.split('.').first @cmd_provider = cmd @collection = collection @os = os @major_version = major_version @repos = repos @packages = packages @services = services @commands = commands @logfile = '/var/log/bootstrap.log' @state = 0 @retries = 0 @results = {} end |
Instance Method Details
#commands ⇒ Object
63 64 65 |
# File 'lib/cem_acpt/bootstrap/bootstrapper.rb', line 63 def commands @commands + ruby_install_commands end |
#instance_available? ⇒ Boolean
67 68 69 |
# File 'lib/cem_acpt/bootstrap/bootstrapper.rb', line 67 def instance_available? @instance_available ||= test_connection end |
#packages ⇒ Object
55 56 57 |
# File 'lib/cem_acpt/bootstrap/bootstrapper.rb', line 55 def packages (@packages + UNIVERSAL_DEPS).uniq end |
#repos ⇒ Object
51 52 53 |
# File 'lib/cem_acpt/bootstrap/bootstrapper.rb', line 51 def repos @repos.push(puppet_agent_repo).uniq end |
#ruby_version ⇒ Object
44 45 46 47 48 49 |
# File 'lib/cem_acpt/bootstrap/bootstrapper.rb', line 44 def ruby_version return @ruby_version if defined?(@ruby_version) @ruby_version = determine_ruby_version(@collection) @ruby_version end |
#run ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/cem_acpt/bootstrap/bootstrapper.rb', line 71 def run raise 'Instance is not available' unless instance_available? @results = {} transition_state @results rescue StandardError => e return_results_with_error(e) end |
#services ⇒ Object
59 60 61 |
# File 'lib/cem_acpt/bootstrap/bootstrapper.rb', line 59 def services @services.uniq end |