linecook-gem 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/linecook/builder/build.rb +1 -1
- data/lib/linecook/builder/darwin_backend.rb +1 -1
- data/lib/linecook/builder/linux_backend.rb +2 -2
- data/lib/linecook/builder/lxc.rb +1 -1
- data/lib/linecook/builder/manager.rb +1 -1
- data/lib/linecook/image/crypt.rb +1 -1
- data/lib/linecook/image/github.rb +1 -1
- data/lib/linecook/image/manager.rb +2 -2
- data/lib/linecook/image/s3.rb +3 -3
- data/lib/linecook/packager/ebs.rb +1 -1
- data/lib/linecook/packager/manager.rb +2 -2
- data/lib/linecook/provisioner/chef-zero.rb +3 -3
- data/lib/linecook/provisioner/manager.rb +1 -1
- data/lib/linecook/provisioner/packer.rb +1 -1
- data/lib/linecook/util/config.rb +11 -4
- data/lib/linecook/util/ssh.rb +1 -1
- data/lib/linecook/version.rb +1 -1
- data/man/LINECOOK.1 +75 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52ee4d244952be42e41085347b73b873a2110112
|
4
|
+
data.tar.gz: dc8e1b7d9dcfc8fa7af0009d3fda67b25f510af0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 477d2277b95838c99f4cd78aba0ce399b8417c941493ad83881cbf4c34b75a2554309fd1b778761b1c0691f17277dfbf47575041c89a97418c70d40965ef2cc5
|
7
|
+
data.tar.gz: 95a941457180422920c157db29c7df6c6170bd14cc57506586ee46e7f786f973daac002fad539ea2dd3a10c577bd832baf588719576d0d1bf4c32056c3f29249
|
@@ -10,7 +10,7 @@ module Linecook
|
|
10
10
|
def initialize(name, image: nil)
|
11
11
|
Linecook::Builder.start
|
12
12
|
@name = name
|
13
|
-
@image = image || Linecook
|
13
|
+
@image = image || Linecook.config[:provisioner][:default_image]
|
14
14
|
@container = Linecook::Lxc::Container.new(name: @name, image: @image, remote: Linecook::Builder.ssh)
|
15
15
|
end
|
16
16
|
|
@@ -5,8 +5,8 @@ module Linecook
|
|
5
5
|
|
6
6
|
def backend
|
7
7
|
check_lxc_version
|
8
|
-
config = Linecook
|
9
|
-
images = Linecook
|
8
|
+
config = Linecook.config[:builder]
|
9
|
+
images = Linecook.config[:image][:images]
|
10
10
|
Linecook::Lxc::Container.new(name: config[:name], home: config[:home], image: config[:image], bridge: true)
|
11
11
|
end
|
12
12
|
|
data/lib/linecook/builder/lxc.rb
CHANGED
@@ -99,7 +99,7 @@ module Linecook
|
|
99
99
|
@upper_dir = File.join(@upper_base, '/upper')
|
100
100
|
@work_dir = File.join(@upper_base, '/work')
|
101
101
|
@socket_dirs = []
|
102
|
-
(Linecook
|
102
|
+
(Linecook.config[:socket_dirs] ||[]).each{ |sock| @socket_dirs << File.join(@root, sock) }
|
103
103
|
end
|
104
104
|
|
105
105
|
def write_config
|
data/lib/linecook/image/crypt.rb
CHANGED
@@ -9,7 +9,7 @@ module Linecook
|
|
9
9
|
extend self
|
10
10
|
|
11
11
|
def fetch(name, upgrade:false, profile: :private)
|
12
|
-
image_name = Linecook
|
12
|
+
image_name = Linecook.config[:image][:images][name][:name]
|
13
13
|
path = File.join(IMAGE_PATH, image_name)
|
14
14
|
url = provider(profile).url(name) unless File.exist?(path) || upgrade# FIXME
|
15
15
|
Linecook::Downloader.download(url, path) unless File.exist?(path) || upgrade
|
@@ -29,7 +29,7 @@ module Linecook
|
|
29
29
|
private
|
30
30
|
|
31
31
|
def provider(image_profile)
|
32
|
-
profile = Linecook
|
32
|
+
profile = Linecook.config[:image][:provider][image_profile]
|
33
33
|
case profile
|
34
34
|
when :s3
|
35
35
|
S3Manager
|
data/lib/linecook/image/s3.rb
CHANGED
@@ -9,7 +9,7 @@ module Linecook
|
|
9
9
|
def url(name)
|
10
10
|
client
|
11
11
|
s3 = Aws::S3::Resource.new
|
12
|
-
obj = s3.bucket(Linecook
|
12
|
+
obj = s3.bucket(Linecook.config[:s3][:bucket]).object(name)
|
13
13
|
obj.presigned_url(:get, expires_in: EXPIRY * 60)
|
14
14
|
end
|
15
15
|
|
@@ -17,7 +17,7 @@ module Linecook
|
|
17
17
|
File.open(path, 'rb') do |file|
|
18
18
|
fname = File.basename(path)
|
19
19
|
pbar = ProgressBar.create(title: fname, total: file.size)
|
20
|
-
common_opts = { bucket: Linecook
|
20
|
+
common_opts = { bucket: Linecook.config[:s3][:bucket], key: File.join('builds', fname) }
|
21
21
|
resp = client.create_multipart_upload(storage_class: 'REDUCED_REDUNDANCY', server_side_encryption: 'AES256', **common_opts)
|
22
22
|
id = resp.upload_id
|
23
23
|
part = 0
|
@@ -38,7 +38,7 @@ module Linecook
|
|
38
38
|
private
|
39
39
|
def client
|
40
40
|
@client ||= begin
|
41
|
-
Aws.config[:credentials] = Aws::Credentials.new(Linecook
|
41
|
+
Aws.config[:credentials] = Aws::Credentials.new(Linecook.config[:aws][:access_key], Linecook.config[:aws][:secret_key])
|
42
42
|
Aws.config[:region] = 'us-east-1'
|
43
43
|
Aws::S3::Client.new
|
44
44
|
end
|
@@ -84,7 +84,7 @@ module Linecook
|
|
84
84
|
|
85
85
|
def client
|
86
86
|
@client ||= begin
|
87
|
-
credentials = Aws::Credentials.new(Linecook
|
87
|
+
credentials = Aws::Credentials.new(Linecook.config[:aws][:access_key], Linecook.config[:aws][:secret_key])
|
88
88
|
Aws::EC2::Client.new(region: @region, credentials: credentials)
|
89
89
|
end
|
90
90
|
end
|
@@ -10,8 +10,8 @@ module Linecook
|
|
10
10
|
|
11
11
|
private
|
12
12
|
def provider
|
13
|
-
name = Linecook
|
14
|
-
config = Linecook
|
13
|
+
name = Linecook.config[:packager][:provider]
|
14
|
+
config = Linecook.config[:packager][name]
|
15
15
|
case name
|
16
16
|
when :ebs
|
17
17
|
Linecook::Packager::EBS.new(**config)
|
@@ -10,7 +10,7 @@ module Linecook
|
|
10
10
|
|
11
11
|
def provision(build, role)
|
12
12
|
chef_config = setup
|
13
|
-
role_config = Linecook
|
13
|
+
role_config = Linecook.config[:roles][role.to_sym]
|
14
14
|
script = ChefProvisioner::Bootstrap.generate(
|
15
15
|
node_name: chef_config[:node_name],
|
16
16
|
chef_version: chef_config[:version] || nil,
|
@@ -31,7 +31,7 @@ module Linecook
|
|
31
31
|
|
32
32
|
def setup
|
33
33
|
ChefProvisioner::Config.setup(client: 'linecook', listen: 'localhost')
|
34
|
-
config = Linecook
|
34
|
+
config = Linecook.config
|
35
35
|
|
36
36
|
chef_config = config[:chef]
|
37
37
|
chef_config.merge!(node_name: "linecook-#{SecureRandom.uuid}",
|
@@ -71,7 +71,7 @@ module Linecook
|
|
71
71
|
def build
|
72
72
|
if stale
|
73
73
|
puts 'Regenerating cookbook cache'
|
74
|
-
Chefdepartie.run(background: true, config: Linecook
|
74
|
+
Chefdepartie.run(background: true, config: Linecook.config[:chef], cache: CACHE_PATH)
|
75
75
|
Chefdepartie.stop
|
76
76
|
write_stamp
|
77
77
|
unlock
|
@@ -20,7 +20,7 @@ module Linecook
|
|
20
20
|
private
|
21
21
|
|
22
22
|
def provider(name)
|
23
|
-
provisioner = Linecook
|
23
|
+
provisioner = Linecook.config[:roles][name.to_sym][:provisioner] || Linecook.config[:provisioner][:default_provider]
|
24
24
|
case provisioner
|
25
25
|
when :chefzero
|
26
26
|
Linecook::Chef
|
@@ -20,7 +20,7 @@ module Linecook
|
|
20
20
|
include Executor
|
21
21
|
|
22
22
|
def initialize(build, role)
|
23
|
-
role_config = Linecook
|
23
|
+
role_config = Linecook.config[:roles][role.to_sym]
|
24
24
|
@packer = packer_path
|
25
25
|
@build = build
|
26
26
|
@template = role_config[:template_path]
|
data/lib/linecook/util/config.rb
CHANGED
@@ -5,11 +5,17 @@ require 'fileutils'
|
|
5
5
|
require 'xhyve'
|
6
6
|
|
7
7
|
module Linecook
|
8
|
+
def self.config
|
9
|
+
config = Config.load_config
|
10
|
+
config
|
11
|
+
end
|
12
|
+
|
8
13
|
module Config
|
9
14
|
extend self
|
10
15
|
attr_reader :config
|
11
16
|
|
12
17
|
CONFIG_PATH = File.join(Dir.pwd, 'linecook.yml').freeze # File.expand_path('../../../config/config.yml', __FILE__)
|
18
|
+
SECRETS_PATH = File.join(Dir.pwd, 'secrets.ejson').freeze # File.expand_path('../../../config/config.yml', __FILE__)
|
13
19
|
LINECOOK_HOME = File.expand_path('~/.linecook').freeze
|
14
20
|
DEFAULT_CONFIG_PATH = File.join(LINECOOK_HOME, 'config.yml').freeze
|
15
21
|
DEFAULT_CONFIG = {
|
@@ -58,8 +64,8 @@ module Linecook
|
|
58
64
|
|
59
65
|
def secrets
|
60
66
|
@secrets ||= begin
|
61
|
-
if File.exists?(
|
62
|
-
JSON.load(`ejson decrypt secrets.ejson`)
|
67
|
+
if File.exists?(SECRETS_PATH)
|
68
|
+
JSON.load(`ejson decrypt secrets.ejson`).deep_symbolize_keys
|
63
69
|
else
|
64
70
|
{}
|
65
71
|
end
|
@@ -85,10 +91,11 @@ module Linecook
|
|
85
91
|
def load_config
|
86
92
|
@config ||= begin
|
87
93
|
config = YAML.load(File.read(DEFAULT_CONFIG_PATH)) if File.exist?(DEFAULT_CONFIG_PATH)
|
88
|
-
config.
|
94
|
+
config.deep_merge!(YAML.load(File.read(CONFIG_PATH))) if File.exist?(CONFIG_PATH)
|
89
95
|
# fail "Cookbook path not provided or doesn't exist" unless (config[:chef][:cookbook_path] && Dir.exists?(config[:chef][:cookbook_path]))
|
90
96
|
# fail "Databag secret not provided or doesn't exist" unless (config[:chef][:encrypted_data_bag_secret] && File.exists?(config[:chef][:encrypted_data_bag_secret]))
|
91
|
-
(config || {}).deep_symbolize_keys
|
97
|
+
(config || {}).deep_symbolize_keys!
|
98
|
+
config.deep_merge!(secrets)
|
92
99
|
end
|
93
100
|
end
|
94
101
|
|
data/lib/linecook/util/ssh.rb
CHANGED
@@ -160,7 +160,7 @@ module Linecook
|
|
160
160
|
|
161
161
|
def setup_ssh_key
|
162
162
|
pubkey = Linecook::SSH.public_key(keyfile: @keyfile)
|
163
|
-
config = Linecook
|
163
|
+
config = Linecook.config[:builder]
|
164
164
|
run("mkdir -p /home/#{config[:username]}/.ssh")
|
165
165
|
upload(pubkey, "/home/#{config[:username]}/.ssh/authorized_keys")
|
166
166
|
end
|
data/lib/linecook/version.rb
CHANGED
data/man/LINECOOK.1
CHANGED
@@ -1,16 +1,90 @@
|
|
1
1
|
.TH LINECOOK 1 "December 2015" Unix "User Manuals"
|
2
2
|
.SH NAME
|
3
3
|
.PP
|
4
|
-
linecook \- system image builder
|
4
|
+
linecook \- Linux system image builder
|
5
5
|
.SH SYNOPSIS
|
6
6
|
.PP
|
7
|
+
linecook setup \- interactive setup
|
8
|
+
.PP
|
7
9
|
linecook help [\fB\fCCOMMAND\fR]\- for specific command help
|
8
10
|
.SH DESCRIPTION
|
9
11
|
.PP
|
10
12
|
Linecook builds system images utilizing overlayfs, squashfs, and linux containers via LXC. Currently, linecook only natively supports chef for provisioning, but using packer with a null resource, any of the mechanisms supported by packer are also supported by linecook.
|
13
|
+
.PP
|
14
|
+
Linecook is intended to serve 3 main purposes:
|
15
|
+
.RS
|
16
|
+
.IP \(bu 2
|
17
|
+
Providing a simple, portable image building process that is useable both in baremetal and cloud deployments.
|
18
|
+
.IP \(bu 2
|
19
|
+
Enabling a means of simple local image development with high production efficacy on Linux and OS X.
|
20
|
+
.IP \(bu 2
|
21
|
+
Simplifying continuous integration and testing of linux systems.
|
22
|
+
.RE
|
23
|
+
.SH USAGE
|
24
|
+
.TP
|
25
|
+
linecook bake SPEC [\-n \-\-name \fB\fCNAME\fR] [\-s \-\-snapshot]
|
26
|
+
\-\-name \- The name
|
27
|
+
\-\-snapshot \- Snapshot the resulting image for later use
|
28
|
+
\-\-encrypt \- Encrypt the snapshot using the configured key. Implies snapshot.
|
29
|
+
\-\-upload \- Upload the resulting image to the configured destination. Implies snapshot.
|
30
|
+
\-\-all \- Snapshot, encrypt, and upload the resulting image.
|
31
|
+
Build a linecook image defined by SPEC, with an optional name to help identify it. The default will be the SPEC name
|
32
|
+
.TP
|
33
|
+
linecook builder
|
34
|
+
start \- start a new builder
|
35
|
+
stop \- stop a running builder
|
36
|
+
info \- show the info about the builder
|
37
|
+
ip \- show the builder's ip
|
38
|
+
.TP
|
39
|
+
linecook config
|
40
|
+
setup
|
41
|
+
check \- validate config
|
42
|
+
show
|
43
|
+
.TP
|
44
|
+
linecook build
|
45
|
+
list
|
46
|
+
info NAME
|
47
|
+
ip NAME
|
48
|
+
stop NAME
|
49
|
+
.TP
|
50
|
+
linecook image
|
51
|
+
list
|
52
|
+
keygen \- generate a new secret key for image encryption
|
53
|
+
fetch
|
54
|
+
find [\fB\fCREGEX\fR] \- list available remote images filtered by an optional regex
|
55
|
+
.PP
|
56
|
+
linecook ami [\fB\fCimage\fR] [\-r \-\-region \fB\fCREGION1,REGION2\fR] [\-x \-\-xen\-type \fB\fCPV|HVM\fR] [\-r \-\-root\-size GIGABYTES] \- create an AMI (Amazon Machine Image) from a snapshot.
|
11
57
|
.SH CONFIGURATION
|
12
58
|
.PP
|
13
59
|
Describe config file here once it's been determined
|
60
|
+
.SH PROVISIONERS
|
61
|
+
.PP
|
62
|
+
Linecook includes an embedded chef\-zero server, and uses the chef\-provisioner
|
63
|
+
\[la]https://rubygems.org/gems/chef-provisioner\[ra] and chefdepartie
|
64
|
+
\[la]https://rubygems.org/gems/chefdepartie\[ra] gems to have first\-class support for local chef\-zero builds.
|
65
|
+
.PP
|
66
|
+
However, if you're not using chef or don't want to use chef\-zero, linecook can be used seamlessly with packer
|
67
|
+
\[la]https://www.packer.io\[ra], and supports any of the Linux\-based provisioners. This includes:
|
68
|
+
.RS
|
69
|
+
.IP \(bu 2
|
70
|
+
Chef\-solo
|
71
|
+
.IP \(bu 2
|
72
|
+
Chef\-client (with a real chef server)
|
73
|
+
.IP \(bu 2
|
74
|
+
Ansible
|
75
|
+
.IP \(bu 2
|
76
|
+
Puppet (masterless or server)
|
77
|
+
.IP \(bu 2
|
78
|
+
Salt
|
79
|
+
.IP \(bu 2
|
80
|
+
Plain old shell scripts
|
81
|
+
.RE
|
82
|
+
.PP
|
83
|
+
See the packer documentation for how to configure these provisioners.
|
84
|
+
.PP
|
85
|
+
To use a packerfile with linecook, just leave out the 'builder' section, or have the builder section be an empty array. You need only specify the 'provisioner' section, and other sections may cause errors. Linecook will automatically insert a null builder with the appropriate connection string for you.
|
86
|
+
.PP
|
87
|
+
Linecook with packer is a powerful combination, as it allows you to leverage packer's 'null builder' to take advantage of all of the provisioners packer already has really good support for. The result is an intermediate image format (squashfs) that can be easily applied to any target.
|
14
88
|
.SH FILES
|
15
89
|
.TP
|
16
90
|
\fI\&./linecook.yml\fP
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linecook-gem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dale Hamel
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.0.
|
75
|
+
version: 0.0.8
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.0.
|
82
|
+
version: 0.0.8
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: chef-provisioner
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -304,4 +304,3 @@ signing_key:
|
|
304
304
|
specification_version: 4
|
305
305
|
summary: Build system images using chef zero, LXC, and packer
|
306
306
|
test_files: []
|
307
|
-
has_rdoc:
|