Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

chef-template-snippet: initial commit

  • Loading branch information...
commit 424580f1a103f78c5395e197b5066824acad70f8 0 parents
@fujin authored
8 Gemfile
@@ -0,0 +1,8 @@
+group :test do
+ gem "rspec", "~> 2.8.0"
+ gem "guard-rspec", "~> 0.6.0"
+ gem "libnotify"
+ gem "rake"
+end
+
+gem "chef", "~> 0.10.8"
79 Gemfile.lock
@@ -0,0 +1,79 @@
+GEM
+ specs:
+ bunny (0.7.8)
+ chef (0.10.8)
+ bunny (>= 0.6.0)
+ erubis
+ highline
+ json (>= 1.4.4, <= 1.6.1)
+ mixlib-authentication (>= 1.1.0)
+ mixlib-cli (>= 1.1.0)
+ mixlib-config (>= 1.1.2)
+ mixlib-log (>= 1.3.0)
+ moneta
+ net-ssh (~> 2.1.3)
+ net-ssh-multi (~> 1.1.0)
+ ohai (>= 0.6.0)
+ rest-client (>= 1.0.4, < 1.7.0)
+ treetop (~> 1.4.9)
+ uuidtools
+ diff-lcs (1.1.3)
+ erubis (2.7.0)
+ ffi (1.0.11)
+ guard (0.10.0)
+ ffi (>= 0.5.0)
+ thor (~> 0.14.6)
+ guard-rspec (0.6.0)
+ guard (>= 0.10.0)
+ highline (1.6.9)
+ json (1.5.2)
+ libnotify (0.7.2)
+ ffi (~> 1.0.0)
+ mime-types (1.17.2)
+ mixlib-authentication (1.1.4)
+ mixlib-log
+ mixlib-cli (1.2.2)
+ mixlib-config (1.1.2)
+ mixlib-log (1.3.0)
+ moneta (0.6.0)
+ net-ssh (2.1.4)
+ net-ssh-gateway (1.1.0)
+ net-ssh (>= 1.99.1)
+ net-ssh-multi (1.1)
+ net-ssh (>= 2.1.4)
+ net-ssh-gateway (>= 0.99.0)
+ ohai (0.6.10)
+ mixlib-cli
+ mixlib-config
+ mixlib-log
+ systemu (~> 2.2.0)
+ yajl-ruby
+ polyglot (0.3.3)
+ rake (0.9.2.2)
+ rest-client (1.6.7)
+ mime-types (>= 1.16)
+ rspec (2.8.0)
+ rspec-core (~> 2.8.0)
+ rspec-expectations (~> 2.8.0)
+ rspec-mocks (~> 2.8.0)
+ rspec-core (2.8.0)
+ rspec-expectations (2.8.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.8.0)
+ systemu (2.2.0)
+ thor (0.14.6)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ uuidtools (2.1.2)
+ yajl-ruby (1.1.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ chef (~> 0.10.8)
+ guard-rspec (~> 0.6.0)
+ libnotify
+ rake
+ rspec (~> 2.8.0)
6 Guardfile
@@ -0,0 +1,6 @@
+guard 'rspec', :version => 2, :cli => "--color --format doc" do
+ watch(%r{^spec/.+_spec\.rb$})
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
+ watch('spec/spec_helper.rb') { "spec" }
+end
+
23 Rakefile
@@ -0,0 +1,23 @@
+# encoding: utf-8
+
+require "rubygems" unless RUBY_VERSION =~ /1.9/
+require "bundler"
+begin
+ Bundler.setup(:default,
+ :development,
+ :test)
+rescue Bundler::BundlerError => e
+ $stderr.puts e.message
+ $stderr.puts "Run `bundle install` to install missing gems"
+ exit e.status_code
+end
+
+require "rake"
+require "rspec/core/rake_task"
+
+RSpec::Core::RakeTask.new do |t|
+ t.verbose = true
+ t.rspec_opts = "--color --format doc"
+end
+
+task :default => %w[spec]
14 Vagrantfile
@@ -0,0 +1,14 @@
+Vagrant::Config.run do |config|
+ config.vm.define :cookbooks do |cookbooks|
+ cookbooks.vm.customize do |vm|
+ vm.memory_size = 4096
+ end
+ cookbooks.vm.box = "natty64"
+ cookbooks.vm.box_url = "https://s3.amazonaws.com/hw-vagrant/natty64.box"
+ cookbooks.vm.provision :chef_solo do |chef|
+ chef.cookbooks_path "cookbooks"
+ chef.add_recipe "jenkins"
+ chef.add_recipe "test"
+ end
+ end
+end
81 libraries/snippet.rb
@@ -0,0 +1,81 @@
+require 'chef/provider/template'
+require 'chef/provider/directory'
+require 'chef/resource/template'
+
+class Chef
+ class Provider
+ class TemplateSnippet < Template
+ def load_current_resource
+ end
+
+ def action_create
+ end
+
+ def action_create_if_missing
+ end
+
+ def action_delete
+ end
+ end
+ end
+
+ class Resource
+ class TemplateSnippet < Template
+
+ def target_dir_from_path
+ ::File.dirname(path)
+ end
+
+ def glob(glob=nil)
+ set_or_return(
+ :glob,
+ glob,
+ :kind_of => [ String ]
+ )
+ end
+
+ def target_file(target_file=nil)
+ set_or_return(
+ :target_file,
+ target_file,
+ :kind_of => [ String ]
+ )
+ end
+
+ end
+ end
+end
+
+if $0 == __FILE__
+ require "rubygems" unless RUBY_VERSION =~ /1.9/
+ require "bundler"
+ begin
+ Bundler.setup(:test)
+ rescue Bundler::BundlerError => e
+ $stderr.puts e.message
+ $stderr.puts "Run `bundle install` to install missing gems"
+ exit e.status_code
+ end
+
+ require "rspec/autorun"
+
+ describe Chef::Provider::TemplateSnippet do
+ before do
+ @provider = Chef::Provider::TemplateSnippet.new
+ end
+
+ it "should have tests"
+
+ end
+
+
+ describe Chef::Resource::TemplateSnippet do
+ before do
+ @resource = Chef::Resource::TemplateSnippet.new
+ end
+
+ it "should have tests"
+
+ end
+
+end
4 readme.rd
@@ -0,0 +1,4 @@
+Chef Template Snippet
+===
+
+Programatically manage any number of snippets to make up a given file
4 recipes/default.rb
@@ -0,0 +1,4 @@
+template_snippet "/etc/foo.d/test" do
+ glob "*"
+ concatenate_into "/etc/foo.conf"
+end
20 spec/snippet_spec.rb
@@ -0,0 +1,20 @@
+require_relative "spec_helper"
+
+describe Chef::Provider::TemplateSnippet do
+ before do
+ @provider = Chef::Provider::TemplateSnippet.new
+ end
+
+ it "should have tests"
+
+end
+
+
+describe Chef::Resource::TemplateSnippet do
+ before do
+ @resource = Chef::Resource::TemplateSnippet.new("test")
+ end
+
+ it "should have tests"
+
+end
12 spec/spec_helper.rb
@@ -0,0 +1,12 @@
+require "rubygems" unless RUBY_VERSION =~ /1.9/
+require "bundler"
+begin
+ Bundler.setup(:test)
+rescue Bundler::BundlerError => e
+ $stderr.puts e.message
+ $stderr.puts "Run `bundle install` to install missing gems"
+ exit e.status_code
+end
+
+require "rspec/autorun"
+Dir[File.join(File.dirname(__FILE__), "..", "libraries", "*.rb")].sort.each { |lib| require lib }
Please sign in to comment.
Something went wrong with that request. Please try again.