dev-lxc 2.2.7 → 2.3.0
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 +12 -0
- data/README.md +3 -3
- data/docs/configuration.md +4 -4
- data/lib/dev-lxc/cli.rb +12 -14
- data/lib/dev-lxc/cluster.rb +99 -24
- data/lib/dev-lxc/server.rb +5 -8
- data/lib/dev-lxc/version.rb +1 -1
- data/lib/dev-lxc.rb +0 -8
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80dd5ce814277d70504316af75ab5a801489356a
|
4
|
+
data.tar.gz: 62c7bb81010529e775615c8e31da47b1360686c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4ce050e1637a22d0dc990560ebf43b39527600bdacf6a048b01a37e8aa45505c327255f59c45f4829576d07c45ea8cf74dd15497e243a638cc90d71eec91c69
|
7
|
+
data.tar.gz: 62b58c1d3956bed13dd7c08a819ac73abaced1cf76e8c7dbe82f055bd3af2e485523b62dfeac5e8f6816b1b79d9d810f2d55cf9131c1cffb87da9acc546ca36f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# dev-lxc Change Log
|
2
2
|
|
3
|
+
## 2.3.0 (2016-11-22)
|
4
|
+
|
5
|
+
* Create DNS records for all servers before starting a server
|
6
|
+
* Delete DNS records for all servers if all are stopped
|
7
|
+
* Add ability to build Automate Job Dispatch Runners
|
8
|
+
* Enable Compliance profiles asset store in Automate
|
9
|
+
* Enable Automate Compliance profiles proxy in Chef Server
|
10
|
+
* Add ability to setup Compliance and create admin user
|
11
|
+
* Fix dev-lxc.yml parsing bug
|
12
|
+
* Allow for snapshot comments to be empty
|
13
|
+
* Fix 'up' command's output so there is a blank line between each server
|
14
|
+
|
3
15
|
## 2.2.7 (2016-09-26)
|
4
16
|
|
5
17
|
* Improve file existence test during dev-lxc.yml validation
|
data/README.md
CHANGED
@@ -119,10 +119,10 @@ mkdir -p /root/work/clusters/automate
|
|
119
119
|
|
120
120
|
Then use the `init` subcommand to generate a sample configuration using the available options. Run `dl help init` to see what options are available.
|
121
121
|
|
122
|
-
The following command configures a standalone Chef Server, a Chef Automate server and a
|
122
|
+
The following command configures a standalone Chef Server, a Chef Automate server and a job dispatch runner.
|
123
123
|
|
124
124
|
```
|
125
|
-
dl init --chef --automate --
|
125
|
+
dl init --chef --automate --runners -f /root/work/clusters/automate/dev-lxc.yml
|
126
126
|
```
|
127
127
|
|
128
128
|
We can easily append additional configurations to this file. For example, the following command appends an infrastructure node.
|
@@ -161,7 +161,7 @@ cluster-view /root/work/clusters/automate
|
|
161
161
|
|
162
162
|
Many dev-lxc subcommands can act on a subset of the cluster's servers by specifying a regular expression that matches the desired server names.
|
163
163
|
|
164
|
-
For example, the following command will show the status of the
|
164
|
+
For example, the following command will show the status of the infrastructure node.
|
165
165
|
|
166
166
|
```
|
167
167
|
dl status node
|
data/docs/configuration.md
CHANGED
@@ -5,10 +5,10 @@ dev-lxc uses a YAML configuration file named `dev-lxc.yml` to define a cluster.
|
|
5
5
|
The `init` command generates sample config files for various server types.
|
6
6
|
|
7
7
|
Let's generate a config for a cluster with a standalone Chef Server, Chef Automate server,
|
8
|
-
private Supermarket server,
|
8
|
+
private Supermarket server, job dispatch runner and an infrastructure node.
|
9
9
|
|
10
10
|
```
|
11
|
-
dev-lxc init --chef --automate --supermarket --
|
11
|
+
dev-lxc init --chef --automate --supermarket --runners --nodes > dev-lxc.yml
|
12
12
|
```
|
13
13
|
|
14
14
|
The contents of `dev-lxc.yml` should look like this.
|
@@ -63,9 +63,9 @@ automate:
|
|
63
63
|
chef_org: delivery
|
64
64
|
enterprise_name: demo-ent
|
65
65
|
|
66
|
-
|
66
|
+
runners:
|
67
67
|
servers:
|
68
|
-
|
68
|
+
runner-1.lxc:
|
69
69
|
products:
|
70
70
|
chefdk: # downloaded only
|
71
71
|
|
data/lib/dev-lxc/cli.rb
CHANGED
@@ -55,6 +55,7 @@ module DevLXC::CLI
|
|
55
55
|
option :supermarket, :type => :boolean, :desc => "Supermarket Server"
|
56
56
|
option :automate, :type => :boolean, :desc => "Automate Server"
|
57
57
|
option :build_nodes, :type => :boolean, :desc => "Build Nodes"
|
58
|
+
option :runners, :type => :boolean, :desc => "Runners"
|
58
59
|
option :adhoc, :type => :boolean, :desc => "Adhoc Servers"
|
59
60
|
option :append, :aliases => "-a", :type => :boolean, :desc => "Do not generate the global config header"
|
60
61
|
option :filename, :aliases => "-f", :desc => "Write generated content to FILE rather than standard output."
|
@@ -140,6 +141,13 @@ build-nodes:
|
|
140
141
|
build-node-1.lxc:
|
141
142
|
products:
|
142
143
|
chefdk: # downloaded only
|
144
|
+
)
|
145
|
+
runners_config = %Q(
|
146
|
+
runners:
|
147
|
+
servers:
|
148
|
+
runner-1.lxc:
|
149
|
+
products:
|
150
|
+
chefdk: # downloaded only
|
143
151
|
)
|
144
152
|
analytics_config = %Q(
|
145
153
|
analytics:
|
@@ -151,6 +159,7 @@ analytics:
|
|
151
159
|
)
|
152
160
|
compliance_config = %Q(
|
153
161
|
compliance:
|
162
|
+
admin_user: admin # the password will be the same as the username
|
154
163
|
servers:
|
155
164
|
compliance.lxc:
|
156
165
|
ipaddress: 10.0.3.205
|
@@ -228,6 +237,7 @@ nodes:
|
|
228
237
|
config += supermarket_config if options[:supermarket]
|
229
238
|
config += automate_config if options[:automate]
|
230
239
|
config += build_nodes_config if options[:build_nodes]
|
240
|
+
config += runners_config if options[:runners]
|
231
241
|
config += adhoc_config if options[:adhoc]
|
232
242
|
config += chef_backend_config if options[:chef_backend]
|
233
243
|
config += nodes_config if options[:nodes]
|
@@ -330,7 +340,6 @@ nodes:
|
|
330
340
|
def up(server_name_regex=nil)
|
331
341
|
start_time = Time.now
|
332
342
|
get_cluster(options[:config]).up(server_name_regex)
|
333
|
-
puts
|
334
343
|
print_elapsed_time(Time.now - start_time)
|
335
344
|
end
|
336
345
|
|
@@ -338,7 +347,7 @@ nodes:
|
|
338
347
|
option :config, :desc => "Specify a cluster's YAML config file. `./dev-lxc.yml` will be used by default"
|
339
348
|
def halt(server_name_regex=nil)
|
340
349
|
start_time = Time.now
|
341
|
-
get_cluster(options[:config]).
|
350
|
+
get_cluster(options[:config]).halt(server_name_regex)
|
342
351
|
print_elapsed_time(Time.now - start_time)
|
343
352
|
end
|
344
353
|
|
@@ -394,19 +403,8 @@ nodes:
|
|
394
403
|
option :config, :desc => "Specify a cluster's YAML config file. `./dev-lxc.yml` will be used by default"
|
395
404
|
option :force, :aliases => "-f", :type => :boolean, :desc => "Destroy servers without confirmation"
|
396
405
|
def destroy(server_name_regex=nil)
|
397
|
-
servers = get_cluster(options[:config]).get_sorted_servers(server_name_regex)
|
398
|
-
if servers.empty?
|
399
|
-
puts "No matching server names were found"
|
400
|
-
exit
|
401
|
-
end
|
402
|
-
unless options[:force]
|
403
|
-
confirmation_string = String.new
|
404
|
-
servers.reverse_each { |s| confirmation_string += "#{s.name}\n" }
|
405
|
-
confirmation_string += "Are you sure you want to destroy these servers? (y/N)\n"
|
406
|
-
return unless yes?(confirmation_string)
|
407
|
-
end
|
408
406
|
start_time = Time.now
|
409
|
-
|
407
|
+
get_cluster(options[:config]).destroy(server_name_regex, options[:force])
|
410
408
|
print_elapsed_time(Time.now - start_time)
|
411
409
|
end
|
412
410
|
|
data/lib/dev-lxc/cluster.rb
CHANGED
@@ -12,27 +12,31 @@ module DevLXC
|
|
12
12
|
@config = Hash.new { |hash, key| hash[key] = {} }
|
13
13
|
@server_configs = Hash.new
|
14
14
|
|
15
|
-
%w(adhoc analytics automate build-nodes chef-backend chef-server compliance nodes supermarket).each do |server_type|
|
15
|
+
%w(adhoc analytics automate build-nodes chef-backend chef-server compliance nodes runners supermarket).each do |server_type|
|
16
16
|
if cluster_config[server_type]
|
17
|
-
mounts = ["/var/dev-lxc var/dev-lxc"]
|
18
|
-
if cluster_config[server_type]["mounts"]
|
19
|
-
mounts.concat(cluster_config[server_type]["mounts"])
|
20
|
-
elsif cluster_config["mounts"]
|
21
|
-
mounts.concat(cluster_config["mounts"])
|
22
|
-
end
|
23
|
-
ssh_keys = cluster_config[server_type]["ssh-keys"]
|
24
|
-
ssh_keys ||= cluster_config["ssh-keys"]
|
25
|
-
base_container_name = cluster_config[server_type]["base_container"]
|
26
|
-
base_container_name ||= cluster_config["base_container"]
|
27
|
-
|
28
17
|
if cluster_config[server_type]["servers"]
|
29
18
|
cluster_config[server_type]["servers"].each do |server_name, server_config|
|
30
19
|
server_config ||= Hash.new
|
20
|
+
|
31
21
|
products = server_config['products']
|
32
22
|
products ||= Hash.new
|
23
|
+
|
24
|
+
mounts = ["/var/dev-lxc var/dev-lxc"]
|
25
|
+
if cluster_config[server_type]["mounts"]
|
26
|
+
mounts.concat(cluster_config[server_type]["mounts"])
|
27
|
+
elsif cluster_config["mounts"]
|
28
|
+
mounts.concat(cluster_config["mounts"])
|
29
|
+
end
|
33
30
|
mounts = ["/var/dev-lxc var/dev-lxc"] + server_config["mounts"] if server_config["mounts"]
|
31
|
+
|
32
|
+
ssh_keys = cluster_config[server_type]["ssh-keys"]
|
33
|
+
ssh_keys ||= cluster_config["ssh-keys"]
|
34
34
|
ssh_keys = server_config["ssh-keys"] if server_config["ssh-keys"]
|
35
|
+
|
36
|
+
base_container_name = cluster_config[server_type]["base_container"]
|
37
|
+
base_container_name ||= cluster_config["base_container"]
|
35
38
|
base_container_name = server_config["base_container"] if server_config["base_container"]
|
39
|
+
|
36
40
|
@server_configs[server_name] = {
|
37
41
|
server_type: server_type,
|
38
42
|
products: products,
|
@@ -143,6 +147,11 @@ module DevLXC
|
|
143
147
|
(server_name, server_config) = cluster_config[server_type]["servers"].first
|
144
148
|
@config[server_type][:fqdn] = server_name
|
145
149
|
end
|
150
|
+
when "compliance"
|
151
|
+
unless cluster_config[server_type]["servers"].first.nil?
|
152
|
+
(server_name, server_config) = cluster_config[server_type]["servers"].first
|
153
|
+
@server_configs[server_name][:admin_user] = cluster_config[server_type]["admin_user"]
|
154
|
+
end
|
146
155
|
when "automate"
|
147
156
|
unless cluster_config[server_type]["servers"].first.nil?
|
148
157
|
(server_name, server_config) = cluster_config[server_type]["servers"].first
|
@@ -260,7 +269,7 @@ module DevLXC
|
|
260
269
|
|
261
270
|
# the order of this list of server_types matters
|
262
271
|
# it determines the order in which actions are applied to each server_type
|
263
|
-
%w(chef-backend chef-server analytics compliance supermarket automate build-nodes nodes adhoc).each do |server_type|
|
272
|
+
%w(chef-backend chef-server analytics compliance supermarket automate build-nodes runners nodes adhoc).each do |server_type|
|
264
273
|
unless @config[server_type].empty?
|
265
274
|
case server_type
|
266
275
|
when "chef-backend"
|
@@ -280,7 +289,7 @@ module DevLXC
|
|
280
289
|
end
|
281
290
|
end
|
282
291
|
end
|
283
|
-
if %w(adhoc automate build-nodes compliance nodes supermarket).include?(server_type)
|
292
|
+
if %w(adhoc automate build-nodes compliance nodes runners supermarket).include?(server_type)
|
284
293
|
server_configs = @server_configs.select { |server_name, server_config| server_config[:server_type] == server_type }
|
285
294
|
server_configs.each_key { |server_name| servers << get_server(server_name) }
|
286
295
|
end
|
@@ -288,6 +297,33 @@ module DevLXC
|
|
288
297
|
servers.select { |s| s.name =~ /#{server_name_regex}/ }
|
289
298
|
end
|
290
299
|
|
300
|
+
def destroy(server_name_regex=nil, force=false)
|
301
|
+
servers = get_sorted_servers(server_name_regex)
|
302
|
+
if servers.empty?
|
303
|
+
puts "No matching server names were found"
|
304
|
+
exit
|
305
|
+
end
|
306
|
+
unless force
|
307
|
+
confirmation_string = String.new
|
308
|
+
servers.reverse_each { |s| confirmation_string += "#{s.name}\n" }
|
309
|
+
confirmation_string += "Are you sure you want to destroy these servers? (y/N)\n"
|
310
|
+
return unless yes?(confirmation_string)
|
311
|
+
end
|
312
|
+
servers.reverse_each { |s| s.destroy; puts }
|
313
|
+
delete_dns_records unless get_sorted_servers.any? { |s| s.container.state != :stopped }
|
314
|
+
end
|
315
|
+
|
316
|
+
def halt(server_name_regex=nil)
|
317
|
+
servers = get_sorted_servers(server_name_regex)
|
318
|
+
servers.reverse_each { |s| s.stop; puts }
|
319
|
+
delete_dns_records unless get_sorted_servers.any? { |s| s.container.state != :stopped }
|
320
|
+
end
|
321
|
+
|
322
|
+
def delete_dns_records
|
323
|
+
@server_configs.keys.each { |server_name| DevLXC::search_file_delete_line("/etc/lxc/addn-hosts.conf", /\s#{server_name}/) }
|
324
|
+
DevLXC::reload_dnsmasq
|
325
|
+
end
|
326
|
+
|
291
327
|
def up(server_name_regex=nil)
|
292
328
|
abort_up = false
|
293
329
|
configured_servers = Array.new
|
@@ -359,7 +395,7 @@ module DevLXC
|
|
359
395
|
abort_up = true
|
360
396
|
end
|
361
397
|
end
|
362
|
-
if @server_configs[server.name][:server_type]
|
398
|
+
if %w(build-nodes runners).include?(@server_configs[server.name][:server_type])
|
363
399
|
if @config['chef-server'][:bootstrap_backend].nil?
|
364
400
|
puts "ERROR: '#{server.name}' requires a Chef Server bootstrap backend to be configured first."
|
365
401
|
abort_up = true
|
@@ -394,25 +430,26 @@ module DevLXC
|
|
394
430
|
clone_from_base_container(server) unless server.container.defined?
|
395
431
|
end
|
396
432
|
servers = get_sorted_servers(server_name_regex)
|
433
|
+
create_dns_records unless servers.empty?
|
397
434
|
servers.each do |server|
|
398
|
-
if @server_configs[server.name][:server_type]
|
435
|
+
if %w(build-nodes runners).include?(@server_configs[server.name][:server_type])
|
399
436
|
next if @server_configs[server.name][:required_products]["chefdk"] && @server_configs[server.name][:required_products].length == 1
|
400
437
|
end
|
401
438
|
install_products(server) unless @server_configs[server.name][:required_products].empty?
|
402
439
|
end
|
403
440
|
servers.each do |server|
|
404
|
-
if server.snapshot_list.select { |sn| sn[2].start_with?("dev-lxc build: completed") }.empty?
|
441
|
+
if server.snapshot_list.select { |sn| sn[2].to_s.start_with?("dev-lxc build: completed") }.empty?
|
405
442
|
if server.name == @config["chef-backend"][:bootstrap_frontend]
|
406
443
|
running_backends = Array.new
|
407
444
|
@config["chef-backend"][:backends].reverse_each do |server_name|
|
408
445
|
backend = get_server(server_name)
|
409
|
-
if backend.container.defined? && backend.snapshot_list.select { |sn| sn[2].start_with?("dev-lxc build: backend cluster configured but frontend not bootstrapped") }.empty?
|
446
|
+
if backend.container.defined? && backend.snapshot_list.select { |sn| sn[2].to_s.start_with?("dev-lxc build: backend cluster configured but frontend not bootstrapped") }.empty?
|
410
447
|
if backend.container.running?
|
411
448
|
running_backends << backend.name
|
412
449
|
backend.stop
|
413
450
|
end
|
414
451
|
backend.snapshot("dev-lxc build: backend cluster configured but frontend not bootstrapped")
|
415
|
-
snapshot = backend.snapshot_list.select { |sn| sn[2].start_with?("dev-lxc build: completed") }.first
|
452
|
+
snapshot = backend.snapshot_list.select { |sn| sn[2].to_s.start_with?("dev-lxc build: completed") }.first
|
416
453
|
backend.snapshot_destroy(snapshot.first) if snapshot
|
417
454
|
end
|
418
455
|
end
|
@@ -439,6 +476,20 @@ module DevLXC
|
|
439
476
|
end
|
440
477
|
end
|
441
478
|
|
479
|
+
def create_dns_records
|
480
|
+
get_sorted_servers.each do |server|
|
481
|
+
ipaddress = server.container.ip_addresses.first
|
482
|
+
ipaddress ||= @server_configs[server.name][:ipaddress]
|
483
|
+
next unless ipaddress
|
484
|
+
additional_fqdn = @server_configs[server.name][:additional_fqdn]
|
485
|
+
dns_record = "#{ipaddress} #{server.name}"
|
486
|
+
dns_record += " #{additional_fqdn}\n" if additional_fqdn
|
487
|
+
DevLXC::search_file_delete_line("/etc/lxc/addn-hosts.conf", /\s#{server.name}/)
|
488
|
+
DevLXC::append_line_to_file("/etc/lxc/addn-hosts.conf", dns_record)
|
489
|
+
end
|
490
|
+
DevLXC::reload_dnsmasq
|
491
|
+
end
|
492
|
+
|
442
493
|
def clone_from_base_container(server)
|
443
494
|
server_type = @server_configs[server.name][:server_type]
|
444
495
|
base_container = DevLXC::Container.new(@server_configs[server.name][:base_container_name])
|
@@ -491,10 +542,10 @@ module DevLXC
|
|
491
542
|
servers.each do |server|
|
492
543
|
products = @server_configs[server.name][:products]
|
493
544
|
@server_configs[server.name][:required_products] = Hash.new
|
494
|
-
if !force && !server.snapshot_list.select { |sn| sn[2].start_with?("dev-lxc build: products installed") }.empty?
|
545
|
+
if !force && !server.snapshot_list.select { |sn| sn[2].to_s.start_with?("dev-lxc build: products installed") }.empty?
|
495
546
|
# Skipping product cache preparation for container because it has a 'products installed' snapshot
|
496
547
|
next
|
497
|
-
elsif !force && !server.snapshot_list.select { |sn| sn[2].start_with?("dev-lxc build: completed") }.empty?
|
548
|
+
elsif !force && !server.snapshot_list.select { |sn| sn[2].to_s.start_with?("dev-lxc build: completed") }.empty?
|
498
549
|
# Skipping product cache preparation for container because it has a 'build: completed' snapshot
|
499
550
|
next
|
500
551
|
end
|
@@ -537,10 +588,10 @@ module DevLXC
|
|
537
588
|
end
|
538
589
|
|
539
590
|
def install_products(server)
|
540
|
-
if !server.snapshot_list.select { |sn| sn[2].start_with?("dev-lxc build: products installed") }.empty?
|
591
|
+
if !server.snapshot_list.select { |sn| sn[2].to_s.start_with?("dev-lxc build: products installed") }.empty?
|
541
592
|
puts "Skipping product installation for container '#{server.name}' because it already has a 'products installed' snapshot"
|
542
593
|
return
|
543
|
-
elsif !server.snapshot_list.select { |sn| sn[2].start_with?("dev-lxc build: completed") }.empty?
|
594
|
+
elsif !server.snapshot_list.select { |sn| sn[2].to_s.start_with?("dev-lxc build: completed") }.empty?
|
544
595
|
puts "Skipping product installation for container '#{server.name}' because it already has a 'build: completed' snapshot"
|
545
596
|
return
|
546
597
|
end
|
@@ -551,7 +602,7 @@ module DevLXC
|
|
551
602
|
server.start
|
552
603
|
end
|
553
604
|
@server_configs[server.name][:required_products].each do |product_name, package_source|
|
554
|
-
next if @server_configs[server.name][:server_type]
|
605
|
+
next if %w(build-nodes runners).include?(@server_configs[server.name][:server_type]) && product_name == "chefdk"
|
555
606
|
server.install_package(package_source)
|
556
607
|
end
|
557
608
|
server.stop
|
@@ -575,6 +626,9 @@ module DevLXC
|
|
575
626
|
when 'build-nodes'
|
576
627
|
sleep 5 # give time for DNS resolution to be available
|
577
628
|
configure_build_node(server)
|
629
|
+
when 'runners'
|
630
|
+
sleep 5 # give time for DNS resolution to be available
|
631
|
+
configure_runner(server)
|
578
632
|
when 'chef-backend'
|
579
633
|
configure_chef_backend(server) if required_products.include?('chef-backend')
|
580
634
|
if required_products.include?('chef-server')
|
@@ -639,6 +693,9 @@ module DevLXC
|
|
639
693
|
setup_cmd += " --no-build-node"
|
640
694
|
setup_cmd += " --configure"
|
641
695
|
run_ctl(server, "delivery", setup_cmd)
|
696
|
+
|
697
|
+
# enable Compliance profiles asset store
|
698
|
+
DevLXC::append_line_to_file("#{server.container.config_item('lxc.rootfs')}/etc/delivery/delivery.rb", "compliance_profiles['enable'] = true")
|
642
699
|
end
|
643
700
|
|
644
701
|
def print_automate_credentials
|
@@ -670,6 +727,18 @@ module DevLXC
|
|
670
727
|
end
|
671
728
|
end
|
672
729
|
|
730
|
+
def configure_runner(server)
|
731
|
+
automate_server_name = @server_configs.select {|name, config| config[:server_type] == 'automate'}.keys.first
|
732
|
+
if automate_server_name
|
733
|
+
automate_server = get_server(automate_server_name)
|
734
|
+
install_runner_cmd = "install-runner #{server.name} dev-lxc"
|
735
|
+
install_runner_cmd += " --password dev-lxc"
|
736
|
+
install_runner_cmd += " --installer #{@server_configs[server.name][:required_products]["chefdk"]}"
|
737
|
+
install_runner_cmd += " --yes"
|
738
|
+
run_ctl(automate_server, "delivery", install_runner_cmd)
|
739
|
+
end
|
740
|
+
end
|
741
|
+
|
673
742
|
def configure_chef_client(server, dot_chef_path)
|
674
743
|
puts "Configuring Chef Client in container '#{server.name}'"
|
675
744
|
|
@@ -816,6 +885,11 @@ data_collector.token "93a49a4f2482c64126f7b6015e6b0f30284287ee4054ff8807fb63d9cb
|
|
816
885
|
FileUtils.mkdir_p("#{server.container.config_item('lxc.rootfs')}/var/opt/chef-compliance")
|
817
886
|
FileUtils.touch("#{server.container.config_item('lxc.rootfs')}/var/opt/chef-compliance/.license.accepted")
|
818
887
|
run_ctl(server, "chef-compliance", "reconfigure")
|
888
|
+
admin_user = @server_configs[server.name][:admin_user]
|
889
|
+
if admin_user
|
890
|
+
run_ctl(server, "chef-compliance", "user-create #{admin_user} #{admin_user}")
|
891
|
+
run_ctl(server, "chef-compliance", "restart core")
|
892
|
+
end
|
819
893
|
end
|
820
894
|
|
821
895
|
def configure_supermarket(server)
|
@@ -1034,6 +1108,7 @@ oc_id['applications']['supermarket'] = {
|
|
1034
1108
|
chef_server_config += %Q(
|
1035
1109
|
data_collector['root_url'] = "https://#{automate_server_name}/data-collector/v0/"
|
1036
1110
|
data_collector['token'] = "93a49a4f2482c64126f7b6015e6b0f30284287ee4054ff8807fb63d9cbd1c506"
|
1111
|
+
profiles['root_url'] = "https://#{automate_server_name}"
|
1037
1112
|
)
|
1038
1113
|
end
|
1039
1114
|
return chef_server_config
|
data/lib/dev-lxc/server.rb
CHANGED
@@ -36,19 +36,17 @@ module DevLXC
|
|
36
36
|
|
37
37
|
def start
|
38
38
|
hwaddr = @container.config_item("lxc.network.0.hwaddr")
|
39
|
-
if @ipaddress
|
40
|
-
DevLXC.assign_ip_address(@ipaddress, @container.name, hwaddr)
|
41
|
-
DevLXC.create_dns_record(@additional_fqdn, @container.name, @ipaddress) unless @additional_fqdn.nil?
|
42
|
-
end
|
39
|
+
DevLXC.assign_ip_address(@ipaddress, @container.name, hwaddr) if @ipaddress
|
43
40
|
@container.sync_mounts(@mounts)
|
44
41
|
@container.start
|
45
42
|
@container.sync_ssh_keys(@ssh_keys)
|
43
|
+
puts
|
46
44
|
end
|
47
45
|
|
48
46
|
def stop
|
49
47
|
hwaddr = @container.config_item("lxc.network.0.hwaddr") if @container.defined?
|
50
48
|
@container.stop
|
51
|
-
|
49
|
+
deregister_from_dhcp(hwaddr)
|
52
50
|
end
|
53
51
|
|
54
52
|
def snapshot(comment=nil)
|
@@ -147,12 +145,11 @@ module DevLXC
|
|
147
145
|
@container.snapshot_list.each { |snapshot| @container.snapshot_destroy(snapshot.first) }
|
148
146
|
end
|
149
147
|
@container.destroy
|
150
|
-
|
148
|
+
deregister_from_dhcp(hwaddr)
|
151
149
|
end
|
152
150
|
|
153
|
-
def
|
151
|
+
def deregister_from_dhcp(hwaddr)
|
154
152
|
if @ipaddress
|
155
|
-
DevLXC.search_file_delete_line("/etc/lxc/addn-hosts.conf", /^#{@ipaddress}\s/)
|
156
153
|
DevLXC.search_file_delete_line("/etc/lxc/dhcp-hosts.conf", /,#{@ipaddress}$/)
|
157
154
|
end
|
158
155
|
unless hwaddr.nil?
|
data/lib/dev-lxc/version.rb
CHANGED
data/lib/dev-lxc.rb
CHANGED
@@ -104,14 +104,6 @@ module DevLXC
|
|
104
104
|
reload_dnsmasq
|
105
105
|
end
|
106
106
|
|
107
|
-
def self.create_dns_record(fqdn, container_name, ipaddress)
|
108
|
-
dns_record = "#{ipaddress} #{container_name} #{fqdn}\n"
|
109
|
-
puts "Creating DNS record: #{dns_record}"
|
110
|
-
search_file_delete_line("/etc/lxc/addn-hosts.conf", /^#{ipaddress}\s/)
|
111
|
-
append_line_to_file("/etc/lxc/addn-hosts.conf", dns_record)
|
112
|
-
reload_dnsmasq
|
113
|
-
end
|
114
|
-
|
115
107
|
def self.reload_dnsmasq
|
116
108
|
system("pkill -HUP dnsmasq")
|
117
109
|
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: 2.
|
4
|
+
version: 2.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: 2016-
|
11
|
+
date: 2016-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
129
|
version: '0'
|
130
130
|
requirements: []
|
131
131
|
rubyforge_project:
|
132
|
-
rubygems_version: 2.6.
|
132
|
+
rubygems_version: 2.6.8
|
133
133
|
signing_key:
|
134
134
|
specification_version: 4
|
135
135
|
summary: A tool for building Chef server clusters using LXC containers
|