Permalink
Browse files

Require param --agentcertname and append value to answers file.

  • Loading branch information...
1 parent 40a17eb commit 152e1af283887e99f6f260e8f3913d017d2c8378 @hadfieldj committed May 22, 2011
Showing with 14 additions and 10 deletions.
  1. +14 −10 lib/puppet/cloudpack.rb
View
@@ -37,6 +37,10 @@ def add_create_options(action)
end
end
+ action.option '--agentcertname=' do
+ required
+ end
+
action.option '--group=', '-g=', '--security-group=' do
before_action do |action, args, options|
options[:group] = options[:group].split(File::PATH_SEPARATOR) unless options[:group].is_a? Array
@@ -123,7 +127,7 @@ def bootstrap(options)
return nil
end
- def classify(certname, options)
+ def classify(agentcertname, options)
puts "Using http://#{Puppet[:report_server]}:#{Puppet[:report_port]} as Dashboard."
http = Puppet::Network::HttpPool.http_instance(Puppet[:report_server], Puppet[:report_port])
@@ -133,7 +137,7 @@ def classify(certname, options)
begin
print 'Registering node ...'
- data = { 'node' => { 'name' => certname } }
+ data = { 'node' => { 'name' => agentcertname } }
response = http.post('/nodes.json', data.to_pson, headers)
if (response.code == '201')
puts ' Done'
@@ -143,7 +147,7 @@ def classify(certname, options)
end
print 'Classifying node ...'
- data = { 'node_name' => certname, 'group_name' => options[:node_group] }
+ data = { 'node_name' => agentcertname, 'group_name' => options[:node_group] }
response = http.post("/memberships.json", data.to_pson, headers)
if (response.code == '201')
puts ' Done'
@@ -225,13 +229,13 @@ def create(options)
end
def init(server, options)
- certname = install(server, options)
+ agentcertname = install(server, options)
options.delete(:_destroy_server_at_exit)
puts "Puppet Enterprise is now installed on: #{server}"
- puts "Node certificate name: #{certname}"
+ puts "Node certificate name: #{agentcertname}"
- classify(certname, options)
+ classify(agentcertname, options)
# HACK: This should be reconciled with the Certificate Face.
opts = options.merge(:ca_location => :remote)
@@ -240,7 +244,7 @@ def init(server, options)
print "Signing certificate ..."
begin
- Puppet::Face[:certificate, '0.0.1'].sign(certname, opts)
+ Puppet::Face[:certificate, '0.0.1'].sign(agentcertname, opts)
puts " Done"
rescue Puppet::Error => e
# TODO: Write useful next steps.
@@ -260,7 +264,7 @@ def install(server, options)
elsif not test('x', '/usr/bin/uuidgen')
raise "/usr/bin/uuidgen is not executable; please change that file's permissions."
end
- certname = `/usr/bin/uuidgen`.downcase.chomp
+ #certname = `/usr/bin/uuidgen`.downcase.chomp
opts = {}
opts[:key_data] = [File.read(keyfile)] if keyfile
@@ -297,13 +301,13 @@ def install(server, options)
print "Installing Puppet ..."
steps = [
'tar -xvzf /tmp/puppet.tar.gz -C /tmp',
- %Q[echo "q_puppetagent_certname='#{ certname }'" >> /tmp/puppet.answers],
+ %Q[echo "q_puppetagent_certname='#{ agentcertname }'" >> /tmp/puppet.answers],
'/tmp/puppet-enterprise-1.0-all/puppet-enterprise-installer -a /tmp/puppet.answers &> /tmp/install.log'
]
ssh.run(steps.map { |c| login == 'root' ? "#{c}" : "sudo #{c}" })
puts " Done"
- return certname
+ return agentcertname
end
def terminate(server, options)

0 comments on commit 152e1af

Please sign in to comment.