Skip to content

Commit

Permalink
Use embedded tower default objects for ManageIQ
Browse files Browse the repository at this point in the history
  • Loading branch information
bzwei committed Mar 22, 2017
1 parent 8dd095d commit 02a4715
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
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

0 comments on commit 02a4715

Please sign in to comment.