forked from ManageIQ/manageiq
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ManageIQ#19079 from carbonin/pull_roles_from_ansib…
…le_galaxy Pull roles from ansible galaxy before running a playbook
- Loading branch information
Showing
4 changed files
with
124 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
RSpec.describe Ansible::Content do | ||
let(:content_dir) { Pathname.new(Dir.mktmpdir) } | ||
let(:roles_dir) { content_dir.join("roles") } | ||
let(:local_requirements) { content_dir.join("requirements.yml") } | ||
let(:roles_requirements) { content_dir.join("roles", "requirements.yml") } | ||
|
||
subject { described_class.new(content_dir) } | ||
|
||
after { FileUtils.rm_rf(content_dir) } | ||
|
||
describe "#fetch_galaxy_roles" do | ||
it "doesn't run anything if there is no requirements file" do | ||
expect(AwesomeSpawn).not_to receive(:run!) | ||
|
||
subject.fetch_galaxy_roles | ||
end | ||
|
||
it "runs ansible-galaxy using the local requirements file" do | ||
FileUtils.touch(local_requirements) | ||
|
||
expected_params = [ | ||
"install", | ||
:roles_path= => roles_dir, | ||
:role_file= => local_requirements | ||
] | ||
expect(AwesomeSpawn).to receive(:run!).with("ansible-galaxy", :params => expected_params) | ||
|
||
subject.fetch_galaxy_roles | ||
end | ||
|
||
it "runs ansible-runner using the roles requirements file" do | ||
FileUtils.mkdir(roles_dir) | ||
FileUtils.touch(roles_requirements) | ||
|
||
expected_params = [ | ||
"install", | ||
:roles_path= => roles_dir, | ||
:role_file= => roles_requirements | ||
] | ||
expect(AwesomeSpawn).to receive(:run!).with("ansible-galaxy", :params => expected_params) | ||
|
||
subject.fetch_galaxy_roles | ||
end | ||
|
||
it "prefers the roles requirements file" do | ||
FileUtils.mkdir(roles_dir) | ||
FileUtils.touch(roles_requirements) | ||
FileUtils.touch(local_requirements) | ||
|
||
expected_params = [ | ||
"install", | ||
:roles_path= => roles_dir, | ||
:role_file= => roles_requirements | ||
] | ||
expect(AwesomeSpawn).to receive(:run!).with("ansible-galaxy", :params => expected_params) | ||
|
||
subject.fetch_galaxy_roles | ||
end | ||
|
||
it "works with a string path" do | ||
FileUtils.touch(local_requirements) | ||
|
||
expected_params = [ | ||
"install", | ||
:roles_path= => roles_dir, | ||
:role_file= => local_requirements | ||
] | ||
expect(AwesomeSpawn).to receive(:run!).with("ansible-galaxy", :params => expected_params) | ||
|
||
described_class.new(content_dir.to_s).fetch_galaxy_roles | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters