vagrant-chefdev 0.1.0
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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +30 -0
- data/Rakefile +3 -0
- data/lib/vagrant/chefdev/action/delete_chef_client.rb +34 -0
- data/lib/vagrant/chefdev/action/delete_chef_node.rb +36 -0
- data/lib/vagrant/chefdev/action.rb +27 -0
- data/lib/vagrant/chefdev/config.rb +19 -0
- data/lib/vagrant/chefdev/plugin.rb +25 -0
- data/lib/vagrant/chefdev/version.rb +5 -0
- data/lib/vagrant/chefdev.rb +9 -0
- data/vagrant-chefdev.gemspec +23 -0
- metadata +99 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 nikethan.nagularaja
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Vagrant::Chefdev
|
2
|
+
|
3
|
+
Vagrant plugin to delete chef client and node in a multi VM environment
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'vagrant-chefdev'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install vagrant-chefdev
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
30
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Chefdev
|
3
|
+
module Action
|
4
|
+
class DeleteChefClient
|
5
|
+
|
6
|
+
def initialize(app, env)
|
7
|
+
@app = app
|
8
|
+
@machine = env[:machine]
|
9
|
+
@global_env = @machine.env
|
10
|
+
@provider = @machine.provider_name
|
11
|
+
@logger = Log4r::Logger.new('vagrant::chefdev::delete_chef_client')
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(env)
|
15
|
+
# skip if machine is not active on destroy action
|
16
|
+
return @app.call(env) if !@machine.id && env[:machine_action] == :destroy
|
17
|
+
|
18
|
+
# check config to see if the chef server is provided
|
19
|
+
return @app.call(env) if @global_env.config_global.chefdev.chef_server.nil?
|
20
|
+
|
21
|
+
# Delete chef Node
|
22
|
+
@logger.info 'Deleting chef client'
|
23
|
+
|
24
|
+
if @machine.config.chefdev.nuke_chef_node
|
25
|
+
machine = @global_env.machine(@global_env.config_global.chefdev.chef_server, p)
|
26
|
+
machine.communicate("knife client delete -y #{@machine.name}")
|
27
|
+
end
|
28
|
+
@app.call(env)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Chefdev
|
3
|
+
module Action
|
4
|
+
class DeleteChefNode
|
5
|
+
|
6
|
+
def initialize(app, env)
|
7
|
+
@app = app
|
8
|
+
@machine = env[:machine]
|
9
|
+
@global_env = @machine.env
|
10
|
+
@provider = @machine.provider_name
|
11
|
+
@logger = Log4r::Logger.new('vagrant::chefdev::delete_chef_node')
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(env)
|
15
|
+
# skip if machine is not active on destroy action
|
16
|
+
return @app.call(env) if !@machine.id && env[:machine_action] == :destroy
|
17
|
+
|
18
|
+
# check config to see if the hosts file should be update automatically
|
19
|
+
return @app.call(env) if @global_env.config_global.chefdev.chef_server.nil?
|
20
|
+
|
21
|
+
# Delete chef Node
|
22
|
+
@logger.info 'Deleting chef node'
|
23
|
+
|
24
|
+
|
25
|
+
if @machine.config.chefdev.nuke_chef_node
|
26
|
+
machine = @global_env.machine(@global_env.config_global.chefdev.chef_server, p)
|
27
|
+
machine.communicate("knife node delete -y #{@machine.name}")
|
28
|
+
|
29
|
+
end
|
30
|
+
@app.call(env)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'vagrant/chefdev/action/delete_chef_client'
|
2
|
+
require 'vagrant/chefdev/action/delete_chef_node'
|
3
|
+
|
4
|
+
module Vagrant
|
5
|
+
module Chefdev
|
6
|
+
module Action
|
7
|
+
include Vagrant::Action::Builtin
|
8
|
+
|
9
|
+
|
10
|
+
def self.delete_chef_node
|
11
|
+
Vagrant::Action::Builder.new.tap do |builder|
|
12
|
+
builder.use ConfigValidate
|
13
|
+
builder.use DeleteChefNode
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
def self.delete_chef_client
|
19
|
+
Vagrant::Action::Builder.new.tap do |builder|
|
20
|
+
builder.use ConfigValidate
|
21
|
+
builder.use DeleteChefClient
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Chefdev
|
3
|
+
class Config < Vagrant.plugin('2', :config)
|
4
|
+
|
5
|
+
attr_accessor :nuke_chef_node
|
6
|
+
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@nuke_chef_node = UNSET_VALUE
|
10
|
+
end
|
11
|
+
|
12
|
+
def finalize!
|
13
|
+
@nuke_chef_node = true if @nuke_chef_node == UNSET_VALUE
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'vagrant/chefdev/action'
|
2
|
+
|
3
|
+
module Vagrant
|
4
|
+
module Chefdev
|
5
|
+
class Plugin < Vagrant.plugin('2')
|
6
|
+
name 'ChefDev'
|
7
|
+
description <<-DESC
|
8
|
+
This plugin manages the chef node and clients
|
9
|
+
DESC
|
10
|
+
|
11
|
+
config(:chefdev) do
|
12
|
+
require_relative 'config'
|
13
|
+
Config
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
action_hook(:chefdev, :machine_action_destroy) do |hook|
|
18
|
+
hook.prepend(Action.delete_chef_node)
|
19
|
+
hook.prepend(Action.delete_chef_client)
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vagrant/chefdev/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "vagrant-chefdev"
|
8
|
+
spec.version = Vagrant::Chefdev::VERSION
|
9
|
+
spec.authors = ["nikethan.nagularaja"]
|
10
|
+
spec.email = ["nikethan.nagularaja@workday.com"]
|
11
|
+
spec.description = %q{Delete chef client and node in multi VM environment}
|
12
|
+
spec.summary = %q{Delete chef client and node in multi VM environment}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-chefdev
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- nikethan.nagularaja
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2013-12-27 00:00:00 -08:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
type: :development
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
segments:
|
27
|
+
- 1
|
28
|
+
- 3
|
29
|
+
version: "1.3"
|
30
|
+
name: bundler
|
31
|
+
requirement: *id001
|
32
|
+
prerelease: false
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
type: :development
|
35
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
41
|
+
version: "0"
|
42
|
+
name: rake
|
43
|
+
requirement: *id002
|
44
|
+
prerelease: false
|
45
|
+
description: Delete chef client and node in multi VM environment
|
46
|
+
email:
|
47
|
+
- nikethan.nagularaja@workday.com
|
48
|
+
executables: []
|
49
|
+
|
50
|
+
extensions: []
|
51
|
+
|
52
|
+
extra_rdoc_files: []
|
53
|
+
|
54
|
+
files:
|
55
|
+
- .gitignore
|
56
|
+
- Gemfile
|
57
|
+
- LICENSE.txt
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- lib/vagrant/chefdev.rb
|
61
|
+
- lib/vagrant/chefdev/action.rb
|
62
|
+
- lib/vagrant/chefdev/action/delete_chef_client.rb
|
63
|
+
- lib/vagrant/chefdev/action/delete_chef_node.rb
|
64
|
+
- lib/vagrant/chefdev/config.rb
|
65
|
+
- lib/vagrant/chefdev/plugin.rb
|
66
|
+
- lib/vagrant/chefdev/version.rb
|
67
|
+
- vagrant-chefdev.gemspec
|
68
|
+
has_rdoc: true
|
69
|
+
homepage: ""
|
70
|
+
licenses:
|
71
|
+
- MIT
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
segments:
|
82
|
+
- 0
|
83
|
+
version: "0"
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
version: "0"
|
91
|
+
requirements: []
|
92
|
+
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 1.3.6
|
95
|
+
signing_key:
|
96
|
+
specification_version: 3
|
97
|
+
summary: Delete chef client and node in multi VM environment
|
98
|
+
test_files: []
|
99
|
+
|