7
8
9
10
11
12
13
14
15
16
17
18
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
|
# File 'lib/openstax/aws/build_image_command_1.rb', line 7
def initialize(ami_name_base:, region:,
verbose: false, debug: false,
github_org:, repo:, branch: nil, sha: nil,
deployment_sha: nil,
packer_absolute_file_path: , playbook_absolute_file_path:,
dry_run: true)
if sha.nil?
branch ||= 'master'
sha = OpenStax::Aws::GitHelper.sha_for_branch_name(
org_slash_repo: "#{github_org}/#{repo}",
branch: branch
)
end
ami_name = "#{ami_name_base}@#{sha[0..6]} #{Time.now.utc.strftime("%y%m%d%H%MZ")}"
@packer = OpenStax::Aws::PackerFactory.new_packer(
absolute_file_path: packer_absolute_file_path,
dry_run: dry_run
)
@packer.only("amazon-ebs")
@packer.var("region", region)
@packer.var("ami_name", ami_name)
@packer.var("sha", sha)
@packer.var("deployment_sha", deployment_sha) unless deployment_sha.nil?
@packer.var("playbook_file", playbook_absolute_file_path)
@packer.var("ami_description", {
sha: sha,
deployment_sha: deployment_sha,
github_org: github_org,
repo: repo
}.to_json)
@packer.verbose! if verbose
@packer.debug! if debug
end
|