Skip to content

Commit

Permalink
Added render-manifest command
Browse files Browse the repository at this point in the history
  • Loading branch information
vshatravenko committed Aug 27, 2017
1 parent 581d86a commit 5d6c6a1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
24 changes: 20 additions & 4 deletions lib/kite/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ def generate()

case options[:cloud]
when "aws"
copy_file("aws/bin/make_cloud_config.sh", "bin/make_cloud_config.sh")
copy_file("aws/bin/make_manifest_bosh-init.sh", "bin/make_manifest_bosh-init.sh")
copy_file("aws/bin/make_manifest_concourse-cluster.sh", "bin/make_manifest_concourse-cluster.sh")

copy_file("aws/terraform/aws-concourse.tf", "terraform/aws-concourse.tf")
copy_file("aws/terraform/aws-vault.tf", "terraform/aws-vault.tf")
copy_file("aws/terraform/bosh-aws-base.tf", "terraform/bosh-aws-base.tf")
Expand All @@ -52,5 +48,25 @@ def generate()

end
end

method_option :manifest, type: :string, desc: "Manifest type", enum: %w{bosh concourse}, required: true
desc "render-manifest", "Render manifest file from configuration and Terraform output"
def render_manifest
say "Rendering #{ options[:manifest] } manifest", :green
@values = YAML.load(File.read('config/cloud.yml'))
@tf_output = parse_tf_state('terraform/terraform.tfstate')

case options[:manifest]
when "bosh"
template("aws/bosh/bosh_director.yml.erb", "bosh_director.yml")

when "concourse"
template("aws/concourse/aws_cloud.yml.erb", "aws_cloud.yml")
template("aws/concourse/concourse.yml.erb", "concourse.yml")
else
say "Manifest type not specified"

end
end
end
end
7 changes: 7 additions & 0 deletions lib/kite/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
module Kite::Helpers
# Parse Terraform .tfstate file, returning the output hash
def parse_tf_state(path)
tf_state = YAML.load(File.open(path))
tf_output = tf_state["modules"].first["outputs"]
tf_output.map { |k, v| tf_output[k] = v["value"] }
tf_output
end
end

0 comments on commit 5d6c6a1

Please sign in to comment.