Class: InfraTestingHelpers::Box
- Inherits:
-
Object
- Object
- InfraTestingHelpers::Box
- Defined in:
- lib/infra_testing_helpers/box.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #applied? ⇒ Boolean
- #apply(manifest) ⇒ Object
-
#initialize(name) ⇒ Box
constructor
A new instance of Box.
- #run_command(command, opts = {}) ⇒ Object
Constructor Details
#initialize(name) ⇒ Box
Returns a new instance of Box.
4 5 6 7 |
# File 'lib/infra_testing_helpers/box.rb', line 4 def initialize(name) @name = name @applied = false end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/infra_testing_helpers/box.rb', line 9 def name @name end |
Instance Method Details
#applied? ⇒ Boolean
19 20 21 |
# File 'lib/infra_testing_helpers/box.rb', line 19 def applied? @applied end |
#apply(manifest) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/infra_testing_helpers/box.rb', line 11 def apply(manifest) manifest.manifest_file do |file| exit_code = run_command("sudo puppet apply --detailed-exitcode --modulepath #{manifest.module_path} #{file}") raise PuppetApplyFailed unless exit_code == 0 or exit_code == 2 @applied = true end end |
#run_command(command, opts = {}) ⇒ Object
24 25 26 27 28 |
# File 'lib/infra_testing_helpers/box.rb', line 24 def run_command(command, opts = {}) stdin = opts[:stdin] ? " << EOF\n#{opts[:stdin]}\nEOF" : "" system "vagrant ssh #{@name} --command \"#{command}\"#{stdin}" $?.exitstatus end |