chef-lxc 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +65 -0
- data/Rakefile +9 -0
- data/bin/chef-lxc +6 -0
- data/chef-lxc.gemspec +30 -0
- data/lib/chef/application/lxc.rb +122 -0
- data/lib/chef/lxc/version.rb +5 -0
- data/lib/chef/lxc.rb +10 -0
- data/lib/chef/provider/lxc.rb +88 -0
- data/lib/chef/resource/lxc.rb +57 -0
- data/spec/chef/recipe_spec.rb +40 -0
- data/spec/chef/simple_spec.rb +24 -0
- data/spec/chef/template_spec.rb +31 -0
- data/spec/chef_lxc_spec.rb +23 -0
- data/spec/data/recipe.rb +15 -0
- data/spec/data/simple.rb +3 -0
- data/spec/data/template.rb +10 -0
- data/spec/spec_helper.rb +29 -0
- metadata +171 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MjVlZDE4Njk0MGY3YTY0NTQ0ZGM0ZjUxMDY3YTk5MmFiMmMxNzI0MA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YjkwZTRkMDVhMTVlMjZjY2EwYmVlMGMyZTUyYjhkNjhmOTFhYTFlMw==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZTU4OWYzMmU4NWE4ZjYyMGQxMzQ4MTY4ZTc1YTU0ZTBlZDExYzA4OGQ2MmM2
|
10
|
+
ZDA3MWEyNmQ3ZjNhM2I0OGMyZmNkMWI0Mzk5NmZiMGZkOTAyMTNkZDU4M2Yx
|
11
|
+
ZTQ1MGRjNGE1NGZlYzJjOGE1NDZjY2Y4YWFlMzYyZGI4YTVhYTU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZmVmZTZhOTQ5ODQ2Mjc3ZjhhZjZlYzMwYTIzNzI3ZjM0MzllNDJlYjk1NDNm
|
14
|
+
ZGFiY2Q2OTBiODVkZWI5NjQ3MjRlZDVlMTk0MTJiYzk4NjJiYmIzOTYyYjFl
|
15
|
+
MGI5OTA3ZjQzYTFiMDAyNzNmYjYwYWJlYzBkNzg5NGZlMzBiNjc=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Ranjib Dey
|
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,65 @@
|
|
1
|
+
# Chef::Lxc
|
2
|
+
|
3
|
+
[Chef](http://www.getchef.com/) integration for [LXC](http://linuxcontainers.org/).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
Note: This library depends on [ruby-lxc](https://github.com/lxc/ruby-lxc), a native liblxc binding, ruby-lxc will be
|
7
|
+
released around April, 2014(alongside LXC 1.0, Ubuntu 14.04 release). Till then,
|
8
|
+
use bundler to experiement with chef-lxc.
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'chef-lxc', github: 'ranjib/chef-lxc'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install chef-lxc
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
- Execute a chef recipe against a running container (like chef-apply)
|
24
|
+
```sh
|
25
|
+
lxc-create -n test -t ubuntu
|
26
|
+
lxc-start -n test -d
|
27
|
+
chef-lxc test -e 'package "screen"' # via command line
|
28
|
+
```
|
29
|
+
or stream a recipe
|
30
|
+
```sh
|
31
|
+
echo 'package "vim"' | sudo bundle exec chef-lxc chef -s
|
32
|
+
```
|
33
|
+
or supply a file
|
34
|
+
```sh
|
35
|
+
chef-lxc test /path/to/recipe.rb
|
36
|
+
```
|
37
|
+
|
38
|
+
- Create & manage containers (inside chef recipes)
|
39
|
+
Following will create a default (ubuntu) container named `web`
|
40
|
+
```ruby
|
41
|
+
lxc "web"
|
42
|
+
```
|
43
|
+
A more elaborate example,
|
44
|
+
```ruby
|
45
|
+
lxc "web" do
|
46
|
+
template "ubuntu"
|
47
|
+
|
48
|
+
recipe do
|
49
|
+
package "apache2"
|
50
|
+
service "apache2" do
|
51
|
+
action [:start, :enable]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
action [:create, :start]
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
1. Fork it
|
62
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
63
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
64
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
65
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/chef-lxc
ADDED
data/chef-lxc.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'chef/lxc/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "chef-lxc"
|
8
|
+
spec.version = Chef::LXC::VERSION
|
9
|
+
spec.authors = ["Ranjib Dey"]
|
10
|
+
spec.email = ["ranjib@linux.com"]
|
11
|
+
spec.description = %q{LXC bindings for Chef}
|
12
|
+
spec.summary = spec.description
|
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
|
+
spec.bindir = "bin"
|
21
|
+
|
22
|
+
spec.add_dependency "chef", "= 11.8.4.ohai7.0"
|
23
|
+
spec.add_dependency "ruby-lxc"
|
24
|
+
spec.add_dependency "lxc-extra"
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
27
|
+
spec.add_development_dependency "rspec"
|
28
|
+
spec.add_development_dependency "rake"
|
29
|
+
spec.add_development_dependency "chef-zero"
|
30
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'chef'
|
2
|
+
require 'highline'
|
3
|
+
require 'chef/lxc'
|
4
|
+
require 'chef/application'
|
5
|
+
require 'chef/client'
|
6
|
+
require 'chef/config'
|
7
|
+
require 'chef/log'
|
8
|
+
require 'fileutils'
|
9
|
+
require 'tempfile'
|
10
|
+
require 'chef/providers'
|
11
|
+
require 'chef/resources'
|
12
|
+
|
13
|
+
class Chef::Application::LXC < Chef::Application
|
14
|
+
|
15
|
+
banner "Usage: chef-lxc CONTAINER [RECIPE_FILE] [-e RECIPE_TEXT] [-s]"
|
16
|
+
|
17
|
+
option :execute,
|
18
|
+
:short => "-e RECIPE_TEXT",
|
19
|
+
:long => "--execute RECIPE_TEXT",
|
20
|
+
:description => "Execute resources supplied in a string",
|
21
|
+
:proc => nil
|
22
|
+
|
23
|
+
option :stdin,
|
24
|
+
:short => "-s",
|
25
|
+
:long => "--stdin",
|
26
|
+
:description => "Execute resources read from STDIN",
|
27
|
+
:boolean => true
|
28
|
+
|
29
|
+
option :log_level,
|
30
|
+
:short => "-l LEVEL",
|
31
|
+
:long => "--log_level LEVEL",
|
32
|
+
:description => "Set the log level (debug, info, warn, error, fatal)",
|
33
|
+
:proc => lambda { |l| l.to_sym }
|
34
|
+
|
35
|
+
option :help,
|
36
|
+
:short => "-h",
|
37
|
+
:long => "--help",
|
38
|
+
:description => "Show this message",
|
39
|
+
:on => :tail,
|
40
|
+
:boolean => true,
|
41
|
+
:show_options => true,
|
42
|
+
:exit => 0
|
43
|
+
|
44
|
+
option :version,
|
45
|
+
:short => "-v",
|
46
|
+
:long => "--version",
|
47
|
+
:description => "Show chef-lxc version",
|
48
|
+
:boolean => true,
|
49
|
+
:proc => lambda {|v| puts "Chef::LXC: #{::Chef::LXC::VERSION}"},
|
50
|
+
:exit => 0
|
51
|
+
|
52
|
+
option :why_run,
|
53
|
+
:short => '-W',
|
54
|
+
:long => '--why-run',
|
55
|
+
:description => 'Enable whyrun mode',
|
56
|
+
:boolean => true
|
57
|
+
|
58
|
+
option :color,
|
59
|
+
:long => '--[no-]color',
|
60
|
+
:boolean => true,
|
61
|
+
:default => true,
|
62
|
+
:description => "Use colored output, defaults to enabled"
|
63
|
+
|
64
|
+
def initialize
|
65
|
+
super
|
66
|
+
end
|
67
|
+
|
68
|
+
def reconfigure
|
69
|
+
parse_options
|
70
|
+
Chef::Config.merge!(config)
|
71
|
+
configure_logging
|
72
|
+
end
|
73
|
+
|
74
|
+
def run_chef_recipe
|
75
|
+
if config[:execute]
|
76
|
+
recipe_text = config[:execute]
|
77
|
+
elsif config[:stdin]
|
78
|
+
recipe_text = STDIN.read
|
79
|
+
else
|
80
|
+
recipe_text = ::File.read(ARGV[1])
|
81
|
+
end
|
82
|
+
Chef::Config[:solo] = true
|
83
|
+
ct = ::LXC::Container.new(ARGV.first)
|
84
|
+
client.ohai.load_plugins
|
85
|
+
ct.execute do
|
86
|
+
client.run_ohai
|
87
|
+
client.load_node
|
88
|
+
client.build_node
|
89
|
+
run_context = Chef::RunContext.new(client.node, {}, client.events)
|
90
|
+
recipe = Chef::Recipe.new("(chef-lxc cookbook)", "(chef-lxc recipe)", run_context)
|
91
|
+
recipe.instance_eval(recipe_text, '/foo/bar.rb', 1)
|
92
|
+
runner = Chef::Runner.new(run_context)
|
93
|
+
runner.converge
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def client
|
98
|
+
@client ||= Class.new(Chef::Client) do
|
99
|
+
def run_ohai
|
100
|
+
ohai.run_plugins
|
101
|
+
end
|
102
|
+
end.new
|
103
|
+
end
|
104
|
+
|
105
|
+
def run_application
|
106
|
+
begin
|
107
|
+
parse_options
|
108
|
+
run_chef_recipe
|
109
|
+
Chef::Application.exit! "Exiting", 0
|
110
|
+
rescue SystemExit => e
|
111
|
+
raise
|
112
|
+
rescue Exception => e
|
113
|
+
Chef::Application.debug_stacktrace(e)
|
114
|
+
Chef::Application.fatal!("#{e.class}: #{e.message}", 1)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def run
|
119
|
+
reconfigure
|
120
|
+
run_application
|
121
|
+
end
|
122
|
+
end
|
data/lib/chef/lxc.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'chef/provider'
|
2
|
+
require 'lxc'
|
3
|
+
|
4
|
+
class Chef
|
5
|
+
class Provider
|
6
|
+
class Lxc < Chef::Provider
|
7
|
+
|
8
|
+
attr_reader :ct
|
9
|
+
|
10
|
+
def initialize(new_resource, run_context)
|
11
|
+
super(new_resource, run_context)
|
12
|
+
end
|
13
|
+
|
14
|
+
def whyrun_supported?
|
15
|
+
true
|
16
|
+
end
|
17
|
+
|
18
|
+
def load_current_resource
|
19
|
+
@ct = ::LXC::Container.new(new_resource.container_name)
|
20
|
+
if (new_resource.action == 'start') or (new_resource.action == 'stop')
|
21
|
+
raise ArgumentError, 'Can not start or stop non-existent container'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def action_create
|
26
|
+
unless ct.defined?
|
27
|
+
converge_by("create container '#{ct.name}'") do
|
28
|
+
template = new_resource.lxc_template.type
|
29
|
+
block_device = new_resource.lxc_template.bd
|
30
|
+
template_options = new_resource.lxc_template.options
|
31
|
+
flags = 0
|
32
|
+
ct.create(template, block_device, flags, template_options)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def action_stop
|
38
|
+
if ct.running?
|
39
|
+
converge_by("stop container '#{ct.name}'") do
|
40
|
+
ct.stop
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def action_start
|
46
|
+
unless ct.running?
|
47
|
+
converge_by("start container '#{ct.name}'") do
|
48
|
+
ct.start
|
49
|
+
end
|
50
|
+
end
|
51
|
+
unless new_resource.recipe_block.nil?
|
52
|
+
run_recipe
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def action_destroy
|
57
|
+
if ct.defined?
|
58
|
+
converge_by("destroy container '#{ct.name}'") do
|
59
|
+
ct.destroy
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def run_recipe
|
65
|
+
client.ohai.load_plugins
|
66
|
+
ct.execute do
|
67
|
+
Chef::Config[:solo] = true
|
68
|
+
client.run_ohai
|
69
|
+
client.load_node
|
70
|
+
client.build_node
|
71
|
+
run_context = Chef::RunContext.new(client.node, {}, client.events)
|
72
|
+
recipe = Chef::Recipe.new(new_resource.name,'inline', run_context)
|
73
|
+
recipe.instance_eval(&new_resource.recipe_block)
|
74
|
+
runner = Chef::Runner.new(run_context)
|
75
|
+
runner.converge
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def client
|
80
|
+
@client ||= Class.new(Chef::Client) do
|
81
|
+
def run_ohai
|
82
|
+
ohai.run_plugins
|
83
|
+
end
|
84
|
+
end.new
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'chef/resource'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Resource
|
5
|
+
class Lxc < Chef::Resource
|
6
|
+
|
7
|
+
class InlineRecipe
|
8
|
+
end
|
9
|
+
|
10
|
+
class LXCTemplate
|
11
|
+
attr_reader :type, :bd, :options
|
12
|
+
def initialize(type='ubuntu')
|
13
|
+
@type = type
|
14
|
+
@bd = nil
|
15
|
+
@options = []
|
16
|
+
end
|
17
|
+
|
18
|
+
def args(args)
|
19
|
+
@options = args
|
20
|
+
end
|
21
|
+
|
22
|
+
def block_device(bd)
|
23
|
+
@bd = bd
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
identity_attr :container_name
|
28
|
+
attr_reader :lxc_template, :recipe_block
|
29
|
+
|
30
|
+
def initialize(name, run_context = nil)
|
31
|
+
super
|
32
|
+
@resource_name = :container
|
33
|
+
@container_name = name
|
34
|
+
@provider = Chef::Provider::Lxc
|
35
|
+
@action = :create
|
36
|
+
@allowed_actions += [:start, :stop, :destroy, :create]
|
37
|
+
@lxc_template = LXCTemplate.new
|
38
|
+
@recipe_block = nil
|
39
|
+
end
|
40
|
+
|
41
|
+
def container_name(arg = nil)
|
42
|
+
set_or_return(:container_name, arg, kind_of: [ String ] )
|
43
|
+
end
|
44
|
+
|
45
|
+
def template(type = 'ubuntu', &block)
|
46
|
+
@lxc_template = LXCTemplate.new(type)
|
47
|
+
if block_given?
|
48
|
+
@lxc_template.instance_eval(&block)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def recipe(&block)
|
53
|
+
@recipe_block = block
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'chef/resource/lxc'
|
4
|
+
require 'chef/provider/lxc'
|
5
|
+
require 'mixlib/shellout'
|
6
|
+
|
7
|
+
describe 'inline recipe' do
|
8
|
+
|
9
|
+
before(:all) do
|
10
|
+
execute_recipe('recipe.rb')
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:ct) do
|
14
|
+
LXC::Container.new('chef')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'container should be created' do
|
18
|
+
expect(ct.defined?).to be_true
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'container should be running' do
|
22
|
+
expect(ct.running?).to be_true
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should create test directory' do
|
26
|
+
expect(file('/opt/test')).to be_directory
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should install apach2 package' do
|
30
|
+
expect(package('apache2')).to be_installed
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should start apache2 service' do
|
34
|
+
expect(service('apache2')).to be_running
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should enable apache2 service' do
|
38
|
+
expect(service('apache2')).to be_enabled
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'chef/resource/lxc'
|
4
|
+
require 'chef/provider/lxc'
|
5
|
+
require 'mixlib/shellout'
|
6
|
+
|
7
|
+
describe 'Chef lxc resource/provider' do
|
8
|
+
|
9
|
+
before(:all) do
|
10
|
+
execute_recipe('simple.rb')
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:ct) do
|
14
|
+
LXC::Container.new('chef')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should create the container' do
|
18
|
+
expect(ct.defined?).to be_true
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should not start the container' do
|
22
|
+
expect(ct.running?).to be_false
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'chef/resource/lxc'
|
4
|
+
require 'chef/provider/lxc'
|
5
|
+
require 'mixlib/shellout'
|
6
|
+
|
7
|
+
describe 'Chef lxc resource/provider' do
|
8
|
+
|
9
|
+
before(:all) do
|
10
|
+
execute_recipe('template.rb')
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:ct) do
|
14
|
+
LXC::Container.new('chef')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'container should be created' do
|
18
|
+
expect(ct.defined?).to be_true
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'container should be running' do
|
22
|
+
expect(ct.running?).to be_true
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'container should be ubuntu 10.04' do
|
26
|
+
version = ct.execute do
|
27
|
+
`lsb_release -a`
|
28
|
+
end
|
29
|
+
expect(version).to match(/10\.04/)
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'chef/application/lxc'
|
3
|
+
|
4
|
+
describe Chef::Application::LXC do
|
5
|
+
before(:all) do
|
6
|
+
c = LXC::Container.new('test')
|
7
|
+
c.create('ubuntu') unless c.defined?
|
8
|
+
c.start unless c.running?
|
9
|
+
end
|
10
|
+
after(:all) do
|
11
|
+
c = LXC::Container.new('test')
|
12
|
+
c.stop if c.running?
|
13
|
+
end
|
14
|
+
it 'should install a package inside a container' do
|
15
|
+
app = Chef::Application::LXC.new
|
16
|
+
app.config[:execute] = 'package "screen"'
|
17
|
+
ARGV.clear
|
18
|
+
ARGV << 'test'
|
19
|
+
expect do
|
20
|
+
app.run_chef_recipe
|
21
|
+
end.to_not raise_error
|
22
|
+
end
|
23
|
+
end
|
data/spec/data/recipe.rb
ADDED
data/spec/data/simple.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
require 'chef/lxc'
|
3
|
+
require 'serverspec'
|
4
|
+
|
5
|
+
include SpecInfra::Helper::Lxc
|
6
|
+
include SpecInfra::Helper::Debian
|
7
|
+
|
8
|
+
|
9
|
+
module LXCSpecHelper
|
10
|
+
def execute_recipe(recipe)
|
11
|
+
c = LXC::Container.new('chef')
|
12
|
+
c.stop if c.running?
|
13
|
+
c.destroy if c.defined?
|
14
|
+
recipe_file = File.expand_path('../data/' + recipe, __FILE__)
|
15
|
+
command = Mixlib::ShellOut.new('chef-apply '+ recipe_file, timeout: 20*60)
|
16
|
+
command.live_stream=$stdout if STDIN.tty?
|
17
|
+
command.run_command
|
18
|
+
command
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
RSpec.configure do |config|
|
23
|
+
config.expect_with(:rspec) { |c| c.syntax = :expect }
|
24
|
+
config.filter_run(focus: true)
|
25
|
+
config.include LXCSpecHelper
|
26
|
+
config.run_all_when_everything_filtered = true
|
27
|
+
config.lxc = "chef"
|
28
|
+
config.backtrace_exclusion_patterns = []
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chef-lxc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ranjib Dey
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: chef
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 11.8.4.ohai7.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 11.8.4.ohai7.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ruby-lxc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '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'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: lxc-extra
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
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: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
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: chef-zero
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: LXC bindings for Chef
|
112
|
+
email:
|
113
|
+
- ranjib@linux.com
|
114
|
+
executables:
|
115
|
+
- chef-lxc
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- .gitignore
|
120
|
+
- Gemfile
|
121
|
+
- LICENSE.txt
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- bin/chef-lxc
|
125
|
+
- chef-lxc.gemspec
|
126
|
+
- lib/chef/application/lxc.rb
|
127
|
+
- lib/chef/lxc.rb
|
128
|
+
- lib/chef/lxc/version.rb
|
129
|
+
- lib/chef/provider/lxc.rb
|
130
|
+
- lib/chef/resource/lxc.rb
|
131
|
+
- spec/chef/recipe_spec.rb
|
132
|
+
- spec/chef/simple_spec.rb
|
133
|
+
- spec/chef/template_spec.rb
|
134
|
+
- spec/chef_lxc_spec.rb
|
135
|
+
- spec/data/recipe.rb
|
136
|
+
- spec/data/simple.rb
|
137
|
+
- spec/data/template.rb
|
138
|
+
- spec/spec_helper.rb
|
139
|
+
homepage: ''
|
140
|
+
licenses:
|
141
|
+
- MIT
|
142
|
+
metadata: {}
|
143
|
+
post_install_message:
|
144
|
+
rdoc_options: []
|
145
|
+
require_paths:
|
146
|
+
- lib
|
147
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ! '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - ! '>='
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
requirements: []
|
158
|
+
rubyforge_project:
|
159
|
+
rubygems_version: 2.1.11
|
160
|
+
signing_key:
|
161
|
+
specification_version: 4
|
162
|
+
summary: LXC bindings for Chef
|
163
|
+
test_files:
|
164
|
+
- spec/chef/recipe_spec.rb
|
165
|
+
- spec/chef/simple_spec.rb
|
166
|
+
- spec/chef/template_spec.rb
|
167
|
+
- spec/chef_lxc_spec.rb
|
168
|
+
- spec/data/recipe.rb
|
169
|
+
- spec/data/simple.rb
|
170
|
+
- spec/data/template.rb
|
171
|
+
- spec/spec_helper.rb
|