2016-05-25 07:12:14 +00:00
|
|
|
require_relative "../../../../base"
|
|
|
|
require_relative "../../support/shared/config"
|
|
|
|
require_relative "shared"
|
2015-11-20 23:13:35 +00:00
|
|
|
|
2015-02-10 14:28:00 +00:00
|
|
|
require Vagrant.source_root.join("plugins/provisioners/ansible/config/host")
|
2014-03-21 11:02:23 +00:00
|
|
|
|
2016-05-25 07:12:14 +00:00
|
|
|
describe VagrantPlugins::Ansible::Config::Host, :skip_windows => true do
|
2014-03-21 11:02:23 +00:00
|
|
|
include_context "unit"
|
|
|
|
|
|
|
|
subject { described_class.new }
|
|
|
|
|
|
|
|
let(:machine) { double("machine", env: Vagrant::Environment.new) }
|
2014-03-29 08:19:26 +00:00
|
|
|
let(:existing_file) { File.expand_path(__FILE__) }
|
|
|
|
|
|
|
|
it "supports a list of options" do
|
|
|
|
supported_options = %w( ask_sudo_pass
|
2014-04-14 03:24:57 +00:00
|
|
|
ask_vault_pass
|
2014-03-29 08:19:26 +00:00
|
|
|
extra_vars
|
2015-11-02 08:03:15 +00:00
|
|
|
force_remote_user
|
2015-11-17 21:06:06 +00:00
|
|
|
galaxy_command
|
|
|
|
galaxy_role_file
|
|
|
|
galaxy_roles_path
|
2014-03-29 08:19:26 +00:00
|
|
|
groups
|
|
|
|
host_key_checking
|
2015-12-01 16:04:56 +00:00
|
|
|
host_vars
|
2014-03-29 08:19:26 +00:00
|
|
|
inventory_path
|
|
|
|
limit
|
|
|
|
playbook
|
|
|
|
raw_arguments
|
|
|
|
raw_ssh_args
|
|
|
|
skip_tags
|
|
|
|
start_at_task
|
|
|
|
sudo
|
|
|
|
sudo_user
|
|
|
|
tags
|
2014-04-14 03:24:57 +00:00
|
|
|
vault_password_file
|
2014-03-29 08:19:26 +00:00
|
|
|
verbose )
|
|
|
|
|
2015-02-10 14:28:00 +00:00
|
|
|
expect(get_provisioner_option_names(described_class)).to eql(supported_options)
|
2014-03-29 08:19:26 +00:00
|
|
|
end
|
|
|
|
|
2016-05-25 07:12:14 +00:00
|
|
|
describe "default options handling" do
|
|
|
|
it_behaves_like "options shared by both Ansible provisioners"
|
|
|
|
|
|
|
|
it "assigns default values to unset host-specific options" do
|
|
|
|
subject.finalize!
|
|
|
|
|
|
|
|
expect(subject.ask_sudo_pass).to be_false
|
|
|
|
expect(subject.ask_vault_pass).to be_false
|
|
|
|
expect(subject.force_remote_user).to be_true
|
|
|
|
expect(subject.host_key_checking).to be_false
|
|
|
|
expect(subject.raw_ssh_args).to be_nil
|
|
|
|
end
|
2014-03-29 08:19:26 +00:00
|
|
|
end
|
2014-03-21 11:02:23 +00:00
|
|
|
|
2015-11-02 08:03:15 +00:00
|
|
|
describe "force_remote_user option" do
|
|
|
|
it_behaves_like "any VagrantConfigProvisioner strict boolean attribute", :force_remote_user, true
|
|
|
|
end
|
2014-04-12 09:00:34 +00:00
|
|
|
describe "host_key_checking option" do
|
|
|
|
it_behaves_like "any VagrantConfigProvisioner strict boolean attribute", :host_key_checking, false
|
|
|
|
end
|
|
|
|
describe "ask_sudo_pass option" do
|
|
|
|
it_behaves_like "any VagrantConfigProvisioner strict boolean attribute", :ask_sudo_pass, false
|
|
|
|
end
|
2014-04-14 03:24:57 +00:00
|
|
|
describe "ask_vault_pass option" do
|
|
|
|
it_behaves_like "any VagrantConfigProvisioner strict boolean attribute", :ask_sudo_pass, false
|
|
|
|
end
|
2014-04-12 09:00:34 +00:00
|
|
|
|
2014-03-21 11:02:23 +00:00
|
|
|
describe "#validate" do
|
2014-03-29 08:19:26 +00:00
|
|
|
before do
|
|
|
|
subject.playbook = existing_file
|
|
|
|
end
|
|
|
|
|
2016-05-25 07:12:14 +00:00
|
|
|
it_behaves_like "an Ansible provisioner", "", "remote"
|
2014-03-21 11:02:23 +00:00
|
|
|
|
2016-04-20 20:27:55 +00:00
|
|
|
it "returns an error if the raw_ssh_args is of the wrong data type" do
|
|
|
|
subject.raw_ssh_args = { arg1: 1, arg2: "foo" }
|
|
|
|
subject.finalize!
|
|
|
|
|
|
|
|
result = subject.validate(machine)
|
|
|
|
expect(result["ansible remote provisioner"]).to eql([
|
|
|
|
I18n.t("vagrant.provisioners.ansible.errors.raw_ssh_args_invalid",
|
|
|
|
type: subject.raw_ssh_args.class.to_s,
|
|
|
|
value: subject.raw_ssh_args.to_s)
|
|
|
|
])
|
|
|
|
end
|
|
|
|
|
|
|
|
it "converts a raw_ssh_args option defined as a String into an Array" do
|
|
|
|
subject.raw_arguments = "-o ControlMaster=no"
|
|
|
|
subject.finalize!
|
|
|
|
|
|
|
|
result = subject.validate(machine)
|
|
|
|
expect(subject.raw_arguments).to eql(["-o ControlMaster=no"])
|
|
|
|
end
|
|
|
|
|
2014-03-21 11:02:23 +00:00
|
|
|
end
|
2014-03-29 08:19:26 +00:00
|
|
|
|
2014-03-21 11:02:23 +00:00
|
|
|
end
|