puppet_server certname changes

At present, puppet_node is defined by default and must almost always be
overwritten. This changes the logic for puppet_server so puppet_node is
initially undefined and the node name will be set based on this order

1. puppet_node if defined
2. host_name if defined (actually this removes the explicit certname
specification which is cleaner and uses the machine hostname)
3. config.vm.box
This commit is contained in:
withnail 2012-02-02 00:00:13 +00:00 committed by Mitchell Hashimoto
parent 77c1b7c9e2
commit e90c36ac77
1 changed files with 7 additions and 5 deletions

View File

@ -12,7 +12,7 @@ module Vagrant
def initialize
@puppet_server = "puppet"
@puppet_node = "puppet_node"
@puppet_node = nil
@options = []
end
end
@ -37,14 +37,16 @@ module Vagrant
options = config.options
options = options.join(" ") if options.is_a?(Array)
if config.puppet_node
cn = config.puppet_node
cn = "--certname #{config.puppet_node}"
elsif env[:vm].config.vm.host_name
cn = ""
else
cn = env[:vm].config.vm.box
cn = "--certname #{env[:vm].config.vm.box}"
end
command = "puppetd #{options} --server #{config.puppet_server} --certname #{cn}"
command = "puppetd #{options} --server #{config.puppet_server} #{cn}"
env[:ui].info I18n.t("vagrant.provisioners.puppet_server.running_puppetd")
env[:ui].info I18n.t("vagrant.provisioners.puppet_server.running_puppetd" + command)
env[:vm].channel.sudo(command) do |type, data|
env[:ui].info(data.chomp, :prefix => false)
end