chef-lxc 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ad048909ff6c48250256ceefeda20d570420936
4
- data.tar.gz: b08f1170d5e9fab374ede9d9574a07f3725c6793
3
+ metadata.gz: 9ba99730c548bcf0e27a3131a9c4ccd53f49ddcf
4
+ data.tar.gz: 13952edcce410d0c0999515a6bb89a786aff0cea
5
5
  SHA512:
6
- metadata.gz: bf7c7af7788aae3b95d9319d00825d9b1b5cbee099ded9d3942beb253634e5334460dcb7ae312908c1feac22200a20846ef3e09c0cb7ed69387de03293bc46da
7
- data.tar.gz: ff715f7e0d96b73c6004c9076dd583284074094441a82e21a824759c99f5c8de44b957f3fc70446009340a48757c6671ee52b857a430d4880a4f670137b1ad15
6
+ metadata.gz: a506cbb2277209230a1fcdef0b1149aea9f1d827f8f8e7f3268562dfaaef454115513d60e2e1d69885190f9215e027bac6155f9399476581042942f9364e994f
7
+ data.tar.gz: dab1929786fd6efbd9df24d08943fbc9d58715b838678b994b5cdc32ef1231807122fc2eb8c0044fad2a58950f0827873e43c1e0723eea202218dae2c4efb030
@@ -11,10 +11,11 @@ class Chef
11
11
  recipe_in_container(self, recipe_content, &block)
12
12
  end
13
13
 
14
- def command(command)
14
+ def command(command, opts = {})
15
+ live_stream = opts[:live_stream] || $stdout
15
16
  out = execute(wait: true) do
16
17
  cmd = Mixlib::ShellOut.new(command)
17
- cmd.live_stream = $stdout
18
+ cmd.live_stream = live_stream
18
19
  cmd.run_command
19
20
  cmd.exitstatus
20
21
  end
@@ -19,12 +19,10 @@ class Chef
19
19
  if force
20
20
  ct.stop if ct.running?
21
21
  ct.destroy
22
- provision(name, opts)
23
- ct = container(name)
22
+ ct = provision(name, opts)
24
23
  end
25
24
  else
26
- provision(name, opts)
27
- ct = container(name)
25
+ ct = provision(name, opts)
28
26
  end
29
27
  ct.start unless ct.running?
30
28
  while ct.ip_addresses.empty?
@@ -41,9 +39,7 @@ class Chef
41
39
  ct
42
40
  end
43
41
 
44
- private
45
-
46
- def provision(name, opts)
42
+ def provision(name, opts = {})
47
43
  from = opts[:from]
48
44
  if from
49
45
  base = container(from)
@@ -53,10 +49,11 @@ class Chef
53
49
  bdevtype = opts[:bdevtype]
54
50
  bdevspecs = opts[:bdevspecs] || {}
55
51
  flags = opts[:flags] || 0
56
- args = opts[:flags] || %w(-d ubuntu -r trusty -a amd64)
52
+ args = opts[:args] || %w(-d ubuntu -r trusty -a amd64)
57
53
  ct = container(name)
58
54
  ct.create(template, bdevtype, bdevspecs, flags, args)
59
55
  end
56
+ container(name)
60
57
  end
61
58
  end
62
59
  end
@@ -1,5 +1,5 @@
1
1
  class Chef
2
2
  module LXC
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
  end
5
5
  end
@@ -100,4 +100,34 @@ describe Chef::LXC::Fleet do
100
100
  expect(role.run_list.count).to eq(1)
101
101
  expect(role.run_list.first.to_s).to eq('recipe[bar]')
102
102
  end
103
+
104
+ context '#provision' do
105
+ it 'uses ubuntu trusty amd64 by default' do
106
+ ct = double(::LXC::Container)
107
+ expect(ct).to receive(:create).with('download', nil,{}, 0, %w(-d ubuntu -r trusty -a amd64))
108
+ expect(::LXC::Container).to receive(:new).with('foo').twice.and_return(ct)
109
+ fleet.provision('foo')
110
+ end
111
+
112
+ it 'passes template and template arguments' do
113
+ ct = double(::LXC::Container)
114
+ expect(ct).to receive(:create).with('ubuntu', nil, {}, 0, %w(-r trusty -a amd64))
115
+ expect(::LXC::Container).to receive(:new).with('foo').twice.and_return(ct)
116
+ fleet.provision('foo', template: 'ubuntu', args: %w(-r trusty -a amd64))
117
+ end
118
+
119
+ it 'passes bdevtype and specs' do
120
+ ct = double(::LXC::Container)
121
+ expect(ct).to receive(:create).with('download', 'lvm',{baz: :bar}, 0, %w(-d ubuntu -r trusty -a amd64))
122
+ expect(::LXC::Container).to receive(:new).with('foo').twice.and_return(ct)
123
+ fleet.provision('foo', bdevtype: 'lvm', bdevspecs: {baz: :bar})
124
+ end
125
+
126
+ it 'passes clone flags' do
127
+ ct = double(::LXC::Container)
128
+ expect(ct).to receive(:create).with('download', nil, {}, 12, %w(-d ubuntu -r trusty -a amd64))
129
+ expect(::LXC::Container).to receive(:new).with('foo').twice.and_return(ct)
130
+ fleet.provision('foo', flags: 12)
131
+ end
132
+ end
103
133
  end
@@ -12,7 +12,7 @@ describe Chef::Application::LXC do
12
12
  end
13
13
  it 'should install a package inside a container' do
14
14
  app = Chef::Application::LXC.new
15
- app.config[:execute] = 'package "screen"'
15
+ app.config[:execute] = 'execute "apt-get update -y"'
16
16
  ARGV.clear
17
17
  ARGV << 'test'
18
18
  expect do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-lxc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ranjib Dey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-06 00:00:00.000000000 Z
11
+ date: 2015-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef