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 4, 2021
1 parent ede4ac7 commit ca5e9c3
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tasks/provision_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,20 @@ def provision(platform, inventory_location, vars)
job_url = data['job_url']
end
inventory_full_path = File.join(inventory_location, 'inventory.yaml')

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)
if File.file?(inventory_full_path)
unless vars.nil?
var_hash = YAML.safe_load(vars)
response_hash['groups'].each do |bg|
bg['targets'].each do |trgt|
bg['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|
Expand All @@ -108,7 +117,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 ca5e9c3

Please sign in to comment.