Permalink
Browse files

Merge branch 'next'

  • Loading branch information...
2 parents ac428b9 + fc66e98 commit 01f610bb223b435dc52f491260af3ea002930102 @joshcooper joshcooper committed Apr 21, 2011
Showing with 3,597 additions and 808 deletions.
  1. +0 −115 README.strings
  2. +50 −0 acceptance/pending/ticket_3360_allow_duplicate_csr_with_option_set.rb
  3. 0 acceptance/pending/ticket_3360_reject_duplicate_csr_with_option_unset.rb
  4. +28 −0 acceptance/pending/ticket_5027_warn_on_dynamic_scope.rb
  5. +38 −0 acceptance/pending/ticket_6928_puppet_master_parse_fails.rb
  6. +39 −0 acceptance/tests/stages/ticket_4655_default_stage_for_classes.rb
  7. +51 −47 lib/puppet/application/cert.rb
  8. +255 −0 lib/puppet/application/device.rb
  9. +64 −23 lib/puppet/application/face_base.rb
  10. +10 −25 lib/puppet/application/kick.rb
  11. +12 −7 lib/puppet/defaults.rb
  12. +11 −17 lib/puppet/face/certificate.rb
  13. +2 −2 lib/puppet/face/facts.rb
  14. +26 −0 lib/puppet/face/help.rb
  15. +8 −7 lib/puppet/face/indirector.rb
  16. +0 −2 lib/puppet/face/node.rb
  17. +4 −1 lib/puppet/face/parser.rb
  18. +25 −0 lib/puppet/indirector/facts/network_device.rb
  19. +1 −1 lib/puppet/indirector/queue.rb
  20. +49 −2 lib/puppet/indirector/request.rb
  21. +66 −26 lib/puppet/interface.rb
  22. +113 −11 lib/puppet/interface/action.rb
  23. +41 −3 lib/puppet/interface/action_builder.rb
  24. +9 −0 lib/puppet/interface/action_manager.rb
  25. +39 −17 lib/puppet/interface/option.rb
  26. +33 −4 lib/puppet/interface/option_builder.rb
  27. +2 −2 lib/puppet/interface/option_manager.rb
  28. +4 −4 lib/puppet/network/http/handler.rb
  29. +23 −0 lib/puppet/node.rb
  30. +12 −8 lib/puppet/node/facts.rb
  31. +8 −11 lib/puppet/parser/compiler.rb
  32. +18 −1 lib/puppet/parser/resource.rb
  33. +5 −5 lib/puppet/parser/scope.rb
  34. +9 −0 lib/puppet/provider/cisco.rb
  35. +6 −12 lib/puppet/provider/interface/cisco.rb
  36. +16 −7 lib/puppet/provider/network_device.rb
  37. +1 −0 lib/puppet/provider/package/aptitude.rb
  38. +175 −0 lib/puppet/provider/package/pkgutil.rb
  39. +4 −10 lib/puppet/provider/vlan/cisco.rb
  40. +1 −0 lib/puppet/resource/catalog.rb
  41. +3 −1 lib/puppet/transaction.rb
  42. +28 −0 lib/puppet/type.rb
  43. +2 −0 lib/puppet/type/interface.rb
  44. +2 −0 lib/puppet/type/schedule.rb
  45. +2 −0 lib/puppet/type/vlan.rb
  46. +2 −1 lib/puppet/util/command_line.rb
  47. +17 −2 lib/puppet/util/network_device.rb
  48. +15 −17 lib/puppet/util/network_device/base.rb
  49. +10 −0 lib/puppet/util/network_device/cisco/device.rb
  50. +72 −0 lib/puppet/util/network_device/cisco/facts.rb
  51. +93 −0 lib/puppet/util/network_device/config.rb
  52. +1 −3 lib/puppet/util/network_device/transport.rb
  53. +4 −0 lib/puppet/util/network_device/transport/ssh.rb
  54. +1 −1 lib/puppet/util/queue.rb
  55. +2 −2 lib/puppet/util/queue/stomp.rb
  56. +2 −2 spec/integration/indirector/catalog/queue_spec.rb
  57. +56 −0 spec/integration/transaction_spec.rb
  58. +111 −0 spec/lib/matchers/json.rb
  59. +1 −0 spec/lib/puppet/face/basetest.rb
  60. +35 −0 spec/shared_behaviours/documentation_on_faces.rb
  61. +29 −25 spec/shared_behaviours/things_that_declare_options.rb
  62. +349 −0 spec/unit/application/device_spec.rb
  63. +96 −9 spec/unit/application/face_base_spec.rb
  64. +3 −4 spec/unit/application/indirection_base_spec.rb
  65. +7 −2 spec/unit/face/certificate_spec.rb
  66. +1 −5 spec/unit/face/facts_spec.rb
  67. +14 −10 spec/unit/face/help_spec.rb
  68. +1 −3 spec/unit/face/node_spec.rb
  69. +89 −0 spec/unit/indirector/facts/network_device_spec.rb
  70. +4 −4 spec/unit/indirector/queue_spec.rb
  71. +96 −0 spec/unit/indirector/request_spec.rb
  72. +5 −0 spec/unit/indirector/rest_spec.rb
  73. +159 −35 spec/unit/interface/action_builder_spec.rb
  74. +20 −0 spec/unit/interface/action_manager_spec.rb
  75. +223 −3 spec/unit/interface/action_spec.rb
  76. +0 −4 spec/unit/interface/face_collection_spec.rb
  77. +56 −10 spec/unit/interface/option_builder_spec.rb
  78. +25 −0 spec/unit/interface/option_spec.rb
  79. +16 −26 spec/unit/interface_spec.rb
  80. +7 −11 spec/unit/network/http/handler_spec.rb
  81. +30 −4 spec/unit/node/facts_spec.rb
  82. +64 −0 spec/unit/node_spec.rb
  83. +8 −46 spec/unit/parser/compiler_spec.rb
  84. +61 −3 spec/unit/parser/resource_spec.rb
  85. +5 −1 spec/unit/parser/scope_spec.rb
  86. +16 −0 spec/unit/provider/cisco_spec.rb
  87. +7 −13 spec/unit/provider/interface/cisco_spec.rb
  88. +13 −8 spec/unit/provider/network_device_spec.rb
  89. +182 −0 spec/unit/provider/package/pkgutil_spec.rb
  90. +7 −13 spec/unit/provider/vlan/cisco_spec.rb
  91. +1 −0 spec/unit/resource/catalog_spec.rb
  92. +18 −0 spec/unit/transaction_spec.rb
  93. +5 −0 spec/unit/type/interface_spec.rb
  94. +8 −0 spec/unit/type/schedule_spec.rb
  95. +5 −0 spec/unit/type/vlan_spec.rb
  96. +12 −125 spec/unit/util/network_device/cisco/device_spec.rb
  97. +63 −0 spec/unit/util/network_device/cisco/facts_spec.rb
  98. +102 −0 spec/unit/util/network_device/config_spec.rb
  99. +8 −0 spec/unit/util/network_device/transport/ssh_spec.rb
  100. +50 −0 spec/unit/util/network_device_spec.rb
  101. +10 −10 spec/unit/util/queue/stomp_spec.rb
  102. +5 −1 spec/watchr.rb
  103. +0 −34 test/lib/puppettest/railstesting.rb
View
@@ -1,115 +0,0 @@
-Puppet Strings
-=================
-A set of executables that provide complete CLI access to Puppet's
-core data types. They also provide String classes for
-each of the core data types, which are extensible via plugins.
-
-For instance, you can create a new action for catalogs at
-lib/puppet/string/catalog/$action.rb.
-
-This is a Puppet module and should work fine if you install it
-in Puppet's module path.
-
-**Note that this only works with Puppet 2.6.next (and thus will work
-with 2.6.5), because there is otherwise a bug in finding Puppet applications.
-You also have to either install the lib files into your Puppet libdir, or
-you need to add this lib directory to your RUBYLIB.**
-
-This is meant to be tested and iterated upon, with the plan that it will be
-merged into Puppet core once we're satisfied with it.
-
-Usage
------
-The general usage is:
-
- $ puppet <string> <verb> <name>
-
-So, e.g.:
-
- $ puppet facts find myhost.domain.com
- $ puppet node destroy myhost
-
-You can use it to list all known data types and the available terminus classes:
-
- $ puppet string list
- catalog : active_record, compiler, queue, rest, yaml
- certificate : ca, file, rest
- certificate_request : ca, file, rest
- certificate_revocation_list : ca, file, rest
- file_bucket_file : file, rest
- inventory : yaml
- key : ca, file
- node : active_record, exec, ldap, memory, plain, rest, yaml
- report : processor, rest, yaml
- resource : ral, rest
- resource_type : parser, rest
- status : local, rest
-
-But most interestingly, you can use it for two main purposes:
-
-* As a client for any Puppet REST server, such as catalogs, facts, reports, etc.
-* As a local CLI for any local Puppet data
-
-A simple case is looking at the local facts:
-
- $ puppet facts find localhost
-
-If you're on the server, you can look in that server's fact collection:
-
- $ puppet facts --mode master --vardir /tmp/foo --terminus yaml find localhost
-
-Note that we're setting both the vardir and the 'mode', which switches from the default 'agent' mode to server mode (requires a patch in my branch).
-
-If you'd prefer the data be outputted in json instead of yaml, well, you can do that, too:
-
- $ puppet find --mode master facts --vardir /tmp/foo --terminus yaml --format pson localhost
-
-To test using it as an endpoint for compiling and retrieving catalogs from a remote server, (from my commit), try this:
-
- # Terminal 1
- $ sbin/puppetmasterd --trace --confdir /tmp/foo --vardir /tmp/foo --debug --manifest ~/bin/test.pp --certname localhost --no-daemonize
-
- # Terminal 2
- $ sbin/puppetd --trace --debug --confdir /tmp/foo --vardir /tmp/foo --certname localhost --server localhost --test --report
-
- # Terminal 3, actual testing
- $ puppet catalog find localhost --certname localhost --server localhost --mode master --confdir /tmp/foo --vardir /tmp/foo --trace --terminus rest
-
-This compiles a test catalog (assuming that ~/bin/test.pp exists) and returns it. With the right auth setup, you can also get facts:
-
- $ puppet facts find localhost --certname localhost --server localhost --mode master --confdir /tmp/foo --vardir /tmp/foo --trace --terminus rest
-
-Or use IRB to do the same thing:
-
- $ irb
- >> require 'puppet/string'
- => true
- >> string = Puppet::String[:facts, '1.0.0']
- => #<Puppet::String::Facts:0x1024a1390 @format=:yaml>
- >> facts = string.find("myhost")
-
-Like I said, a prototype, but I'd love it if people would play it with some and make some recommendations.
-
-Extending
----------
-Like most parts of Puppet, these are easy to extend. Just drop a new action into a given string's directory. E.g.:
-
- $ cat lib/puppet/string/catalog/select.rb
- # Select and show a list of resources of a given type.
- Puppet::String.define(:catalog, '1.0.0') do
- action :select do
- invoke do |host,type|
- catalog = Puppet::Resource::Catalog.indirection.find(host)
-
- catalog.resources.reject { |res| res.type != type }.each { |res| puts res }
- end
- end
- end
- $ puppet catalog select localhost Class
- Class[main]
- Class[Settings]
- $
-
-Notice that this gets loaded automatically when you try to use it. So, if you have a simple command you've written, such as for cleaning up nodes or diffing catalogs, you an port it to this framework and it should fit cleanly.
-
-Also note that strings are versioned. These version numbers are interpreted according to Semantic Versioning (http://semver.org).
@@ -0,0 +1,50 @@
+test_name "#3360: Allow duplicate CSR when allow_duplicate_certs is on"
+
+agent_hostnames = agents.map {|a| a.to_s}
+
+# Kill running Puppet Master -- should not be running at this point
+step "Master: kill running Puppet Master"
+on master, "ps -U puppet | awk '/puppet/ { print \$1 }' | xargs kill || echo \"Puppet Master not running\""
+
+step "Master: Start Puppet Master"
+on master, puppet_master("--allow_duplicate_certs --certdnsnames=\"puppet:$(hostname -s):$(hostname -f)\" --verbose --noop")
+
+step "Generate a certificate request for the agent"
+on agents, "puppet certificate generate `hostname -f` --ca-location remote --server #{master}"
+
+step "Collect the original certs"
+on master, puppet_cert("--sign --all")
+original_certs = on master, puppet_cert("--list --all")
+
+old_certs = {}
+original_certs.stdout.each_line do |line|
+ if line =~ /^\+ (\S+) \((.+)\)$/
+ old_certs[$1] = $2
+ puts "old cert: #{$1} #{$2}"
+ end
+end
+
+step "Make another request with the same certname"
+on agents, "puppet certificate generate `hostname -f` --ca-location remote --server #{master}"
+
+step "Collect the new certs"
+
+on master, puppet_cert("--sign --all")
+new_cert_list = on master, puppet_cert("--list --all")
+
+new_certs = {}
+new_cert_list.stdout.each_line do |line|
+ if line =~ /^\+ (\S+) \((.+)\)$/
+ new_certs[$1] = $2
+ puts "new cert: #{$1} #{$2}"
+ end
+end
+
+step "Verify the certs have changed"
+# using the agent name as the key may cause errors;
+# agent name from cfg file is likely to have short name
+# where certs might be signed with long names.
+old_certs.each_key { |key|
+ next if key.include? master # skip the masters cert, only care about agents
+ fail_test("#{key} does not have a new signed certificate") if old_certs[key] == new_certs[key]
+}
@@ -0,0 +1,28 @@
+test_name "#5027: Issue warnings when using dynamic scope"
+
+step "Apply dynamic scoping manifest on agents"
+apply_manifest_on agents, %q{
+ $foo = 'foo_value'
+
+ class a {
+ $bar = 'bar_value'
+
+ include b
+ }
+
+ class b inherits c {
+ notify { $baz: } # should not generate a warning -- inherited from class c
+ notify { $bar: } # should generate a warning -- uses dynamic scoping
+ notify { $foo: } # should not generate a warning -- comes from top scope
+ }
+
+ class c {
+ $baz = 'baz_value'
+ }
+
+ include a
+}
+
+step "Verify deprecation warning"
+fail_test "Deprecation warning not issued" unless
+ stdout.include? 'warning: Dynamic lookup of $bar will not be supported in future versions. Use a fully-qualified variable name or parameterized classes.'
@@ -0,0 +1,38 @@
+test_name "#6928: Puppet --parseonly should return deprication message"
+
+# Create good and bad formatted manifests
+step "Master: create valid, invalid formatted manifests"
+create_remote_file(master, '/tmp/good.pp', %w{notify{good:}} )
+create_remote_file(master, '/tmp/bad.pp', 'notify{bad:')
+
+step "Master: use --parseonly on an invalid manifest, should return 1 and issue deprecation warning"
+on master, puppet_master( %w{--parseonly /tmp/bad.pp} ), :acceptable_exit_codes => [ 1 ]
+ fail_test "Deprecation warning not issued for --parseonly" unless
+ stdout.include? '--parseonly has been removed. Please use \'puppet parser validate <manifest>\''
+
+step "Agents: create valid, invalid formatted manifests"
+agents.each do |host|
+ create_remote_file(host, '/tmp/good.pp', %w{notify{good:}} )
+ create_remote_file(host, '/tmp/bad.pp', 'notify{bad:')
+end
+
+step "Agents: use --parseonly on an invalid manifest, should return 1 and issue deprecation warning"
+agents.each do |host|
+ on(host, "puppet --parseonly /tmp/bad.pp}", :acceptable_exit_codes => [ 1 ]) do
+ fail_test "Deprecation warning not issued for --parseonly" unless
+ stdout.include? '--parseonly has been removed. Please use \'puppet parser validate <manifest>\''
+ end
+end
+
+step "Test Face for ‘parser validate’ with good manifest -- should pass"
+agents.each do |host|
+ on(host, "puppet parser validate /tmp/good.pp", :acceptable_exit_codes => [ 0 ])
+end
+
+step "Test Face for ‘parser validate’ with bad manifest -- should fail"
+agents.each do |host|
+ on(host, "puppet parser validate /tmp/bad.pp", :acceptable_exit_codes => [ 1 ]) do
+ fail_test "Bad manifest detection failed" unless
+ stderr.include? 'Could not run: Could not parse for environment production'
+ end
+end
@@ -0,0 +1,39 @@
+test_name "#4655: Allow setting the default stage for parameterized classes"
+
+temp_file_name = "/tmp/4655-stage-in-parameterized-class.#{$$}"
+test_manifest = <<HERE
+stage { one: before => Stage[two] }
+stage { two: before => Stage[three] }
+stage { three: before => Stage[main] }
+
+class in_one {
+ exec { "echo 'in_one' > #{temp_file_name}":
+ path => '/usr/bin:/bin',
+ }
+}
+class { in_one: stage => "one" }
+
+class in_two( $stage=two ){
+ exec { "echo 'in_two' >> #{temp_file_name}":
+ path => '/usr/bin:/bin',
+ }
+}
+class { in_two: }
+
+class in_three {
+ exec { "echo 'in_three' >> #{temp_file_name}":
+ path => '/usr/bin:/bin',
+ }
+}
+class { "in_three": stage => "three" }
+HERE
+
+expected_results = "in_one
+in_two
+in_three
+"
+apply_manifest_on agents, test_manifest
+
+on(agents, "cat #{temp_file_name}").each do |result|
+ assert_equal(expected_results, "#{result.stdout}", "Unexpected result for host '#{result.host}'")
+end
Oops, something went wrong.

0 comments on commit 01f610b

Please sign in to comment.