judy 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2103054b846a86a52e939427f863a22c88517a07
4
+ data.tar.gz: ba997a028ad4cdc48cff9b8ad37de77eb0341cee
5
+ SHA512:
6
+ metadata.gz: e52f389b34ab42ab535bc6d48b347657ed79c9ddc5f23652f8cf4e441f4acb338e35412a2b1fc6cf5afdcdb77cff5fd9ae338acc933ed270c525269ddf43ca0f
7
+ data.tar.gz: f5940a7348c2e889a079821d61d6040495cc060e7d42f3171be37ad3e88eda9204ce539693766616f102db72522199c395da79e1e97fd38aa9197e156fe16aca
@@ -0,0 +1,12 @@
1
+ *.gem
2
+ *.rbc
3
+ *~
4
+ *.swp
5
+ *.swo
6
+ .bundle
7
+ .rvmrc
8
+ Gemfile.lock
9
+ coverage
10
+ doc/*
11
+ log/*
12
+ pkg/*
@@ -0,0 +1,9 @@
1
+ nguage: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+ - 1.9.2
6
+ - 1.8.7
7
+ matrix:
8
+ allow_failures:
9
+ - rvm: 1.8.7
@@ -0,0 +1,2 @@
1
+ ## 0.0.1
2
+ Initial release.
@@ -0,0 +1,28 @@
1
+ # Contributing
2
+
3
+ 1. Fork it
4
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
5
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
6
+ 4. Push to the branch (`git push origin my-new-feature`)
7
+ 5. Create new Pull Request
8
+
9
+ ## Development Environment
10
+
11
+ To add a feature, fix a bug, or to run a development build of Judy
12
+ on your machine, clone down the repo and run:
13
+
14
+ $ bundle
15
+
16
+ You can then execute judy:
17
+
18
+ $ bundle exec judy [command]
19
+
20
+ As well as run the tests:
21
+
22
+ $ bundle exec rspec
23
+
24
+ To install the gem on your system from source:
25
+
26
+ $ bundle exec rake install
27
+
28
+ If you need help with your environment, feel free to open an issue.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Peter Souter
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,65 @@
1
+ # Judy
2
+
3
+ [![Judy](http://farm4.staticflickr.com/3599/5766637273_0ea32a43c1.jpg)](http://www.flickr.com/photos/emry/5766637273/ "Judy by Steve and Sara, on Flickr")
4
+
5
+ Judy is an all-in-one toolbox for Puppet. It's a mixture of Rake tasks to add to a pre-existing project and a CLI to allow you to run common puppet tasks through the command-line.
6
+
7
+ ### Current Puppet tools used by Judy
8
+
9
+ * [puppet-lint](https://github.com/rodjek/puppet-lint)
10
+ * [puppet-rspec](https://github.com/rodjek/rspec-puppet) (_WIP_)
11
+
12
+ ## Rake-tasks
13
+
14
+ Some pre-made rake tasks are avaliable in the gem, to run puppet-lint on all `.pp` files, and to run puppet parse all `.pp` files
15
+
16
+ Just add
17
+
18
+ `gem "judy"`
19
+
20
+ To your Gemfile and then add
21
+
22
+ `require "judy/tasks"`
23
+
24
+ Now when you run `bundle exec rake -T` in your app, you should see the judy tasks:
25
+
26
+ ```
27
+ rake lint # Judy: Run puppet-lint
28
+ rake parse # Judy: Parse puppet files
29
+ ```
30
+
31
+ ## Commands
32
+
33
+ ### Parse
34
+
35
+ On an invidiual file:
36
+
37
+ ```
38
+ $ judy parse init.pp
39
+ Parsing with Puppet Version: 3.3.0
40
+ No error found on init.pp
41
+ Parse complete!
42
+ ```
43
+
44
+ Or on a directory:
45
+
46
+ ```
47
+ $ judy parse /etc/puppet/modules/
48
+ Parsing with Puppet Version: 3.3.0
49
+ Loading directory, looking for all puppet files...
50
+ No error found on /etc/puppet/modules/nginx/init.pp
51
+ Parser Error! File: /etc/puppet/modules/nginx/service.pp - Error: Syntax error at ','; expected '}' at /etc/puppet/modules/nginx/service.pp:13
52
+ Parse complete!
53
+ ```
54
+
55
+ ### Help
56
+
57
+ For a complete overview of all of the available commands, run:
58
+
59
+ $ judy help
60
+
61
+ Feel free to open issues in case of bugs or improvments.
62
+
63
+ ## Contributing
64
+
65
+ See the [contributing guide](CONTRIBUTING.md). Pull-requests welcome!
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "judy/tasks"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ Signal.trap("INT") { exit 1 }
4
+
5
+ require "judy"
6
+
7
+ Judy::CLI.start(ARGV)
@@ -0,0 +1,5 @@
1
+ require "judy/cli"
2
+ require "judy/version"
3
+
4
+ module Judy
5
+ end
@@ -0,0 +1,44 @@
1
+ require 'thor'
2
+
3
+ module Judy
4
+ autoload :Middleware, "judy/middleware"
5
+
6
+ class CLI < Thor
7
+ include Thor::Actions
8
+ ENV['THOR_COLUMNS'] = '120'
9
+
10
+ !check_unknown_options
11
+
12
+ map "--version" => :version,
13
+ "-v" => :version
14
+
15
+ desc "parse", "Use Puppets native parser to check given files"
16
+ long_desc "This uses puppets native parser to check given puppet files, you
17
+ can give either a directory or an individual puppet file."
18
+ def parse(path)
19
+ Middleware.sequence_parse.call({"parse_path" => path})
20
+ end
21
+
22
+ desc "lint", "Use puppet-lint to check puppet for lint issues"
23
+ long_desc "This uses puppet-lint to check given puppet files, you
24
+ can give either a directory or an individual puppet file."
25
+ def lint(path)
26
+ Middleware.sequence_lint.call({"lint_path" => path})
27
+ end
28
+
29
+ desc "help [COMMAND]", "Describe commands or a specific command"
30
+ def help(meth=nil)
31
+ super
32
+ if !meth
33
+ say "To learn more or to contribute, please see github.com/petems/judy"
34
+ end
35
+ end
36
+
37
+ desc "version", "Show version"
38
+ def version
39
+ say "Judy #{Judy::VERSION}"
40
+ end
41
+
42
+ end
43
+ end
44
+
@@ -0,0 +1,22 @@
1
+ require "middleware"
2
+
3
+ module Judy
4
+ module Middleware
5
+ autoload :Base, "judy/middleware/base"
6
+ autoload :Linter, "judy/middleware/linter"
7
+ autoload :Parser, "judy/middleware/parser"
8
+
9
+ def self.sequence_parse
10
+ ::Middleware::Builder.new do
11
+ use Parser
12
+ end
13
+ end
14
+
15
+ def self.sequence_lint
16
+ ::Middleware::Builder.new do
17
+ use Linter
18
+ end
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,28 @@
1
+ module Judy
2
+ module Middleware
3
+ # A base middleware class to initalize.
4
+ class Base
5
+ # Some colors for making things pretty.
6
+ CLEAR = "\e[0m"
7
+ RED = "\e[31m"
8
+ GREEN = "\e[32m"
9
+ YELLOW = "\e[33m"
10
+
11
+ # We want access to all of the fun thor cli helper methods,
12
+ # like say, yes?, ask, etc.
13
+ include Thor::Shell
14
+
15
+ def initialize(app)
16
+ @app = app
17
+ # This resets the color to "clear" on the user's terminal.
18
+ say "", :clear, false
19
+ end
20
+
21
+ def call(env)
22
+ @app.call(env)
23
+ end
24
+
25
+ end
26
+ end
27
+ end
28
+
@@ -0,0 +1,48 @@
1
+ require 'puppet-lint'
2
+
3
+ module Judy
4
+ module Middleware
5
+ class Linter < Base
6
+ def call(env)
7
+
8
+ def run_lint(puppet_file)
9
+ PuppetLint.configuration.with_filename = true
10
+ PuppetLint.configuration.fail_on_warnings = true
11
+ PuppetLint.configuration.send("disable_autoloader_layout")
12
+ PuppetLint.configuration.send("disable_80chars")
13
+
14
+ # Not the greatest way of doing it
15
+ # Can be improved when refactor PR merged :)
16
+ # https://github.com/rodjek/puppet-lint/pull/227
17
+ linter = PuppetLint.new
18
+ linter.file = puppet_file
19
+ linter.run
20
+ end
21
+
22
+ if File.directory?("#{env['lint_path']}")
23
+ say "Loading directory, looking for all puppet files..."
24
+ puppet_file_list = Dir["#{env['lint_path']}/**/*.pp"]
25
+ if puppet_file_list.empty?
26
+ say "No .pp files found in the directory given! Exiting", :red
27
+ exit 0
28
+ end
29
+ say "Found #{puppet_file_list.size} puppet files"
30
+ puppet_file_list.each do |puppet_file|
31
+ say "Lint for #{puppet_file}"
32
+ run_lint(File.expand_path(puppet_file))
33
+ end
34
+ else
35
+ if File.extname(env['lint_path']) == '.pp'
36
+ run_lint env['lint_path']
37
+ else
38
+ say "#{env['lint_path']} is not a puppet file!", :red
39
+ exit 0
40
+ end
41
+ end
42
+
43
+ say 'Lint checks complete'
44
+ @app.call(env)
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,46 @@
1
+ require 'puppet'
2
+
3
+ module Judy
4
+ module Middleware
5
+ class Parser < Base
6
+ def call(env)
7
+
8
+ def parse_file(puppet_file, index='')
9
+ begin
10
+ parser = Puppet::Parser::Parser.new("JudyParser#{index}")
11
+ parser.import(puppet_file)
12
+ say "No error found on #{puppet_file}", :green
13
+ rescue Puppet::ParseError => e
14
+ say "Parser Error! File: #{puppet_file} - Error: #{e}", :red
15
+ end
16
+ end
17
+
18
+ Puppet.initialize_settings unless Puppet.settings.app_defaults_initialized?
19
+ puts "Parsing with Puppet Version: #{Puppet.version}"
20
+
21
+ ## To Do: Clean up this logic
22
+ if File.directory?("#{env['parse_path']}")
23
+ say "Loading directory, looking for all puppet files..."
24
+ puppet_file_list = Dir["#{env['parse_path']}/**/*.pp"]
25
+ if puppet_file_list.empty?
26
+ say "No .pp files found in the directory given! Exiting", :red
27
+ exit 0
28
+ end
29
+ puppet_file_list.each_with_index do |puppet_file, index|
30
+ parse_file(File.expand_path(puppet_file), index)
31
+ end
32
+ else
33
+ if File.extname(env['parse_path']) == '.pp'
34
+ parse_file env['parse_path']
35
+ else
36
+ say "#{env['parse_path']} is not a puppet file!", :red
37
+ exit 0
38
+ end
39
+ end
40
+
41
+ say "Parse complete!"
42
+ @app.call(env)
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,71 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+ require 'highline/import'
4
+ require 'ruby-progressbar'
5
+ require 'puppet'
6
+ require 'puppet-lint'
7
+
8
+ desc "Judy: Run puppet-lint"
9
+ task :lint do
10
+ PuppetLint.configuration.with_filename = true
11
+ PuppetLint.configuration.fail_on_warnings = true
12
+ PuppetLint.configuration.send("disable_autoloader_layout") unless ENV['LINT_AUTOLAYOUT']
13
+ PuppetLint.configuration.send("disable_80chars") unless ENV['ENABLE_80CHARS']
14
+
15
+ say "Running lint checks"
16
+
17
+ linter = PuppetLint.new
18
+ puppet_file_list = FileList['**/*.pp']
19
+
20
+ puppet_file_list.each do |puppet_file|
21
+ linter.file = puppet_file
22
+ linter.run
23
+ end
24
+
25
+ fail "Lint Errors Found!" if linter.errors? || linter.warnings?
26
+ say 'Lint checks complete'
27
+ end
28
+
29
+ desc "Judy: Parse puppet files"
30
+ task :parse do
31
+ puppet_file_list = FileList['**/*.pp']
32
+ successes = 0
33
+ failures = 0
34
+ error_string = ""
35
+
36
+ say "Total Puppetfiles found #{puppet_file_list.length}"
37
+
38
+ if Integer(Puppet.version.split('.').first) >= 3
39
+ Puppet.initialize_settings
40
+ end
41
+
42
+ puts "Parsing with Puppet Version: #{Puppet.version}"
43
+
44
+ parse_progress = ProgressBar.create(:title => "Parsing", :format => '%a <%B> %p%% %t',
45
+ :starting_at => 0, :total => puppet_file_list.length)
46
+
47
+ puppet_file_list.each_with_index do |puppet_file, index|
48
+
49
+ parse_progress.increment
50
+
51
+ begin
52
+ parser = Puppet::Parser::Parser.new("rake-parse-#{index}")
53
+ parser.import("#{File.expand_path(puppet_file)}")
54
+ successes += 1
55
+ rescue Puppet::ParseError => e
56
+ error_string += "Parse Error on #{puppet_file}: #{e.message}\n"
57
+ failures += 1
58
+ end
59
+ end
60
+
61
+ total_manifests = successes + failures
62
+
63
+ say "#{total_manifests} files total."
64
+ say "#{successes} files succeeded."
65
+ say "#{failures} files failed."
66
+
67
+ if failures > 0
68
+ say "#{error_string}"
69
+ fail "#{failures} puppet files failed syntax check."
70
+ end
71
+ end
@@ -0,0 +1,3 @@
1
+ module Judy
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,37 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'judy/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "judy"
8
+ gem.version = Judy::VERSION
9
+ gem.authors = ["Peter Souter"]
10
+ gem.email = ["p.morsou@gmail.com"]
11
+ gem.description = %q{A command line tool for uploading to dropbox.}
12
+ gem.summary = %q{Judy is a CLI for Dropbox, for downloading and uploading files.}
13
+ gem.homepage = "https://github.com/petems/judy"
14
+ gem.license = 'MIT'
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.add_dependency "thor", "~> 0.18.1"
22
+ gem.add_dependency "middleware" , "~> 0.1.0"
23
+
24
+ gem.add_dependency "puppet", "~> 3"
25
+ gem.add_dependency "puppet-lint"
26
+ gem.add_dependency "parallel_tests"
27
+ gem.add_dependency "highline"
28
+ gem.add_dependency "ruby-progressbar"
29
+
30
+ gem.add_development_dependency "rake", "~> 10.1.0"
31
+ gem.add_development_dependency "rspec-core", "~> 2.13.0"
32
+ gem.add_development_dependency "rspec-expectations", "~> 2.13.0"
33
+ gem.add_development_dependency "rspec-mocks", "~> 2.13.0"
34
+ gem.add_development_dependency "webmock", "~> 1.11.0"
35
+ gem.add_development_dependency "simplecov", "~> 0.7.1"
36
+
37
+ end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe Judy::CLI do
4
+ include_context "spec"
5
+
6
+ let(:lint_fixtures_dir){ "#{fixtures}/lint"}
7
+
8
+ describe "parse" do
9
+ it "shows error message when file is not a .pp" do
10
+
11
+ expect { @cli.lint("#{lint_fixtures_dir}/no_puppet_here/notpuppet.tmp") }.to raise_error(SystemExit)
12
+
13
+ expect($stdout.string).to include "notpuppet.tmp is not a puppet file!"
14
+ end
15
+
16
+ it "shows error message when no .pp files found in directory" do
17
+
18
+ expect { @cli.lint("#{lint_fixtures_dir}/no_puppet_here/") }.to raise_error(SystemExit)
19
+
20
+ expect($stdout.string).to eql <<-eos
21
+ Loading directory, looking for all puppet files...
22
+ No .pp files found in the directory given! Exiting
23
+ eos
24
+ end
25
+
26
+ it "shows no error with a happy file" do
27
+
28
+ @cli.lint("#{lint_fixtures_dir}/balancer.pp")
29
+
30
+ expect($stdout.string).to include "Lint checks complete"
31
+ end
32
+
33
+ it "shows lint errors with a sad file" do
34
+
35
+ @cli.lint("#{lint_fixtures_dir}/balancer_needs_lint.pp")
36
+
37
+ expect($stdout.string).to include "ERROR: single quoted string containing a variable found on line 48",
38
+ "ERROR: two-space soft tabs not used on line 79"
39
+ end
40
+
41
+ it "can be run against directories" do
42
+ @cli.lint("#{lint_fixtures_dir}/")
43
+
44
+ expect($stdout.string).to include "Found 2 puppet files", "ERROR: single quoted string containing a variable found on line 48",
45
+ "ERROR: two-space soft tabs not used on line 79"
46
+ end
47
+ end
48
+ end
49
+
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe Judy::CLI do
4
+ include_context "spec"
5
+
6
+ let(:parse_fixtures_dir){ "#{fixtures}/parse"}
7
+
8
+ describe "parse" do
9
+ it "shows error message when file is not a .pp" do
10
+
11
+ expect { @cli.parse("#{parse_fixtures_dir}/no_puppet_here/notpuppet.tmp") }.to raise_error(SystemExit)
12
+
13
+ expect($stdout.string).to include "notpuppet.tmp is not a puppet file!"
14
+ end
15
+
16
+ it "shows error message when no .pp files found in directory" do
17
+
18
+ expect { @cli.parse("#{parse_fixtures_dir}/no_puppet_here/") }.to raise_error(SystemExit)
19
+
20
+ expect($stdout.string).to include "Parsing with Puppet Version: ", "Loading directory, looking for all puppet files...",
21
+ "No .pp files found in the directory given! Exiting"
22
+ end
23
+
24
+ it "shows no error with a happy file" do
25
+
26
+ @cli.parse("#{parse_fixtures_dir}/nginx.pp")
27
+
28
+ expect($stdout.string).to include "Parsing with Puppet Version",
29
+ "No error found on #{parse_fixtures_dir}/nginx.pp", "Parse complete!"
30
+ end
31
+
32
+ it "shows an error with a sad file" do
33
+
34
+ @cli.parse("#{parse_fixtures_dir}/nginx_fail.pp")
35
+
36
+ expect($stdout.string).to include "Parsing with Puppet Version",
37
+ "Parser Error! File: #{parse_fixtures_dir}/nginx_fail.pp - Error: Syntax error at ','; expected '}' at #{parse_fixtures_dir}/nginx_fail.pp:9",
38
+ "Parse complete!"
39
+ end
40
+
41
+ it "can be run against directories" do
42
+ @cli.parse("#{parse_fixtures_dir}/")
43
+
44
+ expect($stdout.string).to include "Parsing with Puppet Version",
45
+ "Loading directory, looking for all puppet files...",
46
+ "No error found on #{parse_fixtures_dir}/nginx.pp",
47
+ "Parser Error! File: #{parse_fixtures_dir}/nginx_fail.pp - Error: Syntax error at ','; expected '}' at #{parse_fixtures_dir}/nginx_fail.pp:9",
48
+ "Parse complete!"
49
+ end
50
+ end
51
+ end
52
+
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Judy::CLI do
4
+ include_context "spec"
5
+
6
+ describe "version" do
7
+ it "shows the correct version" do
8
+
9
+ @cli.options = @cli.options.merge(:version => true)
10
+ @cli.version
11
+
12
+ expect($stdout.string.chomp).to eq("Judy #{Judy::VERSION.to_s}")
13
+ end
14
+ end
15
+ end
16
+
@@ -0,0 +1,80 @@
1
+ # == Define Resource Type: apache::balancer
2
+ #
3
+ # This type will create an apache balancer cluster file inside the conf.d
4
+ # directory. Each balancer cluster needs one or more balancer members (that can
5
+ # be declared with the apache::balancermember defined resource type). Using
6
+ # storeconfigs, you can export the apache::balancermember resources on all
7
+ # balancer members, and then collect them on a single apache load balancer
8
+ # server.
9
+ #
10
+ # === Requirement/Dependencies:
11
+ #
12
+ # Currently requires the puppetlabs/concat module on the Puppet Forge and uses
13
+ # storeconfigs on the Puppet Master to export/collect resources from all
14
+ # balancer members.
15
+ #
16
+ # === Parameters
17
+ #
18
+ # [*name*]
19
+ # The namevar of the defined resource type is the balancer clusters name.
20
+ # This name is also used in the name of the conf.d file
21
+ #
22
+ # [*proxy_set*]
23
+ # Hash, default empty. If given, each key-value pair will be used as a ProxySet
24
+ # line in the configuration.
25
+ #
26
+ # [*collect_exported*]
27
+ # Boolean, default 'true'. True means 'collect exported @@balancermember
28
+ # resources' (for the case when every balancermember node exports itself),
29
+ # false means 'rely on the existing declared balancermember resources' (for the
30
+ # case when you know the full set of balancermembers in advance and use
31
+ # apache::balancermember with array arguments, which allows you to deploy
32
+ # everything in 1 run)
33
+ #
34
+ #
35
+ # === Examples
36
+ #
37
+ # Exporting the resource for a balancer member:
38
+ #
39
+ # apache::balancer { 'puppet00': }
40
+ #
41
+ define apache::balancer (
42
+ $proxy_set = {},
43
+ $collect_exported = true,
44
+ ) {
45
+ include concat::setup
46
+ include apache::mod::proxy_balancer
47
+
48
+ $target = "${::apache::params::confd_dir}/balancer_${name}.conf"
49
+
50
+ concat { $target:
51
+ owner => '0',
52
+ group => '0',
53
+ mode => '0644',
54
+ notify => Service['httpd'],
55
+ }
56
+
57
+ concat::fragment { "00-${name}-header":
58
+ target => $target,
59
+ order => '01',
60
+ content => "<Proxy balancer://${name}>\n",
61
+ }
62
+
63
+ if $collect_exported {
64
+ Apache::Balancermember <<| balancer_cluster == $name |>>
65
+ }
66
+ # else: the resources have been created and they introduced their
67
+ # concat fragments. We don't have to do anything about them.
68
+
69
+ concat::fragment { "01-${name}-proxyset":
70
+ target => $target,
71
+ order => '19',
72
+ content => inline_template("<% proxy_set.each do |key, value| %> Proxyset <%= key %>=<%= value %>\n<% end %>"),
73
+ }
74
+
75
+ concat::fragment { "01-${name}-footer":
76
+ target => $target,
77
+ order => '20',
78
+ content => "</Proxy>\n",
79
+ }
80
+ }
@@ -0,0 +1,80 @@
1
+ # == Define Resource Type: apache::balancer
2
+ #
3
+ # This type will create an apache balancer cluster file inside the conf.d
4
+ # directory. Each balancer cluster needs one or more balancer members (that can
5
+ # be declared with the apache::balancermember defined resource type). Using
6
+ # storeconfigs, you can export the apache::balancermember resources on all
7
+ # balancer members, and then collect them on a single apache load balancer
8
+ # server.
9
+ #
10
+ # === Requirement/Dependencies:
11
+ #
12
+ # Currently requires the puppetlabs/concat module on the Puppet Forge and uses
13
+ # storeconfigs on the Puppet Master to export/collect resources from all
14
+ # balancer members.
15
+ #
16
+ # === Parameters
17
+ #
18
+ # [*name*]
19
+ # The namevar of the defined resource type is the balancer clusters name.
20
+ # This name is also used in the name of the conf.d file
21
+ #
22
+ # [*proxy_set*]
23
+ # Hash, default empty. If given, each key-value pair will be used as a ProxySet
24
+ # line in the configuration.
25
+ #
26
+ # [*collect_exported*]
27
+ # Boolean, default 'true'. True means 'collect exported @@balancermember
28
+ # resources' (for the case when every balancermember node exports itself),
29
+ # false means 'rely on the existing declared balancermember resources' (for the
30
+ # case when you know the full set of balancermembers in advance and use
31
+ # apache::balancermember with array arguments, which allows you to deploy
32
+ # everything in 1 run)
33
+ #
34
+ #
35
+ # === Examples
36
+ #
37
+ # Exporting the resource for a balancer member:
38
+ #
39
+ # apache::balancer { 'puppet00': }
40
+ #
41
+ define apache::balancer (
42
+ $proxy_set = {},
43
+ $collect_exported = true,
44
+ ) {
45
+ include concat::setup
46
+ include apache::mod::proxy_balancer
47
+
48
+ $target = '${::apache::params::confd_dir}/balancer_${name}.conf'
49
+
50
+ concat { $target:
51
+ owner => '0',
52
+ group => '0',
53
+ mode => '0644',
54
+ notify => Service['httpd'],
55
+ }
56
+
57
+ concat::fragment { '00-${name}-header':
58
+ target => $target,
59
+ order => '01',
60
+ content => '<Proxy balancer://${name}>\n',
61
+ }
62
+
63
+ if $collect_exported {
64
+ Apache::Balancermember <<| balancer_cluster == $name |>>
65
+ }
66
+ # else: the resources have been created and they introduced their
67
+ # concat fragments. We don't have to do anything about them.
68
+
69
+ concat::fragment { '01-${name}-proxyset':
70
+ target => $target,
71
+ order => '19',
72
+ content => inline_template('<% proxy_set.each do |key, value| %> Proxyset <%= key %>=<%= value %>\n<% end %>'),
73
+ }
74
+
75
+ concat::fragment { '01-${name}-footer':
76
+ target => $target,
77
+ order => '20',
78
+ content => '</Proxy>\n',
79
+ }
80
+ }
@@ -0,0 +1 @@
1
+ # Not a puppet file! :D
@@ -0,0 +1,11 @@
1
+ class nginx::service(
2
+ $configtest_enable = $nginx::params::nx_configtest_enable,
3
+ $service_restart = $nginx::params::nx_service_restart
4
+ ) {
5
+ exec { 'rebuild-nginx-vhosts':
6
+ command => "/bin/cat ${nginx::params::nx_temp_dir}/nginx.d/* > ${nginx::params::nx_conf_dir}/conf.d/vhost_autogen.conf",
7
+ refreshonly => true,
8
+ unless => "/usr/bin/test ! -f ${nginx::params::nx_temp_dir}/nginx.d/*",
9
+ subscribe => File["${nginx::params::nx_temp_dir}/nginx.d"],
10
+ }
11
+ }
@@ -0,0 +1,13 @@
1
+ class nginx::service(
2
+ $configtest_enable = $nginx::params::nx_configtest_enable,
3
+ $service_restart = $nginx::params::nx_service_restart
4
+ ) {
5
+ exec { 'rebuild-nginx-vhosts':
6
+ command => "/bin/cat ${nginx::params::nx_temp_dir}/nginx.d/* > ${nginx::params::nx_conf_dir}/conf.d/vhost_autogen.conf",
7
+ refreshonly => true,
8
+ # Errors!
9
+ ,,,{{{{,,,,$$$}}}}
10
+ unless => "/usr/bin/test ! -f ${nginx::params::nx_temp_dir}/nginx.d/*",
11
+ subscribe => File["${nginx::params::nx_temp_dir}/nginx.d"],
12
+ }
13
+ }
@@ -0,0 +1 @@
1
+ # Not a puppet file! :D
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Judy::Middleware::Base do
4
+ include_context "spec"
5
+
6
+ let(:klass) { described_class }
7
+
8
+ describe ".initialize" do
9
+ it "prints a clear line" do
10
+ $stdout.should_receive(:print).with("")
11
+ klass.new({})
12
+ end
13
+ end
14
+
15
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ shared_context "spec" do
4
+
5
+ before(:each) do
6
+ $stdout.sync = true
7
+ $stderr.sync = true
8
+
9
+ @cli = Judy::CLI.new
10
+
11
+ # Keep track of the old stderr / out
12
+ @orig_stderr = $stderr
13
+ @orig_stdout = $stdout
14
+
15
+ # Make them strings so we can manipulate and compare.
16
+ $stderr = StringIO.new
17
+ $stdout = StringIO.new
18
+ end
19
+
20
+ after(:each) do
21
+ # Reassign the stderr / out so rspec can have it back.
22
+ $stderr = @orig_stderr
23
+ $stdout = @orig_stdout
24
+ end
25
+
26
+ end
@@ -0,0 +1,18 @@
1
+ require 'judy'
2
+ require 'shared/environment'
3
+
4
+ require 'simplecov'
5
+ SimpleCov.start
6
+
7
+ RSpec.configure do |config|
8
+ config.color_enabled = true
9
+ config.order = :random
10
+ end
11
+
12
+ def project_path
13
+ File.expand_path("../..", __FILE__)
14
+ end
15
+
16
+ def fixtures
17
+ "#{project_path}/spec/fixtures"
18
+ end
metadata ADDED
@@ -0,0 +1,269 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: judy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Peter Souter
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.18.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.18.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.1.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: puppet
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '3'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: puppet-lint
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: parallel_tests
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: highline
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: ruby-progressbar
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 10.1.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: 10.1.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec-core
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: 2.13.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ version: 2.13.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: rspec-expectations
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ~>
144
+ - !ruby/object:Gem::Version
145
+ version: 2.13.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ~>
151
+ - !ruby/object:Gem::Version
152
+ version: 2.13.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: rspec-mocks
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ~>
158
+ - !ruby/object:Gem::Version
159
+ version: 2.13.0
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ~>
165
+ - !ruby/object:Gem::Version
166
+ version: 2.13.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: webmock
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ~>
172
+ - !ruby/object:Gem::Version
173
+ version: 1.11.0
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ~>
179
+ - !ruby/object:Gem::Version
180
+ version: 1.11.0
181
+ - !ruby/object:Gem::Dependency
182
+ name: simplecov
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ~>
186
+ - !ruby/object:Gem::Version
187
+ version: 0.7.1
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ~>
193
+ - !ruby/object:Gem::Version
194
+ version: 0.7.1
195
+ description: A command line tool for uploading to dropbox.
196
+ email:
197
+ - p.morsou@gmail.com
198
+ executables:
199
+ - judy
200
+ extensions: []
201
+ extra_rdoc_files: []
202
+ files:
203
+ - .gitignore
204
+ - .travis.yml
205
+ - CHANGELOG.md
206
+ - CONTRIBUTING.md
207
+ - Gemfile
208
+ - LICENSE.md
209
+ - README.md
210
+ - Rakefile
211
+ - bin/judy
212
+ - lib/judy.rb
213
+ - lib/judy/cli.rb
214
+ - lib/judy/middleware.rb
215
+ - lib/judy/middleware/base.rb
216
+ - lib/judy/middleware/linter.rb
217
+ - lib/judy/middleware/parser.rb
218
+ - lib/judy/tasks.rb
219
+ - lib/judy/version.rb
220
+ - slipsquare.gemspec
221
+ - spec/cli/lint_spec.rb
222
+ - spec/cli/parse_spec.rb
223
+ - spec/cli/version_cli_spec.rb
224
+ - spec/fixtures/lint/balancer.pp
225
+ - spec/fixtures/lint/balancer_needs_lint.pp
226
+ - spec/fixtures/lint/no_puppet_here/notpuppet.tmp
227
+ - spec/fixtures/parse/nginx.pp
228
+ - spec/fixtures/parse/nginx_fail.pp
229
+ - spec/fixtures/parse/no_puppet_here/notpuppet.tmp
230
+ - spec/middleware/base_spec.rb
231
+ - spec/shared/environment.rb
232
+ - spec/spec_helper.rb
233
+ homepage: https://github.com/petems/judy
234
+ licenses:
235
+ - MIT
236
+ metadata: {}
237
+ post_install_message:
238
+ rdoc_options: []
239
+ require_paths:
240
+ - lib
241
+ required_ruby_version: !ruby/object:Gem::Requirement
242
+ requirements:
243
+ - - '>='
244
+ - !ruby/object:Gem::Version
245
+ version: '0'
246
+ required_rubygems_version: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - '>='
249
+ - !ruby/object:Gem::Version
250
+ version: '0'
251
+ requirements: []
252
+ rubyforge_project:
253
+ rubygems_version: 2.0.3
254
+ signing_key:
255
+ specification_version: 4
256
+ summary: Judy is a CLI for Dropbox, for downloading and uploading files.
257
+ test_files:
258
+ - spec/cli/lint_spec.rb
259
+ - spec/cli/parse_spec.rb
260
+ - spec/cli/version_cli_spec.rb
261
+ - spec/fixtures/lint/balancer.pp
262
+ - spec/fixtures/lint/balancer_needs_lint.pp
263
+ - spec/fixtures/lint/no_puppet_here/notpuppet.tmp
264
+ - spec/fixtures/parse/nginx.pp
265
+ - spec/fixtures/parse/nginx_fail.pp
266
+ - spec/fixtures/parse/no_puppet_here/notpuppet.tmp
267
+ - spec/middleware/base_spec.rb
268
+ - spec/shared/environment.rb
269
+ - spec/spec_helper.rb