~nvalcarcel/ubuntu/lucid/puppet/fix-546677

« back to all changes in this revision

Viewing changes to ext/puppetlisten/puppetrun.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-12-23 00:48:10 UTC
  • mfrom: (1.1.10 upstream) (3.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091223004810-3i4oryds922g5n59
Tags: 0.25.1-3ubuntu1
* Merge from debian testing.  Remaining changes:
  - debian/rules:
    + Don't start puppet when first installing puppet.
  - debian/puppet.conf, lib/puppet/defaults.rb:
    + Move templates to /etc/puppet
  - lib/puppet/defaults.rb:
    + Fix /var/lib/puppet/state ownership.
  - man/man8/puppet.conf.8: 
    + Fix broken URL in manpage.
  - debian/control:
    + Update maintainer accordint to spec.
    + Puppetmaster Recommends -> Suggests
    + Created puppet-testsuite as a seperate. Allow the users to run puppet's 
      testsuite.
  - tests/Rakefile: Fix rakefile so that the testsuite can acutally be ran.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env ruby
 
2
# this scripts calls a client and ask him to trigger a puppetd run
 
3
# uses SSL for communication based on the puppet infrastructure
 
4
# the client allows access based on the namespaceauth
 
5
# ohadlevy@gmail.com
 
6
 
 
7
port = 8139
 
8
if ARGV[0].nil?
 
9
    warn "Usage: hostname to run against"
 
10
    exit 1
 
11
else
 
12
    host = ARGV[0]
 
13
end
 
14
 
 
15
require 'puppet/sslcertificates/support'
 
16
require 'socket'
 
17
 
 
18
# load puppet configuration, needed to find ssl certificates
 
19
Puppet[:config] = "/etc/puppet/puppet.conf"
 
20
Puppet.parse_config
 
21
 
 
22
# establish the certificate
 
23
ctx = OpenSSL::SSL::SSLContext.new()
 
24
ctx.key = OpenSSL::PKey::RSA.new(File::read(Puppet[:hostprivkey]))
 
25
ctx.cert = OpenSSL::X509::Certificate.new(File::read(Puppet[:hostcert]))
 
26
ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER
 
27
ctx.ca_file = Puppet[:localcacert]
 
28
 
 
29
# establish the connection
 
30
s = TCPSocket.new(host, port)
 
31
ssl = OpenSSL::SSL::SSLSocket.new(s, ctx)
 
32
ssl.connect # start SSL session
 
33
ssl.sync_close = true  # if true the underlying socket will be
 
34
                       # closed in SSLSocket#close. (default: false)
 
35
while (line = ssl.gets)
 
36
    puts line
 
37
end
 
38
 
 
39
ssl.close