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

Use embedded tower default objects for ManageIQ #14467

Merged
merged 1 commit into from
Mar 22, 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
6 changes: 4 additions & 2 deletions app/models/service_ansible_playbook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ def extra_vars_from_dialog
end

def create_inventory_with_hosts(action, hosts)
manager(action).with_provider_connection do |connection|
connection.api.inventories.create!(:name => inventory_name(action), :organization => 1).tap do |inventory|
tower = manager(action)
tower.with_provider_connection do |connection|
miq_org = tower.provider.default_organization
connection.api.inventories.create!(:name => inventory_name(action), :organization => miq_org).tap do |inventory|
hosts.split(',').each do |host|
connection.api.hosts.create!(:name => host, :inventory => inventory.id)
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/service_template_ansible_playbook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def self.build_parameter_list(name, description, info)
:description => description || '',
:project => playbook.configuration_script_source.manager_ref,
:playbook => playbook.name,
:inventory => tower.inventory_root_groups.find_by!(:name => 'Demo Inventory').ems_ref,
:inventory => tower.provider.default_inventory,
:ask_variables_on_launch => true,
:ask_limit_on_launch => true,
:ask_inventory_on_launch => true,
Expand Down
9 changes: 3 additions & 6 deletions spec/models/service_template_ansible_playbook_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@

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

let(:inventory_root_group) { FactoryGirl.create(:inventory_root_group, :name => 'Demo Inventory') }
let(:service_template_catalog) { FactoryGirl.create(:service_template_catalog) }
let(:ems) do
FactoryGirl.create(:automation_manager_ansible_tower, :inventory_root_groups => [inventory_root_group])
end
let(:provider) { FactoryGirl.create(:provider_embedded_ansible, :default_inventory => 1) }
let(:ems) { FactoryGirl.create(:automation_manager_ansible_tower, :provider => provider) }

let(:playbook) do
FactoryGirl.create(:embedded_playbook,
:configuration_script_source => script_source,
:manager => ems,
:inventory_root_group => inventory_root_group)
:manager => ems)
end

let(:job_template) do
Expand Down