dev-lxc 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +33 -0
- data/files/configs/adhoc.yml +26 -0
- data/files/configs/standalone.yml +1 -1
- data/files/configs/tier.yml +1 -1
- data/lib/dev-lxc/cli.rb +6 -4
- data/lib/dev-lxc/cluster.rb +11 -1
- data/lib/dev-lxc/container.rb +2 -0
- data/lib/dev-lxc/server.rb +18 -6
- data/lib/dev-lxc/version.rb +1 -1
- data/lib/dev-lxc.rb +21 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b9f5cdc49598e44f878dd956dd8e47a63fad02d
|
4
|
+
data.tar.gz: 6e46708544b3111bed585fd83049138ef89190f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d69e6c13466415e1471fffa0194830ba608beee4cc2ca8f47e09f2c2100d142388e0ce5499b6df53b7af7045f03dc8ab4fcdda86a338208f95896c40ae0d1c13
|
7
|
+
data.tar.gz: 5a083aac09d0e3b34996e44394bcca46a4d49cd931b6a0e57cfb2a57b3d88c7f22c871fdc896f3354acdb2768ea3d75b59f12838c14fb02c209cb7ac47c1d8b0
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# dev-lxc Change Log
|
2
2
|
|
3
|
+
## 1.3.0 (2015-05-21)
|
4
|
+
|
5
|
+
* New "adhoc" cluster functionality
|
6
|
+
* Platform images have openssh-server installed
|
7
|
+
* Platform images have "dev-lxc" user with "dev-lxc" password and passwordless sudo
|
8
|
+
* Update Analytics package in templates
|
9
|
+
|
3
10
|
## 1.2.2 (2015-05-14)
|
4
11
|
|
5
12
|
* Update version of Chef Manage in templates
|
data/README.md
CHANGED
@@ -345,6 +345,31 @@ you can run the following command.
|
|
345
345
|
dev-lxc up chef
|
346
346
|
```
|
347
347
|
|
348
|
+
### Adhoc Clusters
|
349
|
+
|
350
|
+
dev-lxc can also manage an adhoc cluster of servers.
|
351
|
+
|
352
|
+
An adhoc cluster is just a set of managed servers cloned from the specified platform
|
353
|
+
image. The servers have SSH server running, a "dev-lxc" user with "dev-lxc" password and
|
354
|
+
passwordless sudo access.
|
355
|
+
|
356
|
+
This is particularly useful when you want to use something else, such as chef-provisioning,
|
357
|
+
to configure the servers.
|
358
|
+
|
359
|
+
The number of servers, their names and their IP addresses can be changed to fit your
|
360
|
+
particular requirements.
|
361
|
+
|
362
|
+
The "adhoc" template provides an example cluster configuration suitable for creating a
|
363
|
+
Chef Delivery cluster.
|
364
|
+
|
365
|
+
```
|
366
|
+
mkdir -p /root/dev/clusters/delivery
|
367
|
+
cd /root/dev/clusters/delivery
|
368
|
+
dev-lxc init adhoc > dev-lxc.yml
|
369
|
+
cluster-view
|
370
|
+
dl up
|
371
|
+
```
|
372
|
+
|
348
373
|
### Managing Node Containers
|
349
374
|
|
350
375
|
#### Manually Create a Platform Image
|
@@ -352,6 +377,10 @@ dev-lxc up chef
|
|
352
377
|
Platform images can be used for purposes other than building clusters. For example, they can
|
353
378
|
be used as Chef nodes for testing purposes.
|
354
379
|
|
380
|
+
Platform images have openssh-server installed and running with unique SSH Host Keys.
|
381
|
+
|
382
|
+
Platform images have a "dev-lxc" user with "dev-lxc" password and passwordless sudo.
|
383
|
+
|
355
384
|
You can see a menu of platform images this tool can create by using the following command.
|
356
385
|
|
357
386
|
```
|
@@ -635,6 +664,10 @@ There are four image categories.
|
|
635
664
|
installed to provide a more typical server environment.
|
636
665
|
A few additional packages are also installed.
|
637
666
|
|
667
|
+
Platform images have openssh-server installed and running with unique SSH Host Keys.
|
668
|
+
|
669
|
+
Platform images have a "dev-lxc" user with "dev-lxc" password and passwordless sudo.
|
670
|
+
|
638
671
|
*Once this platform image is created there is rarely a need to delete it.*
|
639
672
|
|
640
673
|
2. Shared Image
|
@@ -0,0 +1,26 @@
|
|
1
|
+
## platform_image can be one of the following:
|
2
|
+
## p-centos-5, p-centos-6, p-ubuntu-1204 or p-ubuntu-1404
|
3
|
+
|
4
|
+
## Make sure a mount's source directory exists in the LXC host
|
5
|
+
|
6
|
+
## Make sure a package's path is correct
|
7
|
+
|
8
|
+
## All FQDNs and server names must end with the `.lxc` domain
|
9
|
+
|
10
|
+
## DHCP reserved (static) IPs must be selected from the IP range 10.0.3.150 - 254
|
11
|
+
|
12
|
+
## topology can be one of the following:
|
13
|
+
## standalone, tier or open-source (for the old open source 11 chef server)
|
14
|
+
|
15
|
+
adhoc:
|
16
|
+
platform_image: p-ubuntu-1404
|
17
|
+
mounts:
|
18
|
+
- /root/dev root/dev
|
19
|
+
|
20
|
+
servers:
|
21
|
+
chef.lxc:
|
22
|
+
ipaddress: 10.0.3.210
|
23
|
+
delivery.lxc:
|
24
|
+
ipaddress: 10.0.3.211
|
25
|
+
build-1.lxc:
|
26
|
+
ipaddress: 10.0.3.212
|
@@ -37,7 +37,7 @@ analytics:
|
|
37
37
|
mounts:
|
38
38
|
- /root/dev root/dev
|
39
39
|
packages:
|
40
|
-
analytics: /root/dev/chef-packages/analytics/opscode-analytics_1.1.
|
40
|
+
analytics: /root/dev/chef-packages/analytics/opscode-analytics_1.1.3-1_amd64.deb
|
41
41
|
|
42
42
|
analytics_fqdn: analytics.lxc
|
43
43
|
topology: standalone
|
data/files/configs/tier.yml
CHANGED
@@ -45,7 +45,7 @@ analytics:
|
|
45
45
|
mounts:
|
46
46
|
- /root/dev root/dev
|
47
47
|
packages:
|
48
|
-
analytics: /root/dev/chef-packages/analytics/opscode-analytics_1.1.
|
48
|
+
analytics: /root/dev/chef-packages/analytics/opscode-analytics_1.1.3-1_amd64.deb
|
49
49
|
|
50
50
|
analytics_fqdn: analytics.lxc
|
51
51
|
topology: tier
|
data/lib/dev-lxc/cli.rb
CHANGED
@@ -114,7 +114,7 @@ module DevLXC::CLI
|
|
114
114
|
|
115
115
|
desc "init [TOPOLOGY] [UNIQUE_STRING]", "Provide a cluster config file with optional uniqueness in server names and FQDNs"
|
116
116
|
def init(topology=nil, unique_string=nil)
|
117
|
-
topologies = %w(open-source standalone tier)
|
117
|
+
topologies = %w(adhoc open-source standalone tier)
|
118
118
|
if topology.nil? || ! topologies.include?(topology)
|
119
119
|
topologies_with_index = topologies.map.with_index{ |a, i| [i+1, *a]}
|
120
120
|
print_table topologies_with_index
|
@@ -148,7 +148,7 @@ module DevLXC::CLI
|
|
148
148
|
option :config, :desc => "Specify a cluster's YAML config file. `./dev-lxc.yml` will be used by default"
|
149
149
|
def status(server_name_regex=nil)
|
150
150
|
cluster = get_cluster(options[:config])
|
151
|
-
puts "Chef Server: https://#{cluster.api_fqdn}\n\n"
|
151
|
+
puts "Chef Server: https://#{cluster.api_fqdn}\n\n" if cluster.api_fqdn
|
152
152
|
puts "Analytics: https://#{cluster.analytics_fqdn}\n\n" if cluster.analytics_fqdn
|
153
153
|
servers = Array.new
|
154
154
|
match_server_name_regex(server_name_regex).map { |s| servers << s.server.status }
|
@@ -211,8 +211,10 @@ module DevLXC::CLI
|
|
211
211
|
images.each_with_index do |(platform_name, shared), images_index|
|
212
212
|
shared.each_with_index do |(shared_name, final), shared_index|
|
213
213
|
printf "Platform: %27s %s\n", (LXC::Container.new(platform_name, lxc_config_path).defined? ? "Created" : "Not Created"), platform_name
|
214
|
-
|
215
|
-
|
214
|
+
unless shared_name.empty?
|
215
|
+
puts "|"
|
216
|
+
printf "\\_ Shared: %26s %s\n", (LXC::Container.new(shared_name, lxc_config_path).defined? ? "Created" : "Not Created"), shared_name
|
217
|
+
end
|
216
218
|
final.each_with_index do |final_name, final_index|
|
217
219
|
puts " |"
|
218
220
|
unique_name = "u-#{final_name}"
|
data/lib/dev-lxc/cluster.rb
CHANGED
@@ -10,6 +10,10 @@ module DevLXC
|
|
10
10
|
@lxc_config_path = @cluster_config["lxc_config_path"]
|
11
11
|
@lxc_config_path ||= "/var/lib/dev-lxc"
|
12
12
|
|
13
|
+
if @cluster_config["adhoc"]
|
14
|
+
@adhoc_servers = @cluster_config["adhoc"]["servers"].keys
|
15
|
+
end
|
16
|
+
|
13
17
|
if @cluster_config["chef-server"]
|
14
18
|
@chef_server_topology = @cluster_config["chef-server"]["topology"]
|
15
19
|
@api_fqdn = @cluster_config["chef-server"]["api_fqdn"]
|
@@ -44,6 +48,12 @@ module DevLXC
|
|
44
48
|
end
|
45
49
|
|
46
50
|
def servers
|
51
|
+
adhoc_servers = Array.new
|
52
|
+
if @adhoc_servers
|
53
|
+
@adhoc_servers.each do |name|
|
54
|
+
adhoc_servers << Server.new(name, 'adhoc', @cluster_config)
|
55
|
+
end
|
56
|
+
end
|
47
57
|
chef_servers = Array.new
|
48
58
|
chef_servers << Server.new(@chef_server_bootstrap_backend, 'chef-server', @cluster_config) if @chef_server_bootstrap_backend
|
49
59
|
if @chef_server_topology == "tier"
|
@@ -58,7 +68,7 @@ module DevLXC
|
|
58
68
|
analytics_servers << Server.new(frontend_name, 'analytics', @cluster_config)
|
59
69
|
end
|
60
70
|
end
|
61
|
-
servers = chef_servers + analytics_servers
|
71
|
+
servers = adhoc_servers + chef_servers + analytics_servers
|
62
72
|
end
|
63
73
|
|
64
74
|
def chef_repo(force=false, pivotal=false)
|
data/lib/dev-lxc/container.rb
CHANGED
@@ -185,6 +185,8 @@ ssl_verify_mode :verify_none
|
|
185
185
|
end
|
186
186
|
base_container.clone(self.name, {:flags => LXC::LXC_CLONE_SNAPSHOT})
|
187
187
|
self.load_config
|
188
|
+
puts "Deleting SSH Server Host Keys"
|
189
|
+
FileUtils.rm_f(Dir.glob("#{self.config_item('lxc.rootfs')}/etc/ssh/ssh_host*_key*"))
|
188
190
|
end
|
189
191
|
end
|
190
192
|
self.start unless self.running?
|
data/lib/dev-lxc/server.rb
CHANGED
@@ -29,6 +29,8 @@ module DevLXC
|
|
29
29
|
@packages = cluster_config[@server_type]["packages"]
|
30
30
|
|
31
31
|
case @server_type
|
32
|
+
when 'adhoc'
|
33
|
+
@shared_image_name = ''
|
32
34
|
when 'analytics'
|
33
35
|
@shared_image_name = "s#{@platform_image_name[1..-1]}"
|
34
36
|
@shared_image_name += "-analytics-#{Regexp.last_match[1].gsub(".", "-")}" if @packages["analytics"].to_s.match(/[_-]((\d+\.?){3,})/)
|
@@ -161,14 +163,22 @@ module DevLXC
|
|
161
163
|
return
|
162
164
|
else
|
163
165
|
puts "Creating container '#{@server.name}'"
|
164
|
-
|
165
|
-
|
166
|
-
|
166
|
+
if @server_type == 'adhoc'
|
167
|
+
platform_image = DevLXC.create_platform_image(@platform_image_name, @lxc_config_path)
|
168
|
+
puts "Cloning platform image '#{platform_image.name}' into container '#{@server.name}'"
|
169
|
+
platform_image.clone(@server.name, {:flags => LXC::LXC_CLONE_SNAPSHOT})
|
170
|
+
else
|
171
|
+
unless @server.name == @chef_server_bootstrap_backend || DevLXC::Container.new(@chef_server_bootstrap_backend, @lxc_config_path).defined?
|
172
|
+
puts "ERROR: The bootstrap backend server '#{@chef_server_bootstrap_backend}' must be created first."
|
173
|
+
exit 1
|
174
|
+
end
|
175
|
+
shared_image = create_shared_image
|
176
|
+
puts "Cloning shared image '#{shared_image.name}' into container '#{@server.name}'"
|
177
|
+
shared_image.clone(@server.name, {:flags => LXC::LXC_CLONE_SNAPSHOT})
|
167
178
|
end
|
168
|
-
shared_image = create_shared_image
|
169
|
-
puts "Cloning shared image '#{shared_image.name}' into container '#{@server.name}'"
|
170
|
-
shared_image.clone(@server.name, {:flags => LXC::LXC_CLONE_SNAPSHOT})
|
171
179
|
@server = DevLXC::Container.new(@server.name, @lxc_config_path)
|
180
|
+
puts "Deleting SSH Server Host Keys"
|
181
|
+
FileUtils.rm_f(Dir.glob("#{@server.config_item('lxc.rootfs')}/etc/ssh/ssh_host*_key*"))
|
172
182
|
puts "Adding lxc.hook.post-stop hook"
|
173
183
|
@server.set_config_item("lxc.hook.post-stop", "/usr/local/share/lxc/hooks/post-stop-dhcp-release")
|
174
184
|
@server.save_config
|
@@ -225,6 +235,8 @@ module DevLXC
|
|
225
235
|
puts "Cloning platform image '#{platform_image.name}' into shared image '#{shared_image.name}'"
|
226
236
|
platform_image.clone(shared_image.name, {:flags => LXC::LXC_CLONE_SNAPSHOT})
|
227
237
|
shared_image = DevLXC::Container.new(shared_image.name, @lxc_config_path)
|
238
|
+
puts "Deleting SSH Server Host Keys"
|
239
|
+
FileUtils.rm_f(Dir.glob("#{shared_image.config_item('lxc.rootfs')}/etc/ssh/ssh_host*_key*"))
|
228
240
|
|
229
241
|
# Disable certain sysctl.d files in Ubuntu 10.04, they cause `start procps` to fail
|
230
242
|
# Enterprise Chef server's postgresql recipe expects to be able to `start procps`
|
data/lib/dev-lxc/version.rb
CHANGED
data/lib/dev-lxc.rb
CHANGED
@@ -42,18 +42,35 @@ module DevLXC
|
|
42
42
|
"#{platform_image.config_item('lxc.rootfs')}/etc/sysctl.d/10-console-messages.conf.orig")
|
43
43
|
end
|
44
44
|
platform_image.run_command("apt-get update")
|
45
|
-
platform_image.run_command("apt-get install -y standard^ server^ vim-nox emacs23-nox curl tree")
|
45
|
+
platform_image.run_command("apt-get install -y standard^ server^ vim-nox emacs23-nox curl tree openssh-server")
|
46
|
+
IO.write("#{platform_image.config_item('lxc.rootfs')}/etc/rc.local", "/usr/sbin/dpkg-reconfigure openssh-server\n")
|
47
|
+
FileUtils.chmod(0755, "#{platform_image.config_item('lxc.rootfs')}/etc/rc.local")
|
46
48
|
when "p-ubuntu-1204", "p-ubuntu-1404"
|
47
49
|
platform_image.run_command("apt-get update")
|
48
|
-
platform_image.run_command("apt-get install -y standard^ server^ vim-nox emacs23-nox tree")
|
50
|
+
platform_image.run_command("apt-get install -y standard^ server^ vim-nox emacs23-nox tree openssh-server")
|
51
|
+
IO.write("#{platform_image.config_item('lxc.rootfs')}/etc/rc.local", "/usr/sbin/dpkg-reconfigure openssh-server\n")
|
52
|
+
FileUtils.chmod(0755, "#{platform_image.config_item('lxc.rootfs')}/etc/rc.local")
|
49
53
|
when "p-centos-5"
|
50
54
|
# downgrade openssl temporarily to overcome an install bug
|
51
55
|
# reference: http://www.hack.net.br/blog/2014/02/12/openssl-conflicts-with-file-from-package-openssl/
|
52
56
|
platform_image.run_command("yum downgrade -y openssl")
|
53
|
-
platform_image.run_command("yum install -y @base @core vim-enhanced emacs-nox tree")
|
57
|
+
platform_image.run_command("yum install -y @base @core vim-enhanced emacs-nox tree openssh-server")
|
58
|
+
FileUtils.mkdir_p("#{platform_image.config_item('lxc.rootfs')}/etc/sudoers.d")
|
59
|
+
FileUtils.chmod(0750, "#{platform_image.config_item('lxc.rootfs')}/etc/sudoers.d")
|
60
|
+
append_line_to_file("#{platform_image.config_item('lxc.rootfs')}/etc/sudoers", "\n#includedir /etc/sudoers.d\n")
|
54
61
|
when "p-centos-6"
|
55
|
-
platform_image.run_command("yum install -y @base @core vim-enhanced emacs-nox tree")
|
62
|
+
platform_image.run_command("yum install -y @base @core vim-enhanced emacs-nox tree openssh-server")
|
56
63
|
end
|
64
|
+
platform_image.run_command("useradd --create-home --shell /bin/bash --password $6$q3FDMpMZ$zfahCxEWHbzuEV98QPzhGZ7fLtGcLNZrbKK7OAYGXmJXZc07WbcxVnDwrMyX/cL6vSp4/IjlrVUZFBp7Orhyu1 dev-lxc")
|
65
|
+
|
66
|
+
FileUtils.mkdir_p("#{platform_image.config_item('lxc.rootfs')}/home/dev-lxc/.ssh")
|
67
|
+
FileUtils.chmod(0700, "#{platform_image.config_item('lxc.rootfs')}/home/dev-lxc/.ssh")
|
68
|
+
FileUtils.touch("#{platform_image.config_item('lxc.rootfs')}/home/dev-lxc/.ssh/authorized_keys")
|
69
|
+
FileUtils.chmod(0600, "#{platform_image.config_item('lxc.rootfs')}/home/dev-lxc/.ssh/authorized_keys")
|
70
|
+
platform_image.run_command("chown -R dev-lxc:dev-lxc /home/dev-lxc/.ssh")
|
71
|
+
|
72
|
+
IO.write("#{platform_image.config_item('lxc.rootfs')}/etc/sudoers.d/dev-lxc", "dev-lxc ALL=NOPASSWD:ALL\n")
|
73
|
+
FileUtils.chmod(0440, "#{platform_image.config_item('lxc.rootfs')}/etc/sudoers.d/dev-lxc")
|
57
74
|
platform_image.stop
|
58
75
|
return platform_image
|
59
76
|
end
|
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.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremiah Snapp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- Rakefile
|
83
83
|
- bin/dev-lxc
|
84
84
|
- dev-lxc.gemspec
|
85
|
+
- files/configs/adhoc.yml
|
85
86
|
- files/configs/open-source.yml
|
86
87
|
- files/configs/standalone.yml
|
87
88
|
- files/configs/tier.yml
|