diff --git a/app/models/service_ansible_playbook.rb b/app/models/service_ansible_playbook.rb index 130f6f621a8..a931fc615c4 100644 --- a/app/models/service_ansible_playbook.rb +++ b/app/models/service_ansible_playbook.rb @@ -1,4 +1,6 @@ class ServiceAnsiblePlaybook < ServiceGeneric + delegate :job_template, :to => :service_template, :allow_nil => true + # A chance for taking options from automate script to override options from a service dialog def preprocess(action, add_options = {}) save_job_options(action, add_options) @@ -38,10 +40,6 @@ def job(action) private - def job_template(action) - service_template.resource_actions.find_by!(:action => action).configuration_template - end - def get_job_options(action) job_opts = options["#{action.downcase}_job_options".to_sym].deep_dup credential_id = job_opts.delete(:credential_id) diff --git a/app/models/service_template_ansible_playbook.rb b/app/models/service_template_ansible_playbook.rb index fbdd7b4536d..cbd49f98bdb 100644 --- a/app/models/service_template_ansible_playbook.rb +++ b/app/models/service_template_ansible_playbook.rb @@ -7,9 +7,8 @@ def self.default_retirement_entry_point '/Service/Generic/StateMachines/GenericLifecycle/retire' end - def job_template(service_action) - item = resource_actions.detect { |ra| ra.action == service_action } - item.configuration_template if item + def job_template(action) + resource_actions.find_by!(:action => action).configuration_template end # create ServiceTemplate and supporting ServiceResources and ResourceActions diff --git a/spec/models/service_ansible_playbook_spec.rb b/spec/models/service_ansible_playbook_spec.rb index df4795abc57..7bf15baa3f4 100644 --- a/spec/models/service_ansible_playbook_spec.rb +++ b/spec/models/service_ansible_playbook_spec.rb @@ -5,7 +5,7 @@ let(:action) { ResourceAction::PROVISION } let(:loaded_service) do - service_template = FactoryGirl.create(:service_template) + service_template = FactoryGirl.create(:service_template_ansible_playbook) service_template.resource_actions.build(:action => action, :configuration_template => tower_job_temp) service_template.save! FactoryGirl.create(:service_ansible_playbook, :options => provision_options, :service_template => service_template)