-
Notifications
You must be signed in to change notification settings - Fork 897
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
Changes from all commits
d2b0a70
636e0a6
8215e52
4323a4f
383a039
1e76650
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require 'awesome_spawn' | ||
require "vmdb/plugins" | ||
|
||
namespace :evm do | ||
namespace :ansible_runner do | ||
desc "Seed galaxy roles for provider playbooks" | ||
task :seed do | ||
Vmdb::Plugins.ansible_runner_content.each do |plugin, content_dir| | ||
puts "Seeding roles for #{plugin.name}..." | ||
|
||
roles_path = content_dir.join('roles') | ||
role_file = content_dir.join('requirements.yml') | ||
|
||
params = ["install", :roles_path= => roles_path, :role_file= => role_file] | ||
|
||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,17 @@ def ansible_content | |
end | ||
end | ||
|
||
def ansible_runner_content | ||
@ansible_runner_content ||= begin | ||
map do |engine| | ||
content_dir = engine.root.join("content", "ansible_tmp") | ||
next unless File.exist?(content_dir.join("requirements.yml")) | ||
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.
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.
Ah didn't see your edit |
||
|
||
[engine, content_dir] | ||
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. Would prefer if this returned a Hash like some of the other ones here. Either that or create the wrapper struct like AutomateDomain or AnsibleContent. |
||
end.compact | ||
end | ||
end | ||
|
||
def automate_domains | ||
@automate_domains ||= begin | ||
require_relative 'plugins/automate_domain' | ||
|
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.
My only concern here is that this enforces a requirements.yml. Is that ok? If it's only to be used for the purpose of galaxy stuff, then maybe we just need to rename the method, or return both things that have non-galaxy and galaxy content, if that makes sense.
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.
requirements.yml came from the galaxy docs https://docs.ansible.com/ansible/latest/reference_appendices/galaxy.html#installing-multiple-roles-from-a-file but you can use that file to seed roles from more than just galaxy. You can also include other files from within this file. I don't think you can specify multiple role files, we would have to run ansible-galaxy for each
*.yml
file if we wanted to do that.