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 all commits
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
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