From 90d7742c9c3222c53baca804747fdb6d53fdaffb Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 4 Feb 2012 13:57:02 +0100 Subject: [PATCH] More intelligent puppet server cert name handling --- CHANGELOG.md | 2 ++ lib/vagrant/provisioners/puppet_server.rb | 22 +++++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41a307bff..93dedf5ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ [GH-698] - When using bridged networking, only list the network interfaces 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) diff --git a/lib/vagrant/provisioners/puppet_server.rb b/lib/vagrant/provisioners/puppet_server.rb index 40e248ee7..ae1fa76bf 100644 --- a/lib/vagrant/provisioners/puppet_server.rb +++ b/lib/vagrant/provisioners/puppet_server.rb @@ -32,16 +32,28 @@ module Vagrant def run_puppetd_client 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 - 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 - 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 - cn = "--certname #{env[:vm].config.vm.box}" + # Otherwise, we default to the name of the box. + cn = env[:vm].config.vm.box 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[:vm].channel.sudo(command) do |type, data|