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

Require EmbeddedAnsible playbook to create playbook service #14226

Merged
merged 1 commit into from
Mar 8, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions app/models/service_template_ansible_playbook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ def self.create_job_templates(service_name, description, config_info, auth_user)
def self.create_job_template(name, description, info, auth_user)
tower, params = build_parameter_list(name, description, info)

task_id = ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript.create_in_provider_queue(tower.id, params, auth_user)
task_id = ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScript.create_in_provider_queue(tower.id, params, auth_user)
task = MiqTask.wait_for_taskid(task_id)
raise task.message unless task.status == "Ok"
task.task_results
end
private_class_method :create_job_template

def self.build_parameter_list(name, description, info)
playbook = ManageIQ::Providers::AnsibleTower::AutomationManager::Playbook.find(info[:playbook_id])
playbook = ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Playbook.find(info[:playbook_id])
tower = playbook.manager
params = {
:name => name,
Expand Down
4 changes: 4 additions & 0 deletions spec/factories/configuration_script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@
factory :ansible_configuration_script,
:class => "ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript",
:parent => :configuration_script

factory :embedded_playbook,
:class => "ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Playbook",
:parent => :configuration_script_payload
end
10 changes: 4 additions & 6 deletions spec/models/service_template_ansible_playbook_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
let(:auth_one) { FactoryGirl.create(:authentication, :manager_ref => 6) }
let(:auth_two) { FactoryGirl.create(:authentication, :manager_ref => 10) }

let(:config_script) { FactoryGirl.create(:configuration_script) }
let(:script_source) { FactoryGirl.create(:configuration_script_source, :manager => ems) }

let(:inventory_root_group) { FactoryGirl.create(:inventory_root_group, :name => 'Demo Inventory') }
Expand All @@ -13,11 +12,10 @@
end

let(:playbook) do
FactoryGirl.create(:configuration_script_payload,
FactoryGirl.create(:embedded_playbook,
:configuration_script_source => script_source,
:manager => ems,
:inventory_root_group => inventory_root_group,
:type => 'ManageIQ::Providers::AnsibleTower::AutomationManager::Playbook')
:inventory_root_group => inventory_root_group)
end

let(:job_template) do
Expand Down Expand Up @@ -74,7 +72,7 @@

it '#create_job_template' do
expect(described_class).to receive(:build_parameter_list).and_return([ems, {}])
expect(ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript)
expect(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScript)
.to receive(:create_in_provider_queue).once.with(ems.id, {}, 'system')
expect(MiqTask).to receive(:wait_for_taskid).with(any_args).once.and_return(
instance_double('MiqTask', :task_results => {}, :status => 'Ok')
Expand All @@ -89,7 +87,7 @@

it 'create_job_template exception' do
expect(described_class).to receive(:build_parameter_list).and_return([ems, {}])
expect(ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript)
expect(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScript)
.to receive(:create_in_provider_queue).once.with(ems.id, {}, 'system')
expect(MiqTask).to receive(:wait_for_taskid).with(any_args).once.and_raise(Exception, 'bad job template')

Expand Down