Skip to content

Commit

Permalink
Merge pull request #152 from HelenCampbell/CISC-973
Browse files Browse the repository at this point in the history
(CISC-973) Handle vars in gcp provisioner
  • Loading branch information
DavidS authored Jan 6, 2021
2 parents ede4ac7 + 6cc8ca8 commit 166bf4a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tasks/provision_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,18 @@ 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 |trgts|
trgts['vars'] = var_hash
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 +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(YAML.dump(response_hash))
end
end

Expand Down

0 comments on commit 166bf4a

Please sign in to comment.