Skip to content

Commit

Permalink
CISC-973) Handle vars in gcp provisioner
Browse files Browse the repository at this point in the history
  • Loading branch information
Helen Campbell committed Jan 5, 2021
1 parent ede4ac7 commit 39664e7
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tasks/provision_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,20 @@ def provision(platform, inventory_location, vars)
params = platform_to_cloud_request_parameters(platform, cloud, region, zone)
response = invoke_cloud_request(params, uri, job_url, 'post')
response_hash = YAML.safe_load(response)

unless vars.nil?
var_hash = YAML.safe_load(vars)
response_hash['groups'].each do |bg|
bg['targets'].each do |trgt|
trgt['uri'].each do |ur|
ur['vars'] = var_hash
end
end
end
end

if File.file?(inventory_full_path)
inventory_hash = inventory_hash_from_inventory_file(inventory_full_path)

inventory_hash['groups'].each do |g|
response_hash['groups'].each do |bg|
if g['name'] == bg['name']
Expand All @@ -108,7 +119,7 @@ def provision(platform, inventory_location, vars)
File.open(inventory_full_path, 'w') { |f| f.write inventory_hash.to_yaml }
else
File.open('inventory.yaml', 'wb') do |f|
f.write(response)
f.write(response_hash)
end
end

Expand Down

0 comments on commit 39664e7

Please sign in to comment.