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

Seed Ansible Roles for Vmdb Plugins #17777

Merged
merged 6 commits into from
Aug 2, 2018
Merged
Changes from 3 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
35 changes: 35 additions & 0 deletions lib/tasks/evm_ansible_runner.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require 'awesome_spawn'
require "vmdb/plugins"

namespace :evm do
namespace :ansible_runner do
desc "Seed galaxy roles for provider playbooks"
task :seed do
plugins_with_req_yml = Vmdb::Plugins.select do |plugin|
req_yml_path = plugin.root.join('content_tmp', 'ansible', 'requirements.yml')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's encode this into VMDB::Plugins a la VMDB::Plugins::AnsibleContent

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 done

File.file?(req_yml_path)
end

plugins_with_req_yml.each do |plugin|
puts "Seeding roles for #{plugin.name}..."

roles_path = plugin.root.join('content_tmp', 'ansible', 'roles')
role_file = plugin.root.join('content_tmp', 'ansible', 'requirements.yml')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer 'content', 'ansible_tmp', .... content won't change, but the inner dir might.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


params = {
nil => "install",
:roles_path= => roles_path,
:role_file= => role_file
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can also be

params = ["install", :roles_path= => roles_path, :role_file= => role_file]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


begin
AwesomeSpawn.run!("ansible-galaxy", :params => params)
puts "Seeding roles for #{plugin.name}...Complete"
rescue AwesomeSpawn::CommandResultError => err
puts "Seeding roles for #{plugin.name}...Failed - #{err.result.error}"
raise
end
end
end
end
end