Skip to content

Commit

Permalink
Merge pull request #19056 from carbonin/dont_create_a_default_project
Browse files Browse the repository at this point in the history
Don't create the embedded ansible default project

(cherry picked from commit 564a6be)
  • Loading branch information
Fryguy authored and simaishi committed Jul 25, 2019
1 parent 1c9a2cd commit 85a9399
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 43 deletions.
35 changes: 0 additions & 35 deletions app/models/manageiq/providers/embedded_ansible/seeding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,42 +19,7 @@ def seed
:resource => manager
)

create_local_playbook_repo
local_repo = ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScriptSource.find_or_create_by!(
:name => "#{Vmdb::Appliance.PRODUCT_NAME} Default Project",
:manager_id => manager.id
)
local_repo.raw_update_in_provider(
:scm_type => "git",
:scm_url => "file://#{local_playbook_repo_dir}",
:scm_update_on_launch => false
)
end

private

def create_local_playbook_repo
Ansible::Content.consolidate_plugin_playbooks

Dir.chdir(local_playbook_repo_dir) do
require 'rugged'
repo = Rugged::Repository.init_at(".")
index = repo.index
index.add_all("*")
index.write

options = {}
options[:tree] = index.write_tree(repo)
options[:author] = options[:committer] = { :email => "system@localhost", :name => "System", :time => Time.now.utc }
options[:message] = "Initial Commit"
options[:parents] = []
options[:update_ref] = 'HEAD'
Rugged::Commit.create(repo, options)
end
end

def local_playbook_repo_dir
Ansible::Content::PLUGIN_CONTENT_DIR
end
end
end
10 changes: 2 additions & 8 deletions spec/models/manageiq/providers/embedded_ansible_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,8 @@
expect(auth.manager_ref).to eq(auth.id.to_s)
end

it "creates the local playbook repo" do
repo = manager.configuration_script_sources.find_by(:name => "ManageIQ Default Project")

expect(repo.scm_type).to eq("git")
expect(repo.scm_url).to eq("file://#{consolidated_repo_path}")
expect(repo.scm_update_on_launch).to be_falsey

expect(Dir.exist?(File.join(consolidated_repo_path, ".git"))).to be_truthy
it "consolidates the embedded ansible content" do
expect(Dir.exist?(File.join(consolidated_repo_path))).to be_truthy
end
end
end

0 comments on commit 85a9399

Please sign in to comment.