diff --git a/plugins/provisioners/salt/config.rb b/plugins/provisioners/salt/config.rb index bf27720f9..ccee43ec1 100644 --- a/plugins/provisioners/salt/config.rb +++ b/plugins/provisioners/salt/config.rb @@ -90,6 +90,13 @@ module VagrantPlugins end end + if @master_config + expanded = Pathname.new(@master_config).expand_path(machine.env.root_path) + if !expanded.file? + errors << I18n.t("vagrant.provisioners.salt.master_config_nonexist") + end + end + if @minion_key || @minion_pub if !@minion_key || !@minion_pub errors << I18n.t("vagrant.provisioners.salt.missing_key") diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 68363ea10..e2ea4ede4 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1635,6 +1635,8 @@ en: salt: minion_config_nonexist: |- The specified minion_config file could not be found. + master_config_nonexist: |- + The specified master_config file could not be found. missing_key: |- You must include both public and private keys. must_accept_keys: |- diff --git a/test/unit/plugins/provisioners/salt/config_test.rb b/test/unit/plugins/provisioners/salt/config_test.rb index 299be65b0..c640a7497 100644 --- a/test/unit/plugins/provisioners/salt/config_test.rb +++ b/test/unit/plugins/provisioners/salt/config_test.rb @@ -42,5 +42,23 @@ describe VagrantPlugins::Salt::Config do expect(result[error_key]).to be_empty end end + + context "master_config" do + it "fails if master_config is set and missing" do + subject.master_config = "/ceci/nest/pas/une/path" + subject.finalize! + + result = subject.validate(machine) + expect(result[error_key]).to_not be_empty + end + + it "is valid if is set and not missing" do + subject.master_config = File.expand_path(__FILE__) + subject.finalize! + + result = subject.validate(machine) + expect(result[error_key]).to be_empty + end + end end end