runpuppet 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,6 +3,8 @@ source "http://rubygems.org"
3
3
  # Example:
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
 
6
+ gem 'rest-client'
7
+ gem 'facter'
6
8
  # Add dependencies to develop your gem here.
7
9
  # Include everything needed to run rake, tests, features, etc.
8
10
  group :development do
data/Gemfile.lock CHANGED
@@ -1,14 +1,18 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ facter (1.6.0)
4
5
  git (1.2.5)
5
6
  jeweler (1.5.2)
6
7
  bundler (~> 1.0.0)
7
8
  git (>= 1.2.5)
8
9
  rake
10
+ mime-types (1.16)
9
11
  mocha (0.9.12)
10
12
  rake (0.9.2)
11
13
  rcov (0.9.9)
14
+ rest-client (1.6.3)
15
+ mime-types (>= 1.16)
12
16
  shoulda (2.11.3)
13
17
 
14
18
  PLATFORMS
@@ -16,7 +20,9 @@ PLATFORMS
16
20
 
17
21
  DEPENDENCIES
18
22
  bundler (~> 1.0.0)
23
+ facter
19
24
  jeweler (~> 1.5.2)
20
25
  mocha
21
26
  rcov
27
+ rest-client
22
28
  shoulda
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.6
1
+ 0.5.7
data/lib/ext.rb ADDED
@@ -0,0 +1,8 @@
1
+ class Array
2
+ # [[1,2]] => {1=>2}
3
+ def to_hash
4
+ hash = {}
5
+ each {|k,v| hash[k]=v}
6
+ hash
7
+ end
8
+ end
data/lib/runpuppet.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'open-uri'
2
2
  require 'socket'
3
3
  require 'yaml'
4
+ require 'rest-client'
5
+ require 'lib/ext'
4
6
 
5
7
  class Runpuppet
6
8
  def self.with_lock(lock_file)
@@ -37,7 +39,19 @@ class Runpuppet
37
39
  open(Config.puppet_controller_url + path, {:http_basic_authentication =>Config.puppet_controller_auth} )
38
40
  rescue Exception => e
39
41
  puts e.inspect
40
- puts "WARNING: no connection to puppet controller!"
42
+ puts "WARNING: error connecting to puppet controller!"
43
+ end
44
+ end
45
+
46
+
47
+ def self.post(path, params)
48
+ params[:hostname] = Socket.gethostname
49
+ params[:ip] = Config.local_ip
50
+ begin
51
+ RestClient.post "#{Config.puppet_controller_url}/puppet/#{path}", params
52
+ rescue Exception => e
53
+ puts e.inspect
54
+ puts "WARNING: error connecting to puppet controller!"
41
55
  end
42
56
  end
43
57
 
@@ -65,6 +79,12 @@ class Runpuppet
65
79
  end
66
80
  end
67
81
 
82
+ def self.report_facts(options={})
83
+ require 'facter/application'
84
+ facts = Facter::Application.run([])
85
+ post('facts', :facts => facts.to_hash)
86
+ end
87
+
68
88
 
69
89
  class Config
70
90
  def self.config
@@ -112,7 +132,7 @@ class Runpuppet
112
132
  end
113
133
 
114
134
  def self.is_ec2?
115
- %x(arp -n) =~ /fe:ff:ff:ff:ff/
135
+ %x(arp -n -i eth0) =~ /fe:ff:ff:ff:ff/
116
136
  end
117
137
  end
118
138
  end
data/runpuppet.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{runpuppet}
8
- s.version = "0.5.6"
8
+ s.version = "0.5.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Roman Heinrich"]
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
27
27
  "Rakefile",
28
28
  "VERSION",
29
29
  "bin/runpuppet",
30
+ "lib/ext.rb",
30
31
  "lib/runpuppet.rb",
31
32
  "runpuppet.gemspec",
32
33
  "test/helper.rb",
@@ -46,12 +47,16 @@ Gem::Specification.new do |s|
46
47
  s.specification_version = 3
47
48
 
48
49
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
+ s.add_runtime_dependency(%q<rest-client>, [">= 0"])
51
+ s.add_runtime_dependency(%q<facter>, [">= 0"])
49
52
  s.add_development_dependency(%q<shoulda>, [">= 0"])
50
53
  s.add_development_dependency(%q<mocha>, [">= 0"])
51
54
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
52
55
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
53
56
  s.add_development_dependency(%q<rcov>, [">= 0"])
54
57
  else
58
+ s.add_dependency(%q<rest-client>, [">= 0"])
59
+ s.add_dependency(%q<facter>, [">= 0"])
55
60
  s.add_dependency(%q<shoulda>, [">= 0"])
56
61
  s.add_dependency(%q<mocha>, [">= 0"])
57
62
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
@@ -59,6 +64,8 @@ Gem::Specification.new do |s|
59
64
  s.add_dependency(%q<rcov>, [">= 0"])
60
65
  end
61
66
  else
67
+ s.add_dependency(%q<rest-client>, [">= 0"])
68
+ s.add_dependency(%q<facter>, [">= 0"])
62
69
  s.add_dependency(%q<shoulda>, [">= 0"])
63
70
  s.add_dependency(%q<mocha>, [">= 0"])
64
71
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
@@ -8,4 +8,11 @@ class TestRunpuppet < Test::Unit::TestCase
8
8
  assert_equal ['user', 'pass'], Runpuppet::Config.puppet_controller_auth
9
9
  end
10
10
  end
11
+
12
+ context 'Runpuppet' do
13
+ should "report facts" do
14
+ ec2_facts = [["architecture", "x86_64"], ["arp", "fe:ff:ff:ff:ff:ff"], ["arp_eth0", "fe:ff:ff:ff:ff:ff"], ["domain", "eu-west-1.compute.internal"], ["ec2_ami_id", "ami-7acafc0e"], ["ec2_ami_launch_index", "0"], ["ec2_ami_manifest_path", "(unknown)"], ["ec2_block_device_mapping_ami", "/dev/sda1"], ["ec2_block_device_mapping_ephemeral0", "/dev/sdb"], ["ec2_block_device_mapping_root", "/dev/sda1"], ["ec2_hostname", "ip-10-234-151-254.eu-west-1.compute.internal"], ["ec2_instance_id", "i-cc511dba"], ["ec2_instance_type", "t1.micro"], ["ec2_kernel_id", "aki-4feec43b"], ["ec2_local_hostname", "ip-10-234-151-254.eu-west-1.compute.internal"], ["ec2_local_ipv4", "10.234.151.254"], ["ec2_placement_availability_zone", "eu-west-1a"], ["ec2_profile", "default-paravirtual"], ["ec2_public_hostname", "ec2-46-137-37-20.eu-west-1.compute.amazonaws.com"], ["ec2_public_ipv4", "46.137.37.20"], ["ec2_public_keys_0_openssh_key", "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCn6ld1os3dZkdIjJ0zqOUrZWi9zODc2WEaonlPRjyxqhX5nDYJMFrvKRXAIi41TKxwGXzor55gbLb5GnLDFMHEZwtye9MH4n98DdSFu8Nxb9wZgT1xZ+UE/9+GKVAJq77yIWP5qe6iJe80JQAaO/WbinMoqBZ9YOF2MgPNIUoP/bPHZ6Fb+/3Nv1NV+aAMB2vqOlrujcGkI49vFmH6qbNKgAAyuakGSIlBab4PBPti3B+tOoLeimqL4H8iAQAWZCjinG12oUTkl07ZpU1waFUTDaKv4QvwFU4bGgZYk7hysAjE7A8NxI7ApEenbxySnkjew4zQlmPmV21u16E3kGYx node-autoscaling"], ["ec2_reservation_id", "r-7c31b10a"], ["ec2_security_groups", "default"], ["facterversion", "1.5.9"], ["fqdn", "ip-10-234-151-254.eu-west-1.compute.internal"], ["hardwareisa", "unknown"], ["hardwaremodel", "x86_64"], ["hostname", "ip-10-234-151-254"], ["id", "root"], ["interfaces", "dummy0,eql,eth0,ifb0,ifb1,lo"], ["ipaddress", "10.234.151.254"], ["ipaddress_eth0", "10.234.151.254"], ["ipaddress_lo", "127.0.0.1"], ["is_virtual", "true"], ["kernel", "Linux"], ["kernelmajversion", "2.6"], ["kernelrelease", "2.6.32-314-ec2"], ["kernelversion", "2.6.32"], ["lib", "/var/lib/puppet/facts"], ["lsbdistcodename", "lucid"], ["lsbdistdescription", "Ubuntu 10.04.2 LTS"], ["lsbdistid", "Ubuntu"], ["lsbdistrelease", "10.04"], ["lsbmajdistrelease", "10"], ["macaddress", "26:73:1b:a3:48:2a"], ["macaddress_dummy0", "26:73:1b:a3:48:2a"], ["macaddress_eth0", "12:31:3b:05:94:10"], ["macaddress_ifb0", "5e:5b:e7:92:26:c2"], ["macaddress_ifb1", "72:50:ad:1d:a1:0f"], ["memoryfree", "430.29 MB"], ["memorysize", "635.17 MB"], ["netmask", "255.255.254.0"], ["netmask_eth0", "255.255.254.0"], ["netmask_lo", "255.0.0.0"], ["network_eth0", "10.234.150.0"], ["network_lo", "127.0.0.0"], ["operatingsystem", "Ubuntu"], ["operatingsystemrelease", "10.04"], ["path", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/rvm/bin"], ["physicalprocessorcount", "1"], ["processor0", "Intel(R) Xeon(R) CPU E5430 @ 2.66GHz"], ["processorcount", "1"], ["ps", "ps -ef"], ["puppetversion", "2.6.7"], ["rubysitedir", "/usr/local/lib/ruby/site_ruby/1.8"], ["rubyversion", "1.8.7"], ["selinux", "false"], ["sshdsakey", "AAAAB3NzaC1kc3MAAACBAM2/DHTO3olTFG6lmWXNJcEYKZtFylFWCLJomNEaMMkf7qEtCLSPVWdhgYKHmk/UBPrpuzWrapVa1/eap77CNgQ6e8LmKdcgkCVcuKSLqtm+e989lb9RrcIUYYd4UXIZbLPKF3z3AOmESxikaiQs9M8x4Jn5kmpPb6fixSvOi577AAAAFQDAQMxsywSbD3W28MCI3kfrbKhEPwAAAIBm5HQwsY8VZnfLgWdkpZfcDv2V/9U+0+Atd6O37wpmF4HjIqbIbTJ1ABCXhLgo5oX2YVsRWfVLLxsmgxPoF5CLBNPQcFhNldto4H8sGkcbNFU8oBEiOgnZ6ZEax/Ooe/bO7wR+dz0F5u9IuMj4QK1GWuiAUr7U8E9Ithhe3DVq1QAAAIB3xFxOwbewB9YaeajoTfJDZzt/ovgSD3V4YYgX7mRG8Zv5UW2LduLgifwBJLWVt/Qp44STI1wON2OFRNDvhIH82+5iW3m5ifIy5c8ZviupZVpYy2adw/Ay3+bP/w0TtosmlzyWW7tj2jXVTc79ul3y9uXfZcQw8EB0ISbafy6+2Q=="], ["sshrsakey", "AAAAB3NzaC1yc2EAAAABIwAAAQEAtdvq2CjLz74rL1peJiZakeZtgeJ6lQ1vzCHseSkB3kjsPBMckz9RIec0PrLcY7BmEMfTIJJOq8OrrKdeCauRWQ47tuajVtXr+FXB0U+4FRLs2onBzUI8k2ToY8qNR7TfD5MmirBrYb26S/r0Lm8d86RkkMl4snbwEU0b42e6NbzcjVShAkbGGols7FpziqQWZY4Coo4Z2b2IBLqBZXg4N9laAsR3NlH8JclkUZ34gh5Bnzmr6b/IxTR06aIP0s0W9KEmzuHGv7S/loC1xAgxJMZf/ViLGAGf83jpnp7mMJ5Pbtbbys8tv+Jp4Jobmn/90FkMstkxpoPZX48ImwDfbQ=="], ["swapfree", "0.00 kB"], ["swapsize", "0.00 kB"], ["timezone", "CEST"], ["uniqueid", "ea0afe97"], ["uptime", "4:51 hours"], ["uptime_days", 0], ["uptime_hours", 4], ["uptime_seconds", 17517], ["virtual", "xenu"]]
15
+
16
+ end
17
+ end
11
18
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runpuppet
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 6
10
- version: 0.5.6
9
+ - 7
10
+ version: 0.5.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Roman Heinrich
@@ -28,9 +28,9 @@ dependencies:
28
28
  segments:
29
29
  - 0
30
30
  version: "0"
31
- name: shoulda
31
+ name: rest-client
32
32
  prerelease: false
33
- type: :development
33
+ type: :runtime
34
34
  requirement: *id001
35
35
  - !ruby/object:Gem::Dependency
36
36
  version_requirements: &id002 !ruby/object:Gem::Requirement
@@ -42,12 +42,40 @@ dependencies:
42
42
  segments:
43
43
  - 0
44
44
  version: "0"
45
- name: mocha
45
+ name: facter
46
46
  prerelease: false
47
- type: :development
47
+ type: :runtime
48
48
  requirement: *id002
49
49
  - !ruby/object:Gem::Dependency
50
50
  version_requirements: &id003 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ name: shoulda
60
+ prerelease: false
61
+ type: :development
62
+ requirement: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ version_requirements: &id004 !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ hash: 3
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ name: mocha
74
+ prerelease: false
75
+ type: :development
76
+ requirement: *id004
77
+ - !ruby/object:Gem::Dependency
78
+ version_requirements: &id005 !ruby/object:Gem::Requirement
51
79
  none: false
52
80
  requirements:
53
81
  - - ~>
@@ -61,9 +89,9 @@ dependencies:
61
89
  name: bundler
62
90
  prerelease: false
63
91
  type: :development
64
- requirement: *id003
92
+ requirement: *id005
65
93
  - !ruby/object:Gem::Dependency
66
- version_requirements: &id004 !ruby/object:Gem::Requirement
94
+ version_requirements: &id006 !ruby/object:Gem::Requirement
67
95
  none: false
68
96
  requirements:
69
97
  - - ~>
@@ -77,9 +105,9 @@ dependencies:
77
105
  name: jeweler
78
106
  prerelease: false
79
107
  type: :development
80
- requirement: *id004
108
+ requirement: *id006
81
109
  - !ruby/object:Gem::Dependency
82
- version_requirements: &id005 !ruby/object:Gem::Requirement
110
+ version_requirements: &id007 !ruby/object:Gem::Requirement
83
111
  none: false
84
112
  requirements:
85
113
  - - ">="
@@ -91,7 +119,7 @@ dependencies:
91
119
  name: rcov
92
120
  prerelease: false
93
121
  type: :development
94
- requirement: *id005
122
+ requirement: *id007
95
123
  description: Is the local client to the puppet_controller
96
124
  email: roman.heinrich@gmail.com
97
125
  executables:
@@ -110,6 +138,7 @@ files:
110
138
  - Rakefile
111
139
  - VERSION
112
140
  - bin/runpuppet
141
+ - lib/ext.rb
113
142
  - lib/runpuppet.rb
114
143
  - runpuppet.gemspec
115
144
  - test/helper.rb