-
Notifications
You must be signed in to change notification settings - Fork 898
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
Seed Ansible Roles for Vmdb Plugins #17777
Conversation
24b9870
to
3342869
Compare
cc @gtanzillo @Ladas |
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.
Should be good 👍
We should probably extract the path to ansible to core, if this script expects it in some location, right?
And rename the content_tmp :-)
Yeah I was trying to think of a good place to put this constant since eventually it'll be shared by both |
3342869
to
7f00d5a
Compare
Allow plugins to add a requirements.yml file to specify roles from galaxy/github/etc... and seed them locally.
91abf5c
to
8536545
Compare
8536545
to
636e0a6
Compare
Okay @gtanzillo @Fryguy this is ready to review |
lib/tasks/evm_ansible_runner.rake
Outdated
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') |
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.
Let's encode this into VMDB::Plugins
a la VMDB::Plugins::AnsibleContent
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.
👍 done
lib/tasks/evm_ansible_runner.rake
Outdated
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') |
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.
Would prefer 'content', 'ansible_tmp', ...
. content
won't change, but the inner dir might.
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.
Done
lib/tasks/evm_ansible_runner.rake
Outdated
nil => "install", | ||
:roles_path= => roles_path, | ||
:role_file= => role_file | ||
} |
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.
This can also be
params = ["install", :roles_path= => roles_path, :role_file= => role_file]
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.
Done
5d79d37
to
71e06cb
Compare
71e06cb
to
383a039
Compare
9668a36
to
1e76650
Compare
Some comments on commits agrare/manageiq@d2b0a70~...1e76650 lib/tasks/evm_ansible_runner.rake
|
Checked commits agrare/manageiq@d2b0a70~...1e76650 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
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.
Looks good 👍
@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 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.
content_dir = engine.root.join("content", "ansible_tmp") | ||
next unless File.exist?(content_dir.join("requirements.yml")) | ||
|
||
[engine, content_dir] |
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.
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.
@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 comment
The reason will be displayed to describe this comment to others. Learn more.
Can we reuse the EDIT: nvm...content_directories assumes there are multiple things inside, which in this case isn't true.content_directories
method?
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.
content_directories
would do content/ansible_tmp/*
which would return every file and dir in that directory. For the purpose of seeding we only care about the role_file. We could change content_directories
to take the last component as an arg and default to *
but we could override with .e.g. requirements.yml
Ah didn't see your edit
Allow plugins to add a requirements.yml file to specify roles from
galaxy/github/etc... and seed them locally.
If I have an example requirements.yml:
And I seed the roles
And an example failure: