-
Notifications
You must be signed in to change notification settings - Fork 55
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
(feat) provisioning lists of images from a file #78
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,28 @@ def run_local_command(command) | |
end | ||
end | ||
|
||
desc "provision list of machines from provision.yaml file. 'bundle exec rake 'litmus:provision_list[default]'" | ||
task :provision_list, [:key] do |_task, args| | ||
provision_hash = YAML.load_file('./provision.yaml') | ||
provisioner = provision_hash[args[:key]]['provisioner'] | ||
provision_hash[args[:key]]['images'].each do |image| | ||
include PuppetLitmus | ||
Rake::Task['spec_prep'].invoke | ||
config_data = { 'modulepath' => File.join(Dir.pwd, 'spec', 'fixtures', 'modules') } | ||
raise "the provision module was not found in #{config_data['modulepath']}, please amend the .fixtures.yml file" unless File.directory?(File.join(config_data['modulepath'], 'provision')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is repeated in various tasks. It'd be good to at least add a helper for this. |
||
|
||
params = { 'action' => 'provision', 'platform' => image, 'inventory' => Dir.pwd } | ||
results = run_task("provision::#{provisioner}", 'localhost', params, config: config_data, inventory: nil) | ||
results.each do |result| | ||
if result['status'] != 'success' | ||
puts "Failed on #{result['node']}\n#{result}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be on stderr? |
||
else | ||
puts "Provisioned #{result['result']['node_name']}" | ||
end | ||
end | ||
end | ||
end | ||
|
||
desc "provision container/VM - abs/docker/vmpooler eg 'bundle exec rake 'litmus:provision[vmpooler, ubuntu-1604-x86_64]'" | ||
task :provision, [:provisioner, :platform] do |_task, args| | ||
include PuppetLitmus | ||
|
@@ -173,15 +195,12 @@ def run_local_command(command) | |
run_local_command("bundle exec bolt file upload #{module_tar} /tmp/#{File.basename(module_tar)} --nodes #{target_string} --inventoryfile inventory.yaml") | ||
install_module_command = "puppet module install /tmp/#{File.basename(module_tar)}" | ||
result = run_command(install_module_command, target_nodes, config: nil, inventory: inventory_hash) | ||
# rubocop:disable Style/GuardClause | ||
if result.is_a?(Array) | ||
result.each do |node| | ||
puts "#{node['node']} failed #{node['result']}" if node['status'] != 'success' | ||
end | ||
else | ||
raise "Failed trying to run '#{install_module_command}' against inventory." | ||
raise "Failed trying to run '#{install_module_command}' against inventory." unless result.is_a?(Array) | ||
|
||
result.each do |node| | ||
puts "#{node['node']} failed #{node['result']}" if node['status'] != 'success' | ||
end | ||
# rubocop:enable Style/GuardClause | ||
|
||
puts 'Installed' | ||
end | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some bikeshedding: perhaps
litmus.yaml
? Also feels like this should be configurable - perhaps an env var with a default?