More intelligent puppet server cert name handling

This commit is contained in:
Mitchell Hashimoto 2012-02-04 13:57:02 +01:00
parent ab8b1d3ea6
commit 90d7742c9c
2 changed files with 19 additions and 5 deletions

View File

@ -10,6 +10,8 @@
[GH-698] [GH-698]
- When using bridged networking, only list the network interfaces - When using bridged networking, only list the network interfaces
that are up as choices. [GH-701] that are up as choices. [GH-701]
- More intelligent handling of the `certname` option for puppet
server. [GH-702]
## 0.9.4 (January 28, 2012) ## 0.9.4 (January 28, 2012)

View File

@ -32,16 +32,28 @@ module Vagrant
def run_puppetd_client def run_puppetd_client
options = config.options options = config.options
options = options.join(" ") if options.is_a?(Array) options = [options] if !options.is_a?(Array)
# Intelligently set the puppet node cert name based on certain
# external parameters.
cn = nil
if config.puppet_node if config.puppet_node
cn = "--certname #{config.puppet_node}" # If a node name is given, we use that directly for the certname
cn = config.puppet_node
elsif env[:vm].config.vm.host_name elsif env[:vm].config.vm.host_name
cn = "" # If a host name is given, we explicitly set the certname to
# nil so that the hostname becomes the cert name.
cn = nil
else else
cn = "--certname #{env[:vm].config.vm.box}" # Otherwise, we default to the name of the box.
cn = env[:vm].config.vm.box
end end
command = "puppetd #{options} --server #{config.puppet_server} #{cn}" # Add the certname option if there is one
options += ["--certname", cn] if cn
options = options.join(" ")
command = "puppetd #{options} --server #{config.puppet_server}"
env[:ui].info I18n.t("vagrant.provisioners.puppet_server.running_puppetd" + command) env[:ui].info I18n.t("vagrant.provisioners.puppet_server.running_puppetd" + command)
env[:vm].channel.sudo(command) do |type, data| env[:vm].channel.sudo(command) do |type, data|