dev-lxc 1.6.1 → 1.6.2
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/CHANGELOG.md +10 -0
- data/README.md +9 -14
- data/lib/dev-lxc/cli.rb +87 -29
- data/lib/dev-lxc/container.rb +21 -4
- data/lib/dev-lxc/server.rb +3 -0
- data/lib/dev-lxc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd60a719f985a22500e7b9985b82330c905b34b0
|
4
|
+
data.tar.gz: 9419f498e4565fe466115f9a9b424167625205cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d3e69df1876b5a4ab25912f582253cd4077af340477f49b50d9d7e7749840dc0189d27505bf69e04573517f6fa96e89b4825e6d14d69774ae2e3a627fe4505a
|
7
|
+
data.tar.gz: f4e4cd3627257e5c10bacac186864dadbd5a42b68cc326395c03d3098ea06babbb90e06fb24c20a521d4ddefcb7500a8e4f78d371e03d7d9e52ddcd3b282ea5e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# dev-lxc Change Log
|
2
2
|
|
3
|
+
## 1.6.2 (2016-04-21)
|
4
|
+
|
5
|
+
* Sync SSH public keys to /home/dev-lxc/.ssh/authorized_keys
|
6
|
+
|
7
|
+
* Improve 'dev-lxc init' header
|
8
|
+
|
9
|
+
* Validate dev-lxc.yml hostnames, mounts, packages and ssh-keys
|
10
|
+
|
11
|
+
* Consolidate package paths for simpler updating
|
12
|
+
|
3
13
|
## 1.6.1 (2016-04-20)
|
4
14
|
|
5
15
|
* Fix for open-source in "dev-lxc init"
|
data/README.md
CHANGED
@@ -497,27 +497,22 @@ dev-lxc init
|
|
497
497
|
```
|
498
498
|
## platform_image can be one of the following:
|
499
499
|
## p-centos-5, p-centos-6, p-centos-7, p-ubuntu-1204, p-ubuntu-1404 or p-ubuntu-1504
|
500
|
+
platform_image: p-ubuntu-1404
|
500
501
|
|
501
|
-
## platform_image_options can be set to provide additional arguments to the LXC create command
|
502
|
+
## platform_image_options can be set to provide additional arguments to the LXC create command
|
502
503
|
## reference arg examples: https://github.com/lxc/lxc/blob/lxc-2.0.0/templates/lxc-download.in#L200-L207
|
503
|
-
|
504
|
-
## platform_image_options: --no-validate --keyserver http://my.key.server.com
|
505
|
-
|
506
|
-
## Make sure all mount source directories exist in the LXC host
|
504
|
+
#platform_image_options: --no-validate
|
507
505
|
|
508
|
-
##
|
506
|
+
## list any host directories you want mounted into the servers
|
507
|
+
mounts:
|
508
|
+
- /root/dev root/dev
|
509
509
|
|
510
|
-
##
|
510
|
+
## list any SSH public keys you want added to /home/dev-lxc/.ssh/authorized_keys
|
511
|
+
#ssh-keys:
|
512
|
+
# - /root/dev/clusters/id_rsa.pub
|
511
513
|
|
512
514
|
## DHCP reserved (static) IPs must be selected from the IP range 10.0.3.150 - 254
|
513
515
|
|
514
|
-
## topology can be one of the following:
|
515
|
-
## standalone (default), tier or open-source (for the old open source 11 chef server)
|
516
|
-
|
517
|
-
platform_image: p-ubuntu-1404
|
518
|
-
mounts:
|
519
|
-
- /root/dev root/dev
|
520
|
-
|
521
516
|
chef-server:
|
522
517
|
packages:
|
523
518
|
server: /root/dev/chef-packages/cs/chef-server-core_12.5.0-1_amd64.deb
|
data/lib/dev-lxc/cli.rb
CHANGED
@@ -6,6 +6,59 @@ module DevLXC::CLI
|
|
6
6
|
class DevLXC < Thor
|
7
7
|
|
8
8
|
no_commands{
|
9
|
+
def validate_cluster_config(cluster_config)
|
10
|
+
hostnames = Array.new
|
11
|
+
mounts = Array.new
|
12
|
+
packages = Array.new
|
13
|
+
ssh_keys = Array.new
|
14
|
+
|
15
|
+
mounts.concat(cluster_config['mounts']) unless cluster_config['mounts'].nil?
|
16
|
+
ssh_keys.concat(cluster_config['ssh-keys']) unless cluster_config['ssh-keys'].nil?
|
17
|
+
|
18
|
+
%w(chef-server analytics compliance supermarket adhoc).each do |server_type|
|
19
|
+
unless cluster_config[server_type].nil?
|
20
|
+
hostnames << cluster_config[server_type]['api_fqdn'] unless cluster_config[server_type]['api_fqdn'].nil?
|
21
|
+
hostnames << cluster_config[server_type]['analytics_fqdn'] unless cluster_config[server_type]['analytics_fqdn'].nil?
|
22
|
+
hostnames.concat(cluster_config[server_type]['servers'].keys) unless cluster_config[server_type]['servers'].nil?
|
23
|
+
mounts.concat(cluster_config[server_type]['mounts']) unless cluster_config[server_type]['mounts'].nil?
|
24
|
+
packages.concat(cluster_config[server_type]['packages'].values) unless cluster_config[server_type]['packages'].nil?
|
25
|
+
ssh_keys.concat(cluster_config[server_type]['ssh-keys']) unless cluster_config[server_type]['ssh-keys'].nil?
|
26
|
+
end
|
27
|
+
end
|
28
|
+
unless hostnames.empty?
|
29
|
+
hostnames.each do |hostname|
|
30
|
+
unless hostname.end_with?(".lxc")
|
31
|
+
puts "ERROR: Hostname #{hostname} does not end with '.lxc'."
|
32
|
+
exit 1
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
unless mounts.empty?
|
37
|
+
mounts.each do |mount|
|
38
|
+
unless File.exists?(mount.split.first)
|
39
|
+
puts "ERROR: Mount source #{mount.split.first} does not exist."
|
40
|
+
exit 1
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
unless packages.empty?
|
45
|
+
packages.each do |package|
|
46
|
+
unless File.exists?(package)
|
47
|
+
puts "ERROR: Package #{package} does not exist."
|
48
|
+
exit 1
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
unless ssh_keys.empty?
|
53
|
+
ssh_keys.each do |ssh_key|
|
54
|
+
unless File.exists?(ssh_key)
|
55
|
+
puts "ERROR: SSH key #{ssh_key} does not exist."
|
56
|
+
exit 1
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
9
62
|
def get_cluster(config_file=nil)
|
10
63
|
config_file ||= "dev-lxc.yml"
|
11
64
|
if ! File.exists?(config_file)
|
@@ -13,7 +66,9 @@ module DevLXC::CLI
|
|
13
66
|
puts " Create a `./dev-lxc.yml` file or specify the path using `--config`."
|
14
67
|
exit 1
|
15
68
|
end
|
16
|
-
|
69
|
+
cluster_config = YAML.load(IO.read(config_file))
|
70
|
+
validate_cluster_config(cluster_config)
|
71
|
+
::DevLXC::Cluster.new(cluster_config)
|
17
72
|
end
|
18
73
|
|
19
74
|
def match_server_name_regex(server_name_regex)
|
@@ -124,42 +179,48 @@ module DevLXC::CLI
|
|
124
179
|
def init(unique_string=nil)
|
125
180
|
header = %Q(## platform_image can be one of the following:
|
126
181
|
## p-centos-5, p-centos-6, p-centos-7, p-ubuntu-1204, p-ubuntu-1404 or p-ubuntu-1504
|
182
|
+
platform_image: p-ubuntu-1404
|
127
183
|
|
128
|
-
## platform_image_options can be set to provide additional arguments to the LXC create command
|
184
|
+
## platform_image_options can be set to provide additional arguments to the LXC create command
|
129
185
|
## reference arg examples: https://github.com/lxc/lxc/blob/lxc-2.0.0/templates/lxc-download.in#L200-L207
|
130
|
-
|
131
|
-
## platform_image_options: --no-validate --keyserver http://my.key.server.com
|
186
|
+
#platform_image_options: --no-validate
|
132
187
|
|
133
|
-
##
|
134
|
-
|
135
|
-
|
188
|
+
## list any host directories you want mounted into the servers
|
189
|
+
mounts:
|
190
|
+
- /root/dev root/dev
|
136
191
|
|
137
|
-
##
|
192
|
+
## list any SSH public keys you want added to /home/dev-lxc/.ssh/authorized_keys
|
193
|
+
#ssh-keys:
|
194
|
+
# - /root/dev/clusters/id_rsa.pub
|
138
195
|
|
139
196
|
## DHCP reserved (static) IPs must be selected from the IP range 10.0.3.150 - 254
|
140
|
-
|
141
|
-
## topology can be one of the following:
|
142
|
-
## standalone (default), tier or open-source (for the old open source 11 chef server)
|
143
|
-
|
144
|
-
platform_image: p-ubuntu-1404
|
145
|
-
mounts:
|
146
|
-
- /root/dev root/dev
|
147
197
|
)
|
148
|
-
|
149
|
-
chef-server:
|
150
|
-
packages:
|
198
|
+
open_source_packages = %Q( packages:
|
151
199
|
server: /root/dev/chef-packages/osc/chef-server_11.1.6-1_amd64.deb
|
152
|
-
api_fqdn: chef.lxc
|
153
|
-
topology: open-source
|
154
|
-
servers:
|
155
|
-
osc-chef.lxc:
|
156
|
-
ipaddress: 10.0.3.200
|
157
200
|
)
|
158
201
|
chef_server_packages = %Q( packages:
|
159
202
|
server: /root/dev/chef-packages/cs/chef-server-core_12.5.0-1_amd64.deb
|
160
203
|
manage: /root/dev/chef-packages/manage/chef-manage_2.2.1-1_amd64.deb
|
161
204
|
reporting: /root/dev/chef-packages/reporting/opscode-reporting_1.5.6-1_amd64.deb
|
162
205
|
push-jobs-server: /root/dev/chef-packages/push-jobs-server/opscode-push-jobs-server_1.1.6-1_amd64.deb
|
206
|
+
)
|
207
|
+
analytics_packages = %Q( packages:
|
208
|
+
analytics: /root/dev/chef-packages/analytics/opscode-analytics_1.3.1-1_amd64.deb
|
209
|
+
)
|
210
|
+
compliance_packages = %Q( packages:
|
211
|
+
compliance: /root/dev/chef-packages/compliance/chef-compliance_1.1.2-1_amd64.deb
|
212
|
+
)
|
213
|
+
supermarket_packages = %Q( packages:
|
214
|
+
supermarket: /root/dev/chef-packages/supermarket/supermarket_2.5.2-1_amd64.deb
|
215
|
+
)
|
216
|
+
open_source_config = %Q(
|
217
|
+
chef-server:
|
218
|
+
#{open_source_packages.chomp}
|
219
|
+
api_fqdn: chef.lxc
|
220
|
+
topology: open-source
|
221
|
+
servers:
|
222
|
+
osc-chef.lxc:
|
223
|
+
ipaddress: 10.0.3.200
|
163
224
|
)
|
164
225
|
tiered_chef_config = %Q(
|
165
226
|
chef-server:
|
@@ -184,24 +245,21 @@ chef-server:
|
|
184
245
|
)
|
185
246
|
analytics_config = %Q(
|
186
247
|
analytics:
|
187
|
-
|
188
|
-
analytics: /root/dev/chef-packages/analytics/opscode-analytics_1.3.1-1_amd64.deb
|
248
|
+
#{analytics_packages.chomp}
|
189
249
|
servers:
|
190
250
|
analytics.lxc:
|
191
251
|
ipaddress: 10.0.3.204
|
192
252
|
)
|
193
253
|
compliance_config = %Q(
|
194
254
|
compliance:
|
195
|
-
|
196
|
-
compliance: /root/dev/chef-packages/compliance/chef-compliance_1.1.2-1_amd64.deb
|
255
|
+
#{compliance_packages.chomp}
|
197
256
|
servers:
|
198
257
|
compliance.lxc:
|
199
258
|
ipaddress: 10.0.3.205
|
200
259
|
)
|
201
260
|
supermarket_config = %Q(
|
202
261
|
supermarket:
|
203
|
-
|
204
|
-
supermarket: /root/dev/chef-packages/supermarket/supermarket_2.5.2-1_amd64.deb
|
262
|
+
#{supermarket_packages.chomp}
|
205
263
|
servers:
|
206
264
|
supermarket.lxc:
|
207
265
|
ipaddress: 10.0.3.206
|
data/lib/dev-lxc/container.rb
CHANGED
@@ -52,10 +52,6 @@ module DevLXC
|
|
52
52
|
end
|
53
53
|
unless mounts.nil?
|
54
54
|
mounts.each do |mount|
|
55
|
-
unless File.exists?(mount.split.first)
|
56
|
-
puts "ERROR: Mount source #{mount.split.first} does not exist."
|
57
|
-
exit 1
|
58
|
-
end
|
59
55
|
if ! preserved_mounts.nil? && preserved_mounts.any? { |m| m.start_with?("#{mount} ") }
|
60
56
|
puts "Skipping mount entry #{mount}, it already exists"
|
61
57
|
next
|
@@ -68,6 +64,27 @@ module DevLXC
|
|
68
64
|
self.save_config
|
69
65
|
end
|
70
66
|
|
67
|
+
def sync_ssh_keys(ssh_keys)
|
68
|
+
dot_ssh_path = "/home/dev-lxc/.ssh"
|
69
|
+
unless File.exist?("#{config_item('lxc.rootfs')}#{dot_ssh_path}/authorized_keys")
|
70
|
+
run_command("sudo -u dev-lxc mkdir -p #{dot_ssh_path}")
|
71
|
+
run_command("sudo -u dev-lxc chmod 700 #{dot_ssh_path}")
|
72
|
+
run_command("sudo -u dev-lxc touch #{dot_ssh_path}/authorized_keys")
|
73
|
+
run_command("sudo -u dev-lxc chmod 600 #{dot_ssh_path}/authorized_keys")
|
74
|
+
end
|
75
|
+
authorized_keys = IO.read("#{config_item('lxc.rootfs')}#{dot_ssh_path}/authorized_keys").split("\n")
|
76
|
+
authorized_keys.delete_if { |m| m.end_with?("## dev-lxc ##") }
|
77
|
+
unless ssh_keys.nil?
|
78
|
+
ssh_keys.each do |ssh_key|
|
79
|
+
puts "Adding SSH key #{ssh_key} to #{dot_ssh_path}/authorized_keys"
|
80
|
+
authorized_keys << IO.read(ssh_key).chomp + " ## dev-lxc ##"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
authorized_keys_content = String.new
|
84
|
+
authorized_keys_content = authorized_keys.join("\n") + "\n" unless authorized_keys.empty?
|
85
|
+
IO.write("#{config_item('lxc.rootfs')}#{dot_ssh_path}/authorized_keys", authorized_keys_content)
|
86
|
+
end
|
87
|
+
|
71
88
|
def run_command(command)
|
72
89
|
unless running?
|
73
90
|
puts "ERROR: Container '#{self.name}' must be running first"
|
data/lib/dev-lxc/server.rb
CHANGED
@@ -31,6 +31,8 @@ module DevLXC
|
|
31
31
|
@role ||= 'standalone'
|
32
32
|
@mounts = cluster_config[@server_type]["mounts"]
|
33
33
|
@mounts ||= cluster_config["mounts"]
|
34
|
+
@ssh_keys = cluster_config[@server_type]["ssh-keys"]
|
35
|
+
@ssh_keys ||= cluster_config["ssh-keys"]
|
34
36
|
@platform_image_name = cluster_config[@server_type]["platform_image"]
|
35
37
|
@platform_image_name ||= cluster_config["platform_image"]
|
36
38
|
@platform_image_options = cluster_config[@server_type]["platform_image_options"]
|
@@ -98,6 +100,7 @@ module DevLXC
|
|
98
100
|
end
|
99
101
|
@server.sync_mounts(@mounts)
|
100
102
|
@server.start
|
103
|
+
@server.sync_ssh_keys(@ssh_keys)
|
101
104
|
end
|
102
105
|
|
103
106
|
def stop
|
data/lib/dev-lxc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dev-lxc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremiah Snapp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|