Merge pull request #9916 from chrisroberts/f-chef-provisioner
Fix Chef apply provisioner to not set node_name
This commit is contained in:
commit
87ce38df93
|
@ -24,7 +24,7 @@ module VagrantPlugins
|
|||
|
||||
@logger = Log4r::Logger.new("vagrant::provisioners::chef")
|
||||
|
||||
if !present?(@config.node_name)
|
||||
if @config.respond_to?(:node_name) && !present?(@config.node_name)
|
||||
# First attempt to get the node name from the hostname, and if that
|
||||
# is not present, generate/retrieve a random hostname.
|
||||
hostname = @machine.config.vm.hostname
|
||||
|
|
|
@ -39,16 +39,21 @@ describe VagrantPlugins::Chef::Provisioner::Base do
|
|||
|
||||
it "defaults to hostname if given" do
|
||||
machine.config.vm.hostname = "by.hostname"
|
||||
instance = described_class.new(machine, OpenStruct.new)
|
||||
instance = described_class.new(machine, OpenStruct.new(node_name: nil))
|
||||
expect(instance.config.node_name).to eq("by.hostname")
|
||||
end
|
||||
|
||||
it "generates a random name if no hostname or node_name is given" do
|
||||
config = OpenStruct.new(node_name: nil)
|
||||
machine.config.vm.hostname = nil
|
||||
instance = described_class.new(machine, OpenStruct.new)
|
||||
instance = described_class.new(machine, OpenStruct.new(node_name: nil))
|
||||
expect(instance.config.node_name).to match(/vagrant\-.+/)
|
||||
end
|
||||
|
||||
it "does not set node_name if configuration does not define it" do
|
||||
expect(config).to receive(:respond_to?).with(:node_name).and_return(false)
|
||||
expect(config).not_to receive(:node_name)
|
||||
described_class.new(machine, config)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#encrypted_data_bag_secret_key_path" do
|
||||
|
|
Loading…
Reference in New Issue