-
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
Run a control action to order Ansible Playbook Service #13874
Conversation
app/models/miq_action.rb
Outdated
@@ -20,6 +20,7 @@ class MiqAction < ApplicationRecord | |||
"set_custom_attribute" => "Set a Custom Attribute in vCenter", | |||
"inherit_parent_tags" => "Inherit Parent Tags", | |||
"remove_tags" => "Remove Tags", | |||
"run_ansible_playbook" => "Run Ansible Playbook", |
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.
@lgalis
I am calling it Run Ansible Playbook for now
This pull request is not mergeable. Please rebase and repush. |
app/models/miq_action.rb
Outdated
@@ -221,6 +222,11 @@ def action_audit(_action, rec, inputs) | |||
:message => "Policy #{msg}: policy: [#{inputs[:policy].description}], event: [#{inputs[:event].description}]") | |||
end | |||
|
|||
def action_run_ansible_playbook(action, rec, inputs) | |||
service_template = ServiceTemplate.find(action.options[:service_template_id]) | |||
Api::ServiceTemplateWorkflow.create(service_template, {}).submit_request |
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.
@abellotti Any thoughts on initiating the service request this way?
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.
it's a lib/services/api/ helper class. right now only used by Api and probably should stay that way. I wonder if that specific logic should be moved to the model and used by Api and from here.
/cc @imtayadeway
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.
I was thinking the same thing. This change would also support a recent request to enable service ordering from an automate methods. https://www.pivotaltracker.com/story/show/140055813
4f7cc8d
to
a06f3d8
Compare
Depends on #13972 |
@mkanoor has any of |
@imtayadeway |
7d5fa69
to
7c19f64
Compare
@gmcculloug |
app/models/miq_action.rb
Outdated
end | ||
|
||
def target_user(record) | ||
record.respond_to?(:tenant_identity) ? record.tenant_identity : User.find("admin") |
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 method should be called tenant_identity
and the "admin" condition should be following the pattern from here: https://github.com/ManageIQ/manageiq/blob/master/app/models/mixins/tenant_identity_mixin.rb#L8
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.
@mkanoor Any thoughts on this one remaining comment?
Checked commits mkanoor/manageiq@386c470~...5a4e3b5 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
Order an Ansible Service for control action run_ansible_playbook