-
Notifications
You must be signed in to change notification settings - Fork 14
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 #201 from chef/i5pranay93/support_aix
Support AIX for chef adhoc runs
- Loading branch information
Showing
5 changed files
with
114 additions
and
1 deletion.
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
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,55 @@ | ||
module ChefApply | ||
class TargetHost | ||
module Aix | ||
|
||
def omnibus_manifest_path | ||
# Note that we can't use File::Join, because that will render for the | ||
# CURRENT platform - not the platform of the target. | ||
"/opt/chef/version-manifest.json" | ||
end | ||
|
||
def mkdir(path) | ||
run_command!("mkdir -p #{path}") | ||
end | ||
|
||
def chown(path, owner) | ||
# owner ||= user | ||
# run_command!("chown #{owner} '#{path}'") | ||
nil | ||
end | ||
|
||
def make_temp_dir | ||
# We will cache this so that we only run this once | ||
@tempdir ||= begin | ||
res = run_command!("bash -c '#{MKTEMP_COMMAND}'") | ||
res.stdout.chomp.strip | ||
end | ||
end | ||
|
||
def install_package(target_package_path) | ||
command = "installp -aXYgd #{target_package_path} all" | ||
run_command!(command) | ||
end | ||
|
||
def del_file(path) | ||
run_command!("rm -rf #{path}") | ||
end | ||
|
||
def del_dir(path) | ||
del_file(path) | ||
end | ||
|
||
def ws_cache_path | ||
"/var/chef-workstation" | ||
end | ||
|
||
# Nothing to escape in a unix-based path | ||
def normalize_path(path) | ||
path | ||
end | ||
|
||
MKTEMP_COMMAND = "d=$(mktemp -d -p${TMPDIR:-/tmp} chef_XXXXXX); echo $d".freeze | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
require "spec_helper" | ||
require "chef_apply/target_host" | ||
require "chef_apply/target_host/aix" | ||
|
||
RSpec.describe ChefApply::TargetHost::Aix do | ||
let(:user) { "testuser" } | ||
let(:host) { "mock://#{user}@example.com" } | ||
let(:family) { "aix" } | ||
let(:name) { "aix" } | ||
let(:path) { "/tmp/blah" } | ||
|
||
subject do | ||
ChefApply::TargetHost.mock_instance(host, family: family, name: name) | ||
end | ||
|
||
context "#make_temp_dir" do | ||
it "creates the directory using a properly formed make_temp_dir" do | ||
expect(subject).to receive(:run_command!) | ||
.with("bash -c '#{ChefApply::TargetHost::Aix::MKTEMP_COMMAND}'") | ||
.and_return(instance_double("result", stdout: "/tmp/blah")) | ||
expect(subject.make_temp_dir).to eq "/tmp/blah" | ||
end | ||
end | ||
|
||
context "#mkdir" do | ||
it "uses a properly formed mkdir to create the directory and changes ownership to connected user" do | ||
expect(subject).to receive(:run_command!).with("mkdir -p /tmp/dir") | ||
subject.mkdir("/tmp/dir") | ||
end | ||
end | ||
|
||
context "#chown" do | ||
# it "uses a properly formed chown to change owning user to the provided user" do | ||
# expect(subject).to receive(:run_command!).with("chown newowner '/tmp/dir'") | ||
# subject.chown("/tmp/dir", "newowner") | ||
# end | ||
xit "Doing nothing for this right now on aix" | ||
end | ||
|
||
context "#install_package" do | ||
context "run the correct pkg run command " do | ||
let(:expected_command) { "installp -aXYgd chef-17.9.26-1.powerpc.bff all" } | ||
it "should run the correct install command" do | ||
expect(subject).to receive(:run_command!).with expected_command | ||
subject.install_package("chef-17.9.26-1.powerpc.bff") | ||
end | ||
|
||
end | ||
end | ||
end |