2013-01-14 00:22:47 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module Puppet
|
|
|
|
module Config
|
|
|
|
class PuppetServer < Vagrant.plugin("2", :config)
|
2015-10-10 18:48:31 +00:00
|
|
|
# The path to Puppet's bin/ directory.
|
|
|
|
# @return [String]
|
|
|
|
attr_accessor :binary_path
|
|
|
|
|
2013-11-25 23:06:05 +00:00
|
|
|
attr_accessor :client_cert_path
|
|
|
|
attr_accessor :client_private_key_path
|
|
|
|
attr_accessor :facter
|
|
|
|
attr_accessor :options
|
2013-01-14 00:22:47 +00:00
|
|
|
attr_accessor :puppet_server
|
|
|
|
attr_accessor :puppet_node
|
|
|
|
|
2013-11-25 22:32:36 +00:00
|
|
|
def initialize
|
|
|
|
super
|
|
|
|
|
2015-10-10 18:48:31 +00:00
|
|
|
@binary_path = UNSET_VALUE
|
2013-11-25 23:06:05 +00:00
|
|
|
@client_cert_path = UNSET_VALUE
|
|
|
|
@client_private_key_path = UNSET_VALUE
|
|
|
|
@facter = {}
|
|
|
|
@options = []
|
|
|
|
@puppet_node = UNSET_VALUE
|
|
|
|
@puppet_server = UNSET_VALUE
|
2013-11-25 22:32:36 +00:00
|
|
|
end
|
|
|
|
|
2014-02-03 21:27:23 +00:00
|
|
|
def merge(other)
|
|
|
|
super.tap do |result|
|
|
|
|
result.facter = @facter.merge(other.facter)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-11-25 22:32:36 +00:00
|
|
|
def finalize!
|
|
|
|
super
|
|
|
|
|
2015-10-10 18:48:31 +00:00
|
|
|
@binary_path = nil if @binary_path == UNSET_VALUE
|
2013-11-25 23:06:05 +00:00
|
|
|
@client_cert_path = nil if @client_cert_path == UNSET_VALUE
|
|
|
|
@client_private_key_path = nil if @client_private_key_path == UNSET_VALUE
|
2013-11-25 22:32:36 +00:00
|
|
|
@puppet_node = nil if @puppet_node == UNSET_VALUE
|
|
|
|
@puppet_server = "puppet" if @puppet_server == UNSET_VALUE
|
|
|
|
end
|
2013-11-25 23:06:05 +00:00
|
|
|
|
|
|
|
def validate(machine)
|
|
|
|
errors = _detected_errors
|
|
|
|
|
|
|
|
if (client_cert_path && !client_private_key_path) ||
|
|
|
|
(client_private_key_path && !client_cert_path)
|
|
|
|
errors << I18n.t(
|
|
|
|
"vagrant.provisioners.puppet_server.client_cert_and_private_key")
|
|
|
|
end
|
|
|
|
|
|
|
|
if client_cert_path
|
|
|
|
path = Pathname.new(client_cert_path).
|
|
|
|
expand_path(machine.env.root_path)
|
|
|
|
if !path.file?
|
|
|
|
errors << I18n.t(
|
|
|
|
"vagrant.provisioners.puppet_server.client_cert_not_found")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if client_private_key_path
|
|
|
|
path = Pathname.new(client_private_key_path).
|
|
|
|
expand_path(machine.env.root_path)
|
|
|
|
if !path.file?
|
|
|
|
errors << I18n.t(
|
|
|
|
"vagrant.provisioners.puppet_server.client_private_key_not_found")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if !puppet_node && (client_cert_path || client_private_key_path)
|
|
|
|
errors << I18n.t(
|
|
|
|
"vagrant.provisioners.puppet_server.cert_requires_node")
|
|
|
|
end
|
|
|
|
|
|
|
|
{ "puppet server provisioner" => errors }
|
|
|
|
end
|
2013-01-14 00:22:47 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|