Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(CISC-973) Handle vars in gcp provisioner #152

Merged
merged 3 commits into from
Jan 6, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
HelenCampbell marked this conversation as resolved.
Show resolved Hide resolved
end
end

Expand Down