linecook-gem 0.2.1 → 0.2.3
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.
- checksums.yaml +4 -4
- data/lib/linecook/builder/build.rb +4 -0
- data/lib/linecook/builder/lxc.rb +1 -1
- data/lib/linecook/cli.rb +7 -0
- data/lib/linecook/image/manager.rb +6 -0
- data/lib/linecook/provisioner/chef-zero.rb +1 -0
- data/lib/linecook/provisioner/manager.rb +2 -1
- data/lib/linecook/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b82d8effb1494b4d5c4fcfd3c91f4b36fd6af24f
|
4
|
+
data.tar.gz: 1780d0a2b8dffc44dfc7a7fe52b95cff4024f662
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbd66174b697182fdb039743d3abd5804f3884d2dca1d0e12817731cd17565cc939689eb0082d612bb3ddb54d1ffd8b78c2fea2ddd2f563faeb97e5ff0711bc0
|
7
|
+
data.tar.gz: 623f5b9b461ace37d1699fc0e8ff5a11c4a510ec0cac780abab1433d68f7a71483bc3c94f606c4db89d659e78012dfcc935869142284f4bbab051a492adea703
|
@@ -17,6 +17,10 @@ module Linecook
|
|
17
17
|
@container = Linecook::Lxc::Container.new(name: @id, image: @image, remote: Linecook::Builder.ssh)
|
18
18
|
end
|
19
19
|
|
20
|
+
def clean
|
21
|
+
Linecook::ImageManager.clean(type: @image[:type]) if @image.is_a?(Hash) && @image[:type]
|
22
|
+
end
|
23
|
+
|
20
24
|
def ssh
|
21
25
|
@ssh ||= Linecook::SSH.new(@container.ip, username: USERNAME, proxy: Linecook::Builder.ssh, keyfile: Linecook::SSH.private_key, setup: false)
|
22
26
|
end
|
data/lib/linecook/builder/lxc.rb
CHANGED
@@ -92,7 +92,7 @@ module Linecook
|
|
92
92
|
def wait_ssh
|
93
93
|
if @remote
|
94
94
|
user = Linecook::Build::USERNAME
|
95
|
-
cexec("useradd -m -G sudo #{user}")
|
95
|
+
cexec("id -u #{user} &>/dev/null || useradd -m -G sudo #{user}")
|
96
96
|
cexec("mkdir -p /home/#{user}/.ssh")
|
97
97
|
Linecook::Builder.ssh.upload(Linecook::SSH.public_key, "/tmp/#{@name}-pubkey")
|
98
98
|
Linecook::Builder.ssh.run("sudo mv /tmp/#{@name}-pubkey #{@root}/home/#{user}/.ssh/authorized_keys")
|
data/lib/linecook/cli.rb
CHANGED
@@ -43,6 +43,13 @@ class Image < Thor
|
|
43
43
|
Linecook::ImageManager.fetch(name)
|
44
44
|
end
|
45
45
|
|
46
|
+
desc 'clean', 'Clean up cached images'
|
47
|
+
method_option :type, type: :string, required: true, banner: 'ID', desc: 'Type of image to list', aliases: '-t'
|
48
|
+
def clean
|
49
|
+
opts = options.symbolize_keys
|
50
|
+
puts Linecook::ImageManager.clean(**opts)
|
51
|
+
end
|
52
|
+
|
46
53
|
desc 'upload IMAGE', 'Upload an image'
|
47
54
|
method_options name: :string
|
48
55
|
def upload(image)
|
@@ -27,6 +27,12 @@ module Linecook
|
|
27
27
|
path
|
28
28
|
end
|
29
29
|
|
30
|
+
def clean(type: nil)
|
31
|
+
Dir["#{File.join([IMAGE_PATH, type].compact)}/**/*"].each do |image|
|
32
|
+
FileUtils.rm_f(image) unless `mount`.index(image)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
30
36
|
def upload(image, profile: :private, type: nil)
|
31
37
|
path = File.join(IMAGE_PATH, File.basename(image))
|
32
38
|
puts "Encrypting and uploading image #{path}"
|
@@ -24,6 +24,7 @@ module Linecook
|
|
24
24
|
build.start
|
25
25
|
build.ssh.forward(chef_port)
|
26
26
|
build.ssh.upload(script, '/tmp/chef_bootstrap')
|
27
|
+
build.ssh.run('[ -f /var/chef/cache/chef-client-running.pid ] && sudo rm -f /var/chef/cache/chef-client-running.pid')
|
27
28
|
build.ssh.run('sudo bash /tmp/chef_bootstrap')
|
28
29
|
build.ssh.run('sudo rm -rf /etc/chef')
|
29
30
|
build.ssh.stop_forwarding
|
@@ -17,7 +17,8 @@ module Linecook
|
|
17
17
|
Linecook::Packager.package(snapshot, type: build_agent.type) if package
|
18
18
|
ensure
|
19
19
|
build_agent.stop(clean: clean) unless keep
|
20
|
-
|
20
|
+
build_agent.clean if clean
|
21
|
+
FileUtils.rm_f(snapshot) if clean && File.exists?(snapshot.to_s)
|
21
22
|
end
|
22
23
|
|
23
24
|
private
|
data/lib/linecook/version.rb
CHANGED