dev-lxc 1.5.1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: adb1cdf6e7713709e685315f22141444da1bd719
4
- data.tar.gz: cf3f3f6ee779b6f28a3b59c9f598b407a5c17072
3
+ metadata.gz: cc3e32a92441d13891b9d18d695f0090b66fda21
4
+ data.tar.gz: 88ffc5dd9c96a388b05bd667efa0911f49a7b9ed
5
5
  SHA512:
6
- metadata.gz: dfc37aab34c3fda3b8dcb78512308479e3491453b337174e4729d7de1f2d8c2c2f325dabf226629a9f16e5619dadb18d37b843ace3a835bae473efca1f2ed5c4
7
- data.tar.gz: 5ac66bb4a2669895356442ecc5c5e58f97d36d10cc3845c1008716d2353fb401e62c38ef00620253dbebcc79317051bcb5ae12f9efa44acd5754c6315a037380
6
+ metadata.gz: 036550a1aa6075233f9ca49dd69e97dee81e34b0b08b11b19eb4ed277d3a0308b5e422d8ca28c979c91c770651210723e38be3292dc83b2faf355a6a36fc2d72
7
+ data.tar.gz: 25a763a9686080b77466efe50e77ad7326081ed6569056362a00d2088786f5d471bc826656ba6d582c53106c45d67b623e7f69afe4856b7d45402eb42725bfc2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # dev-lxc Change Log
2
2
 
3
+ ## 1.6.0 (2015-04-20)
4
+
5
+ * Rewrite "dev-lxc init" so its options determine what config gets generated
6
+
7
+ * Allow mounts, platform_image and platform_image_options to be set globally
8
+
9
+ * Create demo org and mary-admin and joe-user users
10
+
11
+ * Add Supermarket server build capability
12
+
13
+ * Add Compliance server build capability
14
+
15
+ * Improve "dev-lxc status" output
16
+
17
+ * Generate Chef Server config in one shot
18
+
19
+ * Make standalone topology the default for Analytics
20
+
21
+ * Make standalone topology the default for Chef Server
22
+
3
23
  ## 1.5.1 (2015-04-15)
4
24
 
5
25
  * Add ability to pass options to LXC create calls
data/README.md CHANGED
@@ -106,8 +106,8 @@ You only have to type enough of a `dev-lxc` subcommand to make it unique.
106
106
  The following commands are equivalent:
107
107
 
108
108
  ```
109
- dev-lxc init standalone > dev-lxc.yml
110
- dl i standalone > dev-lxc.yml
109
+ dev-lxc init --chef > dev-lxc.yml
110
+ dl i --chef > dev-lxc.yml
111
111
  ```
112
112
 
113
113
  ```
@@ -127,7 +127,7 @@ dl d
127
127
 
128
128
  ### Create and Manage a Cluster
129
129
 
130
- The following instructions will build a tier Chef Server with a tier Analytics server
130
+ The following instructions will build a tier Chef Server with an Analytics server
131
131
  for demonstration purposes.
132
132
  The size of this cluster uses about 3GB ram and takes awhile for the first
133
133
  build of the servers. Feel free to try the standalone config first.
@@ -141,7 +141,7 @@ Be sure you configure the
141
141
  appropriately.
142
142
 
143
143
  ```
144
- dev-lxc init tier > dev-lxc.yml
144
+ dev-lxc init --tiered-chef --analytics > dev-lxc.yml
145
145
  ```
146
146
 
147
147
  #### List Images
@@ -364,7 +364,7 @@ Chef Delivery cluster.
364
364
  ```
365
365
  mkdir -p /root/dev/clusters/delivery
366
366
  cd /root/dev/clusters/delivery
367
- dev-lxc init adhoc > dev-lxc.yml
367
+ dev-lxc init --adhoc > dev-lxc.yml
368
368
  cluster-view
369
369
  dl up
370
370
  ```
@@ -492,67 +492,55 @@ The following command generates sample config files for various cluster topologi
492
492
  dev-lxc init
493
493
  ```
494
494
 
495
- `dev-lxc init tier > dev-lxc.yml` creates a `dev-lxc.yml` file with the following content:
495
+ `dev-lxc init --tiered-chef --analytics > dev-lxc.yml` creates a `dev-lxc.yml` file with the following content:
496
496
 
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
500
 
501
- ## Make sure a mount's source directory exists in the LXC host
501
+ ## platform_image_options can be set to provide additional arguments to the LXC create command.
502
+ ## reference arg examples: https://github.com/lxc/lxc/blob/lxc-2.0.0/templates/lxc-download.in#L200-L207
503
+ ## for example:
504
+ ## platform_image_options: --no-validate --keyserver http://my.key.server.com
502
505
 
503
- ## Make sure a package's path is correct
506
+ ## Make sure all mount source directories exist in the LXC host
507
+
508
+ ## Make sure all package paths are correct
504
509
 
505
510
  ## All FQDNs and server names must end with the `.lxc` domain
506
511
 
507
512
  ## DHCP reserved (static) IPs must be selected from the IP range 10.0.3.150 - 254
508
513
 
509
514
  ## topology can be one of the following:
510
- ## standalone, tier or open-source (for the old open source 11 chef server)
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
511
520
 
512
521
  chef-server:
513
- platform_image: p-ubuntu-1404
514
- mounts:
515
- - /root/dev root/dev
516
522
  packages:
517
523
  server: /root/dev/chef-packages/cs/chef-server-core_12.5.0-1_amd64.deb
518
524
  manage: /root/dev/chef-packages/manage/chef-manage_2.2.1-1_amd64.deb
519
- # reporting: /root/dev/chef-packages/reporting/opscode-reporting_1.5.6-1_amd64.deb
520
- # push-jobs-server: /root/dev/chef-packages/push-jobs-server/opscode-push-jobs-server_1.1.6-1_amd64.deb
521
-
522
- api_fqdn: chef.lxc
525
+ reporting: /root/dev/chef-packages/reporting/opscode-reporting_1.5.6-1_amd64.deb
526
+ push-jobs-server: /root/dev/chef-packages/push-jobs-server/opscode-push-jobs-server_1.1.6-1_amd64.deb
523
527
  topology: tier
528
+ api_fqdn: chef.lxc
524
529
  servers:
525
530
  chef-be.lxc:
531
+ ipaddress: 10.0.3.201
526
532
  role: backend
527
- ipaddress: 10.0.3.203
528
533
  bootstrap: true
529
534
  chef-fe1.lxc:
535
+ ipaddress: 10.0.3.202
530
536
  role: frontend
531
- ipaddress: 10.0.3.204
532
- # chef-fe2.lxc:
533
- # role: frontend
534
- # ipaddress: 10.0.3.205
535
537
 
536
538
  analytics:
537
- platform_image: p-ubuntu-1404
538
- mounts:
539
- - /root/dev root/dev
540
539
  packages:
541
540
  analytics: /root/dev/chef-packages/analytics/opscode-analytics_1.3.1-1_amd64.deb
542
-
543
- analytics_fqdn: analytics.lxc
544
- topology: tier
545
541
  servers:
546
- analytics-be.lxc:
547
- role: backend
548
- ipaddress: 10.0.3.206
549
- bootstrap: true
550
- analytics-fe1.lxc:
551
- role: frontend
552
- ipaddress: 10.0.3.207
553
- # analytics-fe2.lxc:
554
- # role: frontend
555
- # ipaddress: 10.0.3.208
542
+ analytics.lxc:
543
+ ipaddress: 10.0.3.204
556
544
  ```
557
545
 
558
546
  This config defines a tier cluster consisting of a single backend and a single frontend.
@@ -591,8 +579,8 @@ each cluster's config file.
591
579
 
592
580
  ```
593
581
  mkdir -p ~/clusters/{clusterA,clusterB}
594
- dev-lxc init tier > ~/clusters/clusterA/dev-lxc.yml
595
- dev-lxc init standalone > ~/clusters/clusterB/dev-lxc.yml
582
+ dev-lxc init --tiered-chef > ~/clusters/clusterA/dev-lxc.yml
583
+ dev-lxc init --chef > ~/clusters/clusterB/dev-lxc.yml
596
584
  cd ~/clusters/clusterA && dev-lxc up # starts clusterA
597
585
  cd ~/clusters/clusterB && dev-lxc up # starts clusterB
598
586
  ```
@@ -619,7 +607,7 @@ more clusters you have to maintain uniqueness across the YAML config files for t
619
607
  For example, you can use the following command to prefix the servers names with `1234-` when
620
608
  generating a cluster's config.
621
609
 
622
- dev-lxc init tier 1234- > dev-lxc.yml
610
+ dev-lxc init --tiered-chef 1234- > dev-lxc.yml
623
611
 
624
612
  * IP Addresses
625
613
 
data/lib/dev-lxc/cli.rb CHANGED
@@ -68,9 +68,9 @@ module DevLXC::CLI
68
68
  puts "ERROR: Can not copy validation key because Chef Server '#{chef_server_bootstrap_backend.name}' is not created."
69
69
  exit 1
70
70
  end
71
- chef_server_url = "https://#{cluster.api_fqdn}/organizations/ponyville"
72
- validation_client_name = 'ponyville-validator'
73
- validation_key = "#{chef_server_bootstrap_backend.config_item('lxc.rootfs')}/root/chef-repo/.chef/ponyville-validator.pem"
71
+ chef_server_url = "https://#{cluster.api_fqdn}/organizations/demo"
72
+ validation_client_name = 'demo-validator'
73
+ validation_key = "#{chef_server_bootstrap_backend.config_item('lxc.rootfs')}/root/chef-repo/.chef/demo-validator.pem"
74
74
  elsif chef_server_url.nil? || validation_client_name.nil? || validation_key.nil?
75
75
  puts "ERROR: All of the --chef-server-url, --validation-client-name and --validation-key options must be set or left unset. Do not set only some of these options."
76
76
  exit 1
@@ -100,9 +100,9 @@ module DevLXC::CLI
100
100
  puts "ERROR: Can not copy validation key because Chef Server '#{chef_server_bootstrap_backend.name}' is not created."
101
101
  exit 1
102
102
  end
103
- chef_server_url = "https://#{cluster.api_fqdn}/organizations/ponyville"
104
- validation_client_name = 'ponyville-validator'
105
- validation_key = "#{chef_server_bootstrap_backend.config_item('lxc.rootfs')}/root/chef-repo/.chef/ponyville-validator.pem"
103
+ chef_server_url = "https://#{cluster.api_fqdn}/organizations/demo"
104
+ validation_client_name = 'demo-validator'
105
+ validation_key = "#{chef_server_bootstrap_backend.config_item('lxc.rootfs')}/root/chef-repo/.chef/demo-validator.pem"
106
106
  elsif chef_server_url.nil? || validation_client_name.nil? || validation_key.nil?
107
107
  puts "ERROR: All of the --chef-server-url, --validation-client-name and --validation-key options must be set or left unset. Do not set only some of these options."
108
108
  exit 1
@@ -113,25 +113,122 @@ module DevLXC::CLI
113
113
  print_elapsed_time(Time.now - start_time)
114
114
  end
115
115
 
116
- desc "init [TOPOLOGY] [UNIQUE_STRING]", "Provide a cluster config file with optional uniqueness in server names and FQDNs"
117
- def init(topology=nil, unique_string=nil)
118
- topologies = %w(adhoc open-source standalone tier)
119
- if topology.nil? || ! topologies.include?(topology)
120
- topologies_with_index = topologies.map.with_index{ |a, i| [i+1, *a]}
121
- print_table topologies_with_index
122
- selection = ask("Which cluster topology do you want to use?", :limited_to => topologies_with_index.map{|c| c[0].to_s})
123
- topology = topologies[selection.to_i - 1]
124
- end
125
- config = IO.read("#{File.dirname(__FILE__)}/../../files/configs/#{topology}.yml")
116
+ desc "init [UNIQUE_STRING]", "Provide a cluster config file with optional uniqueness in server names and FQDNs"
117
+ option :open_source, :type => :boolean, :desc => "Standalone Old Open Source Chef Server"
118
+ option :tiered_chef, :type => :boolean, :desc => "Tiered Chef Server"
119
+ option :chef, :type => :boolean, :desc => "Standalone Chef Server"
120
+ option :analytics, :type => :boolean, :desc => "Analytics Server"
121
+ option :compliance, :type => :boolean, :desc => "Compliance Server"
122
+ option :supermarket, :type => :boolean, :desc => "Supermarket Server"
123
+ option :adhoc, :type => :boolean, :desc => "Adhoc Servers"
124
+ def init(unique_string=nil)
125
+ header = %Q(## platform_image can be one of the following:
126
+ ## p-centos-5, p-centos-6, p-centos-7, p-ubuntu-1204, p-ubuntu-1404 or p-ubuntu-1504
127
+
128
+ ## platform_image_options can be set to provide additional arguments to the LXC create command.
129
+ ## reference arg examples: https://github.com/lxc/lxc/blob/lxc-2.0.0/templates/lxc-download.in#L200-L207
130
+ ## for example:
131
+ ## platform_image_options: --no-validate --keyserver http://my.key.server.com
132
+
133
+ ## Make sure all mount source directories exist in the LXC host
134
+
135
+ ## Make sure all package paths are correct
136
+
137
+ ## All FQDNs and server names must end with the `.lxc` domain
138
+
139
+ ## 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
+ )
148
+ open_source_config = %Q(
149
+ chef-server:
150
+ packages:
151
+ 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
+ )
158
+ chef_server_packages = %Q( packages:
159
+ server: /root/dev/chef-packages/cs/chef-server-core_12.5.0-1_amd64.deb
160
+ manage: /root/dev/chef-packages/manage/chef-manage_2.2.1-1_amd64.deb
161
+ reporting: /root/dev/chef-packages/reporting/opscode-reporting_1.5.6-1_amd64.deb
162
+ push-jobs-server: /root/dev/chef-packages/push-jobs-server/opscode-push-jobs-server_1.1.6-1_amd64.deb
163
+ )
164
+ tiered_chef_config = %Q(
165
+ chef-server:
166
+ #{chef_server_packages.chomp}
167
+ topology: tier
168
+ api_fqdn: chef.lxc
169
+ servers:
170
+ chef-be.lxc:
171
+ ipaddress: 10.0.3.201
172
+ role: backend
173
+ bootstrap: true
174
+ chef-fe1.lxc:
175
+ ipaddress: 10.0.3.202
176
+ role: frontend
177
+ )
178
+ chef_config = %Q(
179
+ chef-server:
180
+ #{chef_server_packages.chomp}
181
+ servers:
182
+ chef.lxc:
183
+ ipaddress: 10.0.3.203
184
+ )
185
+ analytics_config = %Q(
186
+ analytics:
187
+ packages:
188
+ analytics: /root/dev/chef-packages/analytics/opscode-analytics_1.3.1-1_amd64.deb
189
+ servers:
190
+ analytics.lxc:
191
+ ipaddress: 10.0.3.204
192
+ )
193
+ compliance_config = %Q(
194
+ compliance:
195
+ packages:
196
+ compliance: /root/dev/chef-packages/compliance/chef-compliance_1.1.2-1_amd64.deb
197
+ servers:
198
+ compliance.lxc:
199
+ ipaddress: 10.0.3.205
200
+ )
201
+ supermarket_config = %Q(
202
+ supermarket:
203
+ packages:
204
+ supermarket: /root/dev/chef-packages/supermarket/supermarket_2.5.2-1_amd64.deb
205
+ servers:
206
+ supermarket.lxc:
207
+ ipaddress: 10.0.3.206
208
+ )
209
+ adhoc_config = %Q(
210
+ adhoc:
211
+ servers:
212
+ adhoc.lxc:
213
+ ipaddress: 10.0.3.207
214
+ )
215
+ config = header
216
+ config += chef_config if options[:chef]
217
+ config += tiered_chef_config if options[:tiered_chef]
218
+ config += analytics_config if options[:analytics]
219
+ config += compliance_config if options[:compliance]
220
+ config += supermarket_config if options[:supermarket]
221
+ config += adhoc_config if options[:adhoc]
126
222
  unless unique_string.nil?
127
223
  config_hash = YAML.load(config.gsub(/^#/, ''))
128
224
  config.gsub!(/api_fqdn:\s+#{config_hash['api_fqdn']}/, "api_fqdn: #{unique_string}#{config_hash['api_fqdn']}")
129
225
  config.gsub!(/analytics_fqdn:\s+#{config_hash['analytics_fqdn']}/, "analytics_fqdn: #{unique_string}#{config_hash['analytics_fqdn']}")
130
- config_hash['chef-server']['servers'].keys.each do |server_name|
131
- config.gsub!(/ #{server_name}:/, " #{unique_string}#{server_name}:")
132
- end
133
- config_hash['analytics']['servers'].keys.each do |server_name|
134
- config.gsub!(/ #{server_name}:/, " #{unique_string}#{server_name}:")
226
+ %w(open-source chef-server analytics compliance supermarket adhoc).each do |server_type|
227
+ if config_hash[server_type]
228
+ config_hash[server_type]['servers'].keys.each do |server_name|
229
+ config.gsub!(/ #{server_name}:/, " #{unique_string}#{server_name}:")
230
+ end
231
+ end
135
232
  end
136
233
  end
137
234
  puts config
@@ -149,8 +246,11 @@ module DevLXC::CLI
149
246
  option :config, :desc => "Specify a cluster's YAML config file. `./dev-lxc.yml` will be used by default"
150
247
  def status(server_name_regex=nil)
151
248
  cluster = get_cluster(options[:config])
152
- puts "Chef Server: https://#{cluster.api_fqdn}\n\n" if cluster.api_fqdn
153
- puts "Analytics: https://#{cluster.analytics_fqdn}\n\n" if cluster.analytics_fqdn
249
+ puts "Chef Server FQDN: #{cluster.api_fqdn}\n" if cluster.api_fqdn
250
+ puts "Analytics FQDN: #{cluster.analytics_fqdn}\n" if cluster.analytics_fqdn
251
+ puts "Compliance FQDN: #{cluster.compliance_fqdn}\n" if cluster.compliance_fqdn
252
+ puts "Supermarket FQDN: #{cluster.supermarket_fqdn}\n" if cluster.supermarket_fqdn
253
+ puts
154
254
  servers = Array.new
155
255
  match_server_name_regex(server_name_regex).map { |s| servers << s.server.status }
156
256
  max_server_name_length = servers.max_by { |s| s['name'].length }['name'].length unless servers.empty?
@@ -2,7 +2,7 @@ require "dev-lxc/server"
2
2
 
3
3
  module DevLXC
4
4
  class Cluster
5
- attr_reader :api_fqdn, :analytics_fqdn, :chef_server_bootstrap_backend, :analytics_bootstrap_backend, :lxc_config_path
5
+ attr_reader :api_fqdn, :chef_server_bootstrap_backend, :analytics_fqdn, :analytics_bootstrap_backend, :compliance_fqdn, :supermarket_fqdn, :lxc_config_path
6
6
 
7
7
  def initialize(cluster_config)
8
8
  @cluster_config = cluster_config
@@ -16,6 +16,7 @@ module DevLXC
16
16
 
17
17
  if @cluster_config["chef-server"]
18
18
  @chef_server_topology = @cluster_config["chef-server"]["topology"]
19
+ @chef_server_topology ||= 'standalone'
19
20
  @api_fqdn = @cluster_config["chef-server"]["api_fqdn"]
20
21
  @chef_server_servers = @cluster_config["chef-server"]["servers"]
21
22
  @chef_server_frontends = Array.new
@@ -23,6 +24,7 @@ module DevLXC
23
24
  case @chef_server_topology
24
25
  when 'open-source', 'standalone'
25
26
  @chef_server_bootstrap_backend = name if config["role"].nil?
27
+ @api_fqdn ||= @chef_server_bootstrap_backend
26
28
  when 'tier'
27
29
  @chef_server_bootstrap_backend = name if config["role"] == "backend" && config["bootstrap"] == true
28
30
  @chef_server_frontends << name if config["role"] == "frontend"
@@ -32,6 +34,7 @@ module DevLXC
32
34
 
33
35
  if @cluster_config["analytics"]
34
36
  @analytics_topology = @cluster_config["analytics"]["topology"]
37
+ @analytics_topology ||= 'standalone'
35
38
  @analytics_fqdn = @cluster_config["analytics"]["analytics_fqdn"]
36
39
  @analytics_servers = @cluster_config["analytics"]["servers"]
37
40
  @analytics_frontends = Array.new
@@ -39,12 +42,27 @@ module DevLXC
39
42
  case @analytics_topology
40
43
  when 'standalone'
41
44
  @analytics_bootstrap_backend = name if config["role"].nil?
45
+ @analytics_fqdn ||= @analytics_bootstrap_backend
42
46
  when 'tier'
43
47
  @analytics_bootstrap_backend = name if config["role"] == "backend" && config["bootstrap"] == true
44
48
  @analytics_frontends << name if config["role"] == "frontend"
45
49
  end
46
50
  end
47
51
  end
52
+
53
+ if @cluster_config["compliance"]
54
+ compliance_servers = @cluster_config["compliance"]["servers"]
55
+ compliance_servers.each_key do |name|
56
+ @compliance_fqdn = name
57
+ end
58
+ end
59
+
60
+ if @cluster_config["supermarket"]
61
+ supermarket_servers = @cluster_config["supermarket"]["servers"]
62
+ supermarket_servers.each_key do |name|
63
+ @supermarket_fqdn = name
64
+ end
65
+ end
48
66
  end
49
67
 
50
68
  def servers
@@ -69,6 +87,9 @@ module DevLXC
69
87
  end
70
88
  end
71
89
  servers = adhoc_servers + chef_servers + analytics_servers
90
+ servers << Server.new(@compliance_fqdn, 'compliance', @cluster_config) if @compliance_fqdn
91
+ servers << Server.new(@supermarket_fqdn, 'supermarket', @cluster_config) if @supermarket_fqdn
92
+ servers
72
93
  end
73
94
 
74
95
  def chef_repo(force=false, pivotal=false)
@@ -98,8 +119,8 @@ module DevLXC
98
119
  validator_name = "chef-validator"
99
120
  else
100
121
  chef_server_root = "https://#{@api_fqdn}"
101
- chef_server_url = "https://#{@api_fqdn}/organizations/ponyville"
102
- validator_name = "ponyville-validator"
122
+ chef_server_url = "https://#{@api_fqdn}/organizations/demo"
123
+ validator_name = "demo-validator"
103
124
 
104
125
  if pivotal
105
126
  if File.exists?("./chef-repo/.chef/pivotal.rb") && ! force
@@ -154,6 +175,24 @@ server "#{frontend_name}",
154
175
  )
155
176
  end
156
177
  end
178
+ if @analytics_fqdn
179
+ chef_server_config += %Q(
180
+ oc_id['applications'] ||= {}
181
+ oc_id['applications']['analytics'] = {
182
+ 'redirect_uri' => 'https://#{@analytics_fqdn}/'
183
+ }
184
+ rabbitmq['vip'] = '#{@chef_server_bootstrap_backend}'
185
+ rabbitmq['node_ip_address'] = '0.0.0.0'
186
+ )
187
+ end
188
+ if @supermarket_fqdn
189
+ chef_server_config += %Q(
190
+ oc_id['applications'] ||= {}
191
+ oc_id['applications']['supermarket'] = {
192
+ 'redirect_uri' => 'https://#{@supermarket_fqdn}/auth/chef_oauth2/callback'
193
+ }
194
+ )
195
+ end
157
196
  return chef_server_config
158
197
  end
159
198
 
@@ -1,3 +1,4 @@
1
+ require "json"
1
2
  require "dev-lxc/container"
2
3
  require "dev-lxc/cluster"
3
4
 
@@ -15,6 +16,8 @@ module DevLXC
15
16
  @lxc_config_path = cluster.lxc_config_path
16
17
  @api_fqdn = cluster.api_fqdn
17
18
  @analytics_fqdn = cluster.analytics_fqdn
19
+ @compliance_fqdn = cluster.compliance_fqdn
20
+ @supermarket_fqdn = cluster.supermarket_fqdn
18
21
  @chef_server_bootstrap_backend = cluster.chef_server_bootstrap_backend
19
22
  @analytics_bootstrap_backend = cluster.analytics_bootstrap_backend
20
23
  @chef_server_config = cluster.chef_server_config
@@ -23,14 +26,19 @@ module DevLXC
23
26
  @server = DevLXC::Container.new(name, @lxc_config_path)
24
27
  @config = cluster_config[@server_type]["servers"][@server.name]
25
28
  @ipaddress = @config["ipaddress"]
26
- @role = @config["role"] ? @config["role"] : cluster_config[@server_type]['topology']
29
+ @role = @config["role"]
30
+ @role ||= cluster_config[@server_type]['topology']
31
+ @role ||= 'standalone'
27
32
  @mounts = cluster_config[@server_type]["mounts"]
33
+ @mounts ||= cluster_config["mounts"]
28
34
  @platform_image_name = cluster_config[@server_type]["platform_image"]
35
+ @platform_image_name ||= cluster_config["platform_image"]
29
36
  @platform_image_options = cluster_config[@server_type]["platform_image_options"]
37
+ @platform_image_options ||= cluster_config["platform_image_options"]
30
38
  @packages = cluster_config[@server_type]["packages"]
31
39
 
32
40
  case @server_type
33
- when 'adhoc'
41
+ when 'adhoc', 'compliance', 'supermarket'
34
42
  @shared_image_name = ''
35
43
  when 'analytics'
36
44
  @shared_image_name = "s#{@platform_image_name[1..-1]}"
@@ -82,6 +90,10 @@ module DevLXC
82
90
  DevLXC.create_dns_record(@analytics_fqdn, @server.name, @ipaddress)
83
91
  when 'chef-server'
84
92
  DevLXC.create_dns_record(@api_fqdn, @server.name, @ipaddress)
93
+ when 'compliance'
94
+ DevLXC.create_dns_record(@compliance_fqdn, @server.name, @ipaddress)
95
+ when 'supermarket'
96
+ DevLXC.create_dns_record(@supermarket_fqdn, @server.name, @ipaddress)
85
97
  end
86
98
  end
87
99
  @server.sync_mounts(@mounts)
@@ -163,7 +175,11 @@ module DevLXC
163
175
  return
164
176
  else
165
177
  puts "Creating container '#{@server.name}'"
166
- if @server_type == 'adhoc'
178
+ if %w(adhoc compliance supermarket).include?(@server_type)
179
+ if @server_type == 'supermarket' && (@chef_server_bootstrap_backend && ! DevLXC::Container.new(@chef_server_bootstrap_backend, @lxc_config_path).defined?)
180
+ puts "ERROR: The bootstrap backend server '#{@chef_server_bootstrap_backend}' must be created first."
181
+ exit 1
182
+ end
167
183
  platform_image = DevLXC.create_platform_image(@platform_image_name, @platform_image_options, @lxc_config_path)
168
184
  puts "Cloning platform image '#{platform_image.name}' into container '#{@server.name}'"
169
185
  platform_image.clone(@server.name, {:flags => LXC::LXC_CLONE_SNAPSHOT})
@@ -194,6 +210,10 @@ module DevLXC
194
210
  DevLXC.create_dns_record(@analytics_fqdn, @server.name, @ipaddress)
195
211
  when 'chef-server'
196
212
  DevLXC.create_dns_record(@api_fqdn, @server.name, @ipaddress)
213
+ when 'compliance'
214
+ DevLXC.create_dns_record(@compliance_fqdn, @server.name, @ipaddress)
215
+ when 'supermarket'
216
+ DevLXC.create_dns_record(@supermarket_fqdn, @server.name, @ipaddress)
197
217
  end
198
218
  end
199
219
  @server.sync_mounts(@mounts)
@@ -205,7 +225,15 @@ module DevLXC
205
225
  @server.start
206
226
  # Allow adhoc servers time to generate SSH Server Host Keys
207
227
  sleep 5 if @server_type == 'adhoc'
228
+ case @server_type
229
+ when 'compliance'
230
+ @server.install_package(@packages["compliance"]) unless @packages["compliance"].nil?
231
+ when 'supermarket'
232
+ @server.install_package(@packages["supermarket"]) unless @packages["supermarket"].nil?
233
+ end
208
234
  configure_analytics if @server_type == 'analytics'
235
+ configure_compliance if @server_type == 'compliance'
236
+ configure_supermarket if @server_type == 'supermarket'
209
237
  if @server_type == 'chef-server' && ! @packages["server"].nil?
210
238
  configure_server
211
239
  create_users if @server.name == @chef_server_bootstrap_backend
@@ -216,9 +244,6 @@ module DevLXC
216
244
  unless @role == 'open-source'
217
245
  configure_reporting unless @packages["reporting"].nil?
218
246
  configure_push_jobs_server unless @packages["push-jobs-server"].nil?
219
- if @analytics_bootstrap_backend && %w(standalone backend).include?(@role)
220
- configure_chef_server_for_analytics
221
- end
222
247
  end
223
248
  end
224
249
  @server.stop
@@ -316,29 +341,6 @@ module DevLXC
316
341
  run_ctl("opscode-manage", "reconfigure")
317
342
  end
318
343
 
319
- def configure_chef_server_for_analytics
320
- puts "Configuring for Analytics"
321
- case @chef_server_type
322
- when 'private-chef'
323
- DevLXC.append_line_to_file("#{@server.config_item('lxc.rootfs')}/etc/opscode/private-chef.rb",
324
- "\noc_id['applications'] = {\n 'analytics' => {\n 'redirect_uri' => 'https://#{@analytics_fqdn}/'\n }\n}\n")
325
-
326
- DevLXC.append_line_to_file("#{@server.config_item('lxc.rootfs')}/etc/opscode/private-chef.rb",
327
- "\nrabbitmq['vip'] = '#{@chef_server_bootstrap_backend}'\nrabbitmq['node_ip_address'] = '0.0.0.0'\n")
328
- when 'chef-server-core'
329
- DevLXC.append_line_to_file("#{@server.config_item('lxc.rootfs')}/etc/opscode/chef-server.rb",
330
- "\noc_id['applications'] = {\n 'analytics' => {\n 'redirect_uri' => 'https://#{@analytics_fqdn}/'\n }\n}\n")
331
-
332
- DevLXC.append_line_to_file("#{@server.config_item('lxc.rootfs')}/etc/opscode/chef-server.rb",
333
- "\nrabbitmq['vip'] = '#{@chef_server_bootstrap_backend}'\nrabbitmq['node_ip_address'] = '0.0.0.0'\n")
334
- end
335
-
336
- run_ctl(@server_ctl, "stop")
337
- run_ctl(@server_ctl, "reconfigure")
338
- run_ctl(@server_ctl, "restart")
339
- run_ctl("opscode-manage", "reconfigure") if @role == 'frontend'
340
- end
341
-
342
344
  def configure_analytics
343
345
  case @role
344
346
  when "standalone", "backend"
@@ -355,6 +357,25 @@ module DevLXC
355
357
  run_ctl("opscode-analytics", "reconfigure")
356
358
  end
357
359
 
360
+ def configure_compliance
361
+ run_ctl("chef-compliance", "reconfigure")
362
+ end
363
+
364
+ def configure_supermarket
365
+ if @chef_server_bootstrap_backend && DevLXC::Container.new(@chef_server_bootstrap_backend, @lxc_config_path).defined?
366
+ chef_server_supermarket_config = JSON.parse(IO.read("#{LXC::Container.new(@chef_server_bootstrap_backend, @lxc_config_path).config_item('lxc.rootfs')}/etc/opscode/oc-id-applications/supermarket.json"))
367
+ supermarket_config = {
368
+ 'chef_server_url' => "https://#{@api_fqdn}/",
369
+ 'chef_oauth2_app_id' => chef_server_supermarket_config['uid'],
370
+ 'chef_oauth2_secret' => chef_server_supermarket_config['secret'],
371
+ 'chef_oauth2_verify_ssl' => false
372
+ }
373
+ FileUtils.mkdir_p("#{@server.config_item('lxc.rootfs')}/etc/supermarket")
374
+ IO.write("#{@server.config_item('lxc.rootfs')}/etc/supermarket/supermarket.json", JSON.pretty_generate(supermarket_config))
375
+ end
376
+ run_ctl("supermarket", "reconfigure")
377
+ end
378
+
358
379
  def run_ctl(component, subcommand)
359
380
  puts "Running `#{component}-ctl #{subcommand}` in '#{@server.name}'"
360
381
  @server.run_command("#{component}-ctl #{subcommand}")
@@ -367,15 +388,16 @@ module DevLXC
367
388
  case @chef_server_type
368
389
  when 'chef-server'
369
390
  chef_server_url = "https://127.0.0.1"
370
- username = "admin"
391
+ admin_username = "admin"
371
392
  validator_name = "chef-validator"
372
393
 
373
394
  FileUtils.cp( Dir.glob("#{@server.config_item('lxc.rootfs')}/etc/chef-server/{admin,chef-validator}.pem"), "#{@server.config_item('lxc.rootfs')}/root/chef-repo/.chef" )
374
395
  when 'private-chef', 'chef-server-core'
375
396
  chef_server_root = "https://127.0.0.1"
376
- chef_server_url = "https://127.0.0.1/organizations/ponyville"
377
- username = "rainbowdash"
378
- validator_name = "ponyville-validator"
397
+ chef_server_url = "https://127.0.0.1/organizations/demo"
398
+ admin_username = "mary-admin"
399
+ username = "joe-user"
400
+ validator_name = "demo-validator"
379
401
 
380
402
  FileUtils.cp( "#{@server.config_item('lxc.rootfs')}/etc/opscode/pivotal.pem", "#{@server.config_item('lxc.rootfs')}/root/chef-repo/.chef" )
381
403
 
@@ -401,9 +423,16 @@ current_dir = File.dirname(__FILE__)
401
423
 
402
424
  chef_server_url "#{chef_server_url}"
403
425
 
404
- node_name "#{username}"
405
- client_key "\#{current_dir}/#{username}.pem"
426
+ node_name "#{admin_username}"
427
+ client_key "\#{current_dir}/#{admin_username}.pem"
428
+ )
429
+
430
+ knife_rb += %Q(
431
+ #node_name "#{username}"
432
+ #client_key "\#{current_dir}/#{username}.pem"
433
+ ) unless username.nil?
406
434
 
435
+ knife_rb += %Q(
407
436
  validation_client_name "#{validator_name}"
408
437
  validation_key "\#{current_dir}/#{validator_name}.pem"
409
438
 
@@ -419,15 +448,19 @@ ssl_verify_mode :verify_none
419
448
  # give time for all services to come up completely
420
449
  sleep 60
421
450
  @server.run_command("/opt/opscode/embedded/bin/gem install knife-opc --no-ri --no-rdoc")
422
- @server.run_command("/opt/opscode/embedded/bin/knife opc org create ponyville ponyville --filename /root/chef-repo/.chef/ponyville-validator.pem -c /root/chef-repo/.chef/pivotal.rb")
423
- @server.run_command("/opt/opscode/embedded/bin/knife opc user create rainbowdash rainbowdash rainbowdash rainbowdash@noreply.com rainbowdash --filename /root/chef-repo/.chef/rainbowdash.pem -c /root/chef-repo/.chef/pivotal.rb")
424
- @server.run_command("/opt/opscode/embedded/bin/knife opc org user add ponyville rainbowdash --admin -c /root/chef-repo/.chef/pivotal.rb")
451
+ @server.run_command("/opt/opscode/embedded/bin/knife opc org create demo demo --filename /root/chef-repo/.chef/demo-validator.pem -c /root/chef-repo/.chef/pivotal.rb")
452
+ @server.run_command("/opt/opscode/embedded/bin/knife opc user create mary-admin mary admin mary-admin@noreply.com mary-admin --filename /root/chef-repo/.chef/mary-admin.pem -c /root/chef-repo/.chef/pivotal.rb")
453
+ @server.run_command("/opt/opscode/embedded/bin/knife opc org user add demo mary-admin --admin -c /root/chef-repo/.chef/pivotal.rb")
454
+ @server.run_command("/opt/opscode/embedded/bin/knife opc user create joe-user joe user joe-user@noreply.com joe-user --filename /root/chef-repo/.chef/joe-user.pem -c /root/chef-repo/.chef/pivotal.rb")
455
+ @server.run_command("/opt/opscode/embedded/bin/knife opc org user add demo joe-user -c /root/chef-repo/.chef/pivotal.rb")
425
456
  when 'chef-server-core'
426
457
  # give time for all services to come up completely
427
458
  sleep 10
428
- run_ctl(@server_ctl, "org-create ponyville ponyville --filename /root/chef-repo/.chef/ponyville-validator.pem")
429
- run_ctl(@server_ctl, "user-create rainbowdash rainbowdash rainbowdash rainbowdash@noreply.com rainbowdash --filename /root/chef-repo/.chef/rainbowdash.pem")
430
- run_ctl(@server_ctl, "org-user-add ponyville rainbowdash --admin")
459
+ run_ctl(@server_ctl, "org-create demo demo --filename /root/chef-repo/.chef/demo-validator.pem")
460
+ run_ctl(@server_ctl, "user-create mary-admin mary admin mary-admin@noreply.com mary-admin --filename /root/chef-repo/.chef/mary-admin.pem")
461
+ run_ctl(@server_ctl, "org-user-add demo mary-admin --admin")
462
+ run_ctl(@server_ctl, "user-create joe-user joe user joe-user@noreply.com joe-user --filename /root/chef-repo/.chef/joe-user.pem")
463
+ run_ctl(@server_ctl, "org-user-add demo joe-user")
431
464
  end
432
465
  end
433
466
  end
@@ -1,3 +1,3 @@
1
1
  module DevLXC
2
- VERSION = "1.5.1"
2
+ VERSION = "1.6.0"
3
3
  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.5.1
4
+ version: 1.6.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-04-18 00:00:00.000000000 Z
11
+ date: 2016-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -82,10 +82,6 @@ files:
82
82
  - Rakefile
83
83
  - bin/dev-lxc
84
84
  - dev-lxc.gemspec
85
- - files/configs/adhoc.yml
86
- - files/configs/open-source.yml
87
- - files/configs/standalone.yml
88
- - files/configs/tier.yml
89
85
  - lib/dev-lxc.rb
90
86
  - lib/dev-lxc/cli.rb
91
87
  - lib/dev-lxc/cluster.rb
@@ -1,31 +0,0 @@
1
- ## platform_image can be one of the following:
2
- ## p-centos-5, p-centos-6, p-centos-7, p-ubuntu-1204, p-ubuntu-1404 or p-ubuntu-1504
3
-
4
- ## platform_image_options can be set to provide additional arguments to the LXC create command.
5
- ## reference arg examples: https://github.com/lxc/lxc/blob/lxc-2.0.0/templates/lxc-download.in#L200-L207
6
- ## for example:
7
- ## platform_image_options: --no-validate --keyserver http://my.key.server.com
8
-
9
- ## Make sure a mount's source directory exists in the LXC host
10
-
11
- ## Make sure a package's path is correct
12
-
13
- ## All FQDNs and server names must end with the `.lxc` domain
14
-
15
- ## DHCP reserved (static) IPs must be selected from the IP range 10.0.3.150 - 254
16
-
17
- ## topology can be one of the following:
18
- ## standalone, tier or open-source (for the old open source 11 chef server)
19
-
20
- adhoc:
21
- platform_image: p-ubuntu-1404
22
- mounts:
23
- - /root/dev root/dev
24
-
25
- servers:
26
- chef.lxc:
27
- ipaddress: 10.0.3.210
28
- delivery.lxc:
29
- ipaddress: 10.0.3.211
30
- build-1.lxc:
31
- ipaddress: 10.0.3.212
@@ -1,31 +0,0 @@
1
- ## platform_image can be one of the following:
2
- ## p-centos-5, p-centos-6, p-centos-7, p-ubuntu-1204, p-ubuntu-1404 or p-ubuntu-1504
3
-
4
- ## platform_image_options can be set to provide additional arguments to the LXC create command.
5
- ## reference arg examples: https://github.com/lxc/lxc/blob/lxc-2.0.0/templates/lxc-download.in#L200-L207
6
- ## for example:
7
- ## platform_image_options: --no-validate --keyserver http://my.key.server.com
8
-
9
- ## Make sure a mount's source directory exists in the LXC host
10
-
11
- ## Make sure a package's path is correct
12
-
13
- ## All FQDNs and server names must end with the `.lxc` domain
14
-
15
- ## DHCP reserved (static) IPs must be selected from the IP range 10.0.3.150 - 254
16
-
17
- ## topology can be one of the following:
18
- ## standalone, tier or open-source (for the old open source 11 chef server)
19
-
20
- chef-server:
21
- platform_image: p-ubuntu-1204
22
- mounts:
23
- - /root/dev root/dev
24
- packages:
25
- server: /root/dev/chef-packages/osc/chef-server_11.1.6-1_amd64.deb
26
-
27
- api_fqdn: chef.lxc
28
- topology: open-source
29
- servers:
30
- osc-chef.lxc:
31
- ipaddress: 10.0.3.199
@@ -1,47 +0,0 @@
1
- ## platform_image can be one of the following:
2
- ## p-centos-5, p-centos-6, p-centos-7, p-ubuntu-1204, p-ubuntu-1404 or p-ubuntu-1504
3
-
4
- ## platform_image_options can be set to provide additional arguments to the LXC create command.
5
- ## reference arg examples: https://github.com/lxc/lxc/blob/lxc-2.0.0/templates/lxc-download.in#L200-L207
6
- ## for example:
7
- ## platform_image_options: --no-validate --keyserver http://my.key.server.com
8
-
9
- ## Make sure a mount's source directory exists in the LXC host
10
-
11
- ## Make sure a package's path is correct
12
-
13
- ## All FQDNs and server names must end with the `.lxc` domain
14
-
15
- ## DHCP reserved (static) IPs must be selected from the IP range 10.0.3.150 - 254
16
-
17
- ## topology can be one of the following:
18
- ## standalone, tier or open-source (for the old open source 11 chef server)
19
-
20
- chef-server:
21
- platform_image: p-ubuntu-1404
22
- mounts:
23
- - /root/dev root/dev
24
- packages:
25
- server: /root/dev/chef-packages/cs/chef-server-core_12.5.0-1_amd64.deb
26
- manage: /root/dev/chef-packages/manage/chef-manage_2.2.1-1_amd64.deb
27
- # reporting: /root/dev/chef-packages/reporting/opscode-reporting_1.5.6-1_amd64.deb
28
- # push-jobs-server: /root/dev/chef-packages/push-jobs-server/opscode-push-jobs-server_1.1.6-1_amd64.deb
29
-
30
- api_fqdn: chef.lxc
31
- topology: standalone
32
- servers:
33
- chef.lxc:
34
- ipaddress: 10.0.3.201
35
-
36
- analytics:
37
- platform_image: p-ubuntu-1404
38
- mounts:
39
- - /root/dev root/dev
40
- packages:
41
- analytics: /root/dev/chef-packages/analytics/opscode-analytics_1.3.1-1_amd64.deb
42
-
43
- analytics_fqdn: analytics.lxc
44
- topology: standalone
45
- servers:
46
- analytics.lxc:
47
- ipaddress: 10.0.3.202
@@ -1,63 +0,0 @@
1
- ## platform_image can be one of the following:
2
- ## p-centos-5, p-centos-6, p-centos-7, p-ubuntu-1204, p-ubuntu-1404 or p-ubuntu-1504
3
-
4
- ## platform_image_options can be set to provide additional arguments to the LXC create command.
5
- ## reference arg examples: https://github.com/lxc/lxc/blob/lxc-2.0.0/templates/lxc-download.in#L200-L207
6
- ## for example:
7
- ## platform_image_options: --no-validate --keyserver http://my.key.server.com
8
-
9
- ## Make sure a mount's source directory exists in the LXC host
10
-
11
- ## Make sure a package's path is correct
12
-
13
- ## All FQDNs and server names must end with the `.lxc` domain
14
-
15
- ## DHCP reserved (static) IPs must be selected from the IP range 10.0.3.150 - 254
16
-
17
- ## topology can be one of the following:
18
- ## standalone, tier or open-source (for the old open source 11 chef server)
19
-
20
- chef-server:
21
- platform_image: p-ubuntu-1404
22
- mounts:
23
- - /root/dev root/dev
24
- packages:
25
- server: /root/dev/chef-packages/cs/chef-server-core_12.5.0-1_amd64.deb
26
- manage: /root/dev/chef-packages/manage/chef-manage_2.2.1-1_amd64.deb
27
- # reporting: /root/dev/chef-packages/reporting/opscode-reporting_1.5.6-1_amd64.deb
28
- # push-jobs-server: /root/dev/chef-packages/push-jobs-server/opscode-push-jobs-server_1.1.6-1_amd64.deb
29
-
30
- api_fqdn: chef.lxc
31
- topology: tier
32
- servers:
33
- chef-be.lxc:
34
- role: backend
35
- ipaddress: 10.0.3.203
36
- bootstrap: true
37
- chef-fe1.lxc:
38
- role: frontend
39
- ipaddress: 10.0.3.204
40
- # chef-fe2.lxc:
41
- # role: frontend
42
- # ipaddress: 10.0.3.205
43
-
44
- analytics:
45
- platform_image: p-ubuntu-1404
46
- mounts:
47
- - /root/dev root/dev
48
- packages:
49
- analytics: /root/dev/chef-packages/analytics/opscode-analytics_1.3.1-1_amd64.deb
50
-
51
- analytics_fqdn: analytics.lxc
52
- topology: tier
53
- servers:
54
- analytics-be.lxc:
55
- role: backend
56
- ipaddress: 10.0.3.206
57
- bootstrap: true
58
- analytics-fe1.lxc:
59
- role: frontend
60
- ipaddress: 10.0.3.207
61
- # analytics-fe2.lxc:
62
- # role: frontend
63
- # ipaddress: 10.0.3.208