Class: Builderator::Interface::Packer
- Inherits:
-
Builderator::Interface
- Object
- Builderator::Interface
- Builderator::Interface::Packer
- Defined in:
- lib/builderator/interface/packer.rb
Overview
Generate packer.json
Instance Attribute Summary collapse
-
#packerfile ⇒ Object
readonly
Returns the value of attribute packerfile.
Instance Method Summary collapse
-
#initialize(*_) ⇒ Packer
constructor
A new instance of Packer.
- #render ⇒ Object
Methods inherited from Builderator::Interface
berkshelf, #bundled?, #clean, command, #directory, from_gem, packer, #source, template, vagrant, #which, #write
Constructor Details
#initialize(*_) ⇒ Packer
Returns a new instance of Packer.
19 20 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 54 55 56 57 58 59 60 61 62 |
# File 'lib/builderator/interface/packer.rb', line 19 def initialize(*_) super @packerfile ||= { :builders => [], :provisioners => [] }.tap do |json| Config.profile.current.packer.build.each do |_, build| build_hash = build.to_hash.tap do |b| b[:tags] = Config.profile.current. end # If we specify encrypted boot, packer won't allow ami_users. # See: https://github.com/MYOB-Technology/packer/blob/509cd7dcf194beb6ca6d0c39057f7490fa630d78/builder/amazon/common/ami_config.go#L59-L61 # A PR (https://github.com/mitchellh/packer/pull/4023) has been # submitted to resolve this issue but we shouldn't remove this # until a new Packer release with this feature. if build_hash.key?(:encrypt_boot) build_hash.delete(:ami_users) end ## Support is missing for several regions in some versions of Packer # Moving this functionality into a task until we can confirm that Packer # has full support again. build_hash.delete(:ami_regions) # This is not directly supported by Packer build_hash.delete(:tagging_role) json[:builders] << build_hash end ## Initialize the staging directory json[:provisioners] << { :type => 'shell', :inline => "sudo mkdir -p #{Config.chef.staging_directory}/cache && "\ "sudo chown $(whoami) -R #{Config.chef.staging_directory}" } end _artifact_provisioners _chef_provisioner end |
Instance Attribute Details
#packerfile ⇒ Object (readonly)
Returns the value of attribute packerfile.
17 18 19 |
# File 'lib/builderator/interface/packer.rb', line 17 def packerfile @packerfile end |
Instance Method Details
#render ⇒ Object
64 65 66 |
# File 'lib/builderator/interface/packer.rb', line 64 def render JSON.pretty_generate(packerfile) end |