dev-lxc 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +43 -18
- data/files/configs/open-source.yml +2 -2
- data/files/configs/standalone.yml +8 -3
- data/files/configs/tier.yml +11 -6
- data/lib/dev-lxc/chef-cluster.rb +22 -28
- data/lib/dev-lxc/chef-server.rb +81 -37
- data/lib/dev-lxc/cli.rb +20 -20
- 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: 1a2504fbc77e129f8ff71d3df68ecc6682d1596a
|
4
|
+
data.tar.gz: 4569ba40a07de0ee53e56af5cee2a206c618f63d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c89e156bd257dd1dc28e109b73adf0023d9879cf356af5d0e6f4e4f7421896f370cd1319be29ddc1d12ee16fc6001b336ef40bf30257bcd30f20e9162bf4d30
|
7
|
+
data.tar.gz: 64ce4c9738287b28c5c9cccd0b6752731f2120ac08afd171215698035d9326753b9f8999d9bf8a8e761f1e6ffb22de736ac0b96dc57128c329af2fa2212f5702
|
data/README.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# dev-lxc
|
2
2
|
|
3
|
-
A tool for creating Chef
|
3
|
+
A tool for creating Chef Server clusters with a Chef Analytics server using LXC containers.
|
4
4
|
|
5
|
-
Using [ruby-lxc](https://github.com/lxc/ruby-lxc) it builds a standalone
|
6
|
-
tier cluster composed of a backend and multiple frontends with round-robin
|
5
|
+
Using [ruby-lxc](https://github.com/lxc/ruby-lxc) it builds a standalone Chef Server or
|
6
|
+
tier Chef Server cluster composed of a backend and multiple frontends with round-robin
|
7
|
+
DNS resolution. It will also optionally build a Chef Analytics server and connect it with
|
8
|
+
the Chef Server.
|
7
9
|
|
8
10
|
The dev-lxc tool is well suited as a tool for support related work, customized
|
9
11
|
cluster builds for demo purposes, as well as general experimentation and exploration.
|
@@ -92,8 +94,9 @@ dl cl d
|
|
92
94
|
|
93
95
|
### Create and Manage a Cluster
|
94
96
|
|
95
|
-
The following instructions will
|
96
|
-
|
97
|
+
The following instructions will build a tier cluster with an Analytics server for
|
98
|
+
demonstration purposes.
|
99
|
+
The size of this cluster uses about 3GB ram and takes awhile for the first
|
97
100
|
build of the servers. Feel free to try the standalone config first.
|
98
101
|
|
99
102
|
#### Define cluster
|
@@ -106,6 +109,8 @@ appropriately.
|
|
106
109
|
|
107
110
|
dev-lxc cluster init tier > dev-lxc.yml
|
108
111
|
|
112
|
+
Uncomment the Analytics server section in `dev-lxc.yml` if you want it to be built.
|
113
|
+
|
109
114
|
#### Start cluster
|
110
115
|
|
111
116
|
Starting the cluster the first time takes awhile since it has a lot to build.
|
@@ -130,11 +135,15 @@ Run the following command to see the status of the cluster.
|
|
130
135
|
|
131
136
|
This is an example of the output.
|
132
137
|
|
133
|
-
|
134
|
-
|
135
|
-
|
138
|
+
```
|
139
|
+
Cluster is available at https://chef.lxc
|
140
|
+
Analytics is available at https://analytics.lxc
|
141
|
+
be-tier.lxc running 10.0.3.203
|
142
|
+
fe1-tier.lxc running 10.0.3.204
|
143
|
+
analytics-tier.lxc running 10.0.3.206
|
144
|
+
```
|
136
145
|
|
137
|
-
[https://chef
|
146
|
+
[https://chef.lxc](https://chef.lxc) resolves to the frontend.
|
138
147
|
|
139
148
|
#### Create chef-repo
|
140
149
|
|
@@ -166,6 +175,9 @@ seconds effectively starting with a clean slate very easily.
|
|
166
175
|
|
167
176
|
The abspath subcommand can be used to prepend each server's rootfs path to a particular file.
|
168
177
|
|
178
|
+
When using `dev-lxc cluster abspath` only results for actual Chef Servers will be returned.
|
179
|
+
If an Analytics server is described in `dev-lcx.yml` it will be ignored.
|
180
|
+
|
169
181
|
For example, you can use the following command to edit each server's chef-server.rb file without
|
170
182
|
logging into the containers.
|
171
183
|
|
@@ -176,6 +188,9 @@ logging into the containers.
|
|
176
188
|
After modifying the chef-server.rb you could use the run_command subcommand to tell each server
|
177
189
|
to run `chef-server-ctl reconfigure`.
|
178
190
|
|
191
|
+
When using `dev-lxc cluster run_command` the command will only be run in actual Chef Servers.
|
192
|
+
If an Analytics server is described in `dev-lcx.yml` it will be ignored.
|
193
|
+
|
179
194
|
dev-lxc cluster run_command 'chef-server-ctl reconfigure'
|
180
195
|
|
181
196
|
#### Destroy cluster
|
@@ -196,15 +211,20 @@ dev-lxc can also be used as a library.
|
|
196
211
|
|
197
212
|
require 'yaml'
|
198
213
|
require 'dev-lxc'
|
199
|
-
|
214
|
+
config = YAML.load(IO.read('dev-lxc.yml'))
|
215
|
+
cluster = DevLXC::ChefCluster.new(config)
|
200
216
|
cluster.start
|
201
217
|
cluster.status
|
202
218
|
cluster.run_command("uptime")
|
203
|
-
server = DevLXC::ChefServer.new("fe1-tier.lxc",
|
219
|
+
server = DevLXC::ChefServer.new("fe1-tier.lxc", config)
|
204
220
|
server.stop
|
221
|
+
server.status
|
222
|
+
cluster.status
|
205
223
|
server.start
|
224
|
+
cluster.status
|
206
225
|
server.run_command("chef-server-ctl reconfigure")
|
207
226
|
cluster.destroy
|
227
|
+
cluster.status
|
208
228
|
|
209
229
|
## Cluster Config Files
|
210
230
|
|
@@ -218,31 +238,36 @@ The following command generates sample config files for various cluster topologi
|
|
218
238
|
|
219
239
|
platform_container: p-ubuntu-1404
|
220
240
|
topology: tier
|
221
|
-
api_fqdn: chef
|
241
|
+
api_fqdn: chef.lxc
|
242
|
+
#analytics_fqdn: analytics.lxc
|
222
243
|
mounts:
|
223
244
|
- /dev-shared dev-shared
|
224
245
|
packages:
|
225
|
-
server: /dev-shared/chef-packages/cs/chef-server-core_12.0.
|
246
|
+
server: /dev-shared/chef-packages/cs/chef-server-core_12.0.5-1_amd64.deb
|
247
|
+
# manage: /dev-shared/chef-packages/manage/opscode-manage_1.11.2-1_amd64.deb
|
226
248
|
# reporting: /dev-shared/chef-packages/reporting/opscode-reporting_1.2.3-1_amd64.deb
|
227
249
|
# push-jobs-server: /dev-shared/chef-packages/push-jobs-server/opscode-push-jobs-server_1.1.6-1_amd64.deb
|
228
|
-
#
|
250
|
+
# analytics: /dev-shared/chef-packages/analytics/opscode-analytics_1.1.1-1_amd64.deb
|
229
251
|
servers:
|
230
252
|
be-tier.lxc:
|
231
253
|
role: backend
|
232
|
-
ipaddress: 10.0.3.
|
254
|
+
ipaddress: 10.0.3.203
|
233
255
|
bootstrap: true
|
234
256
|
fe1-tier.lxc:
|
235
257
|
role: frontend
|
236
|
-
ipaddress: 10.0.3.
|
258
|
+
ipaddress: 10.0.3.204
|
237
259
|
# fe2-tier.lxc:
|
238
260
|
# role: frontend
|
239
|
-
# ipaddress: 10.0.3.
|
261
|
+
# ipaddress: 10.0.3.205
|
262
|
+
# analytics-tier.lxc:
|
263
|
+
# role: analytics
|
264
|
+
# ipaddress: 10.0.3.206
|
240
265
|
|
241
266
|
This config defines a tier cluster consisting of a single backend and a single frontend.
|
242
267
|
|
243
268
|
A second frontend is commented out to conserve resources. If you uncomment the second
|
244
269
|
frontend then both frontends will be created and dnsmasq will resolve the `api_fqdn`
|
245
|
-
[chef
|
270
|
+
[chef.lxc](chef.lxc) to both frontends using a round-robin policy.
|
246
271
|
|
247
272
|
The config file is very customizable. You can add or remove mounts, packages or servers,
|
248
273
|
change ip addresses, change server names, change the base_platform and more.
|
@@ -1,10 +1,10 @@
|
|
1
1
|
platform_container: p-ubuntu-1204
|
2
2
|
topology: open-source
|
3
|
-
api_fqdn: chef
|
3
|
+
api_fqdn: chef.lxc
|
4
4
|
mounts:
|
5
5
|
- /dev-shared dev-shared
|
6
6
|
packages:
|
7
7
|
server: /dev-shared/chef-packages/osc/chef-server_11.1.6-1_amd64.deb
|
8
8
|
servers:
|
9
9
|
chef-osc.lxc:
|
10
|
-
ipaddress: 10.0.3.
|
10
|
+
ipaddress: 10.0.3.207
|
@@ -1,13 +1,18 @@
|
|
1
1
|
platform_container: p-ubuntu-1404
|
2
2
|
topology: standalone
|
3
|
-
api_fqdn: chef
|
3
|
+
api_fqdn: chef.lxc
|
4
|
+
#analytics_fqdn: analytics.lxc
|
4
5
|
mounts:
|
5
6
|
- /dev-shared dev-shared
|
6
7
|
packages:
|
7
|
-
server: /dev-shared/chef-packages/cs/chef-server-core_12.0.
|
8
|
+
server: /dev-shared/chef-packages/cs/chef-server-core_12.0.5-1_amd64.deb
|
9
|
+
# manage: /dev-shared/chef-packages/manage/opscode-manage_1.11.2-1_amd64.deb
|
8
10
|
# reporting: /dev-shared/chef-packages/reporting/opscode-reporting_1.2.3-1_amd64.deb
|
9
11
|
# push-jobs-server: /dev-shared/chef-packages/push-jobs-server/opscode-push-jobs-server_1.1.6-1_amd64.deb
|
10
|
-
#
|
12
|
+
# analytics: /dev-shared/chef-packages/analytics/opscode-analytics_1.1.1-1_amd64.deb
|
11
13
|
servers:
|
12
14
|
chef-standalone.lxc:
|
13
15
|
ipaddress: 10.0.3.201
|
16
|
+
# analytics-standalone.lxc:
|
17
|
+
# role: analytics
|
18
|
+
# ipaddress: 10.0.3.202
|
data/files/configs/tier.yml
CHANGED
@@ -1,21 +1,26 @@
|
|
1
1
|
platform_container: p-ubuntu-1404
|
2
2
|
topology: tier
|
3
|
-
api_fqdn: chef
|
3
|
+
api_fqdn: chef.lxc
|
4
|
+
#analytics_fqdn: analytics.lxc
|
4
5
|
mounts:
|
5
6
|
- /dev-shared dev-shared
|
6
7
|
packages:
|
7
|
-
server: /dev-shared/chef-packages/cs/chef-server-core_12.0.
|
8
|
+
server: /dev-shared/chef-packages/cs/chef-server-core_12.0.5-1_amd64.deb
|
9
|
+
# manage: /dev-shared/chef-packages/manage/opscode-manage_1.11.2-1_amd64.deb
|
8
10
|
# reporting: /dev-shared/chef-packages/reporting/opscode-reporting_1.2.3-1_amd64.deb
|
9
11
|
# push-jobs-server: /dev-shared/chef-packages/push-jobs-server/opscode-push-jobs-server_1.1.6-1_amd64.deb
|
10
|
-
#
|
12
|
+
# analytics: /dev-shared/chef-packages/analytics/opscode-analytics_1.1.1-1_amd64.deb
|
11
13
|
servers:
|
12
14
|
be-tier.lxc:
|
13
15
|
role: backend
|
14
|
-
ipaddress: 10.0.3.
|
16
|
+
ipaddress: 10.0.3.203
|
15
17
|
bootstrap: true
|
16
18
|
fe1-tier.lxc:
|
17
19
|
role: frontend
|
18
|
-
ipaddress: 10.0.3.
|
20
|
+
ipaddress: 10.0.3.204
|
19
21
|
# fe2-tier.lxc:
|
20
22
|
# role: frontend
|
21
|
-
# ipaddress: 10.0.3.
|
23
|
+
# ipaddress: 10.0.3.205
|
24
|
+
# analytics-tier.lxc:
|
25
|
+
# role: analytics
|
26
|
+
# ipaddress: 10.0.3.206
|
data/lib/dev-lxc/chef-cluster.rb
CHANGED
@@ -2,54 +2,57 @@ require "dev-lxc/chef-server"
|
|
2
2
|
|
3
3
|
module DevLXC
|
4
4
|
class ChefCluster
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :bootstrap_backend
|
6
6
|
|
7
7
|
def initialize(cluster_config)
|
8
8
|
@cluster_config = cluster_config
|
9
9
|
@api_fqdn = @cluster_config["api_fqdn"]
|
10
|
+
@analytics_fqdn = @cluster_config["analytics_fqdn"]
|
10
11
|
@topology = @cluster_config["topology"]
|
11
12
|
@servers = @cluster_config["servers"]
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
@frontends = Array.new
|
14
|
+
@servers.each do |name, config|
|
15
|
+
case @topology
|
16
|
+
when 'open-source', 'standalone'
|
17
|
+
@bootstrap_backend = name if config["role"].nil?
|
18
|
+
when 'tier'
|
19
|
+
@bootstrap_backend = name if config["role"] == "backend" && config["bootstrap"] == true
|
20
|
+
@frontends << name if config["role"] == "frontend"
|
21
|
+
end
|
22
|
+
@analytics_server = name if config["role"] == "analytics"
|
15
23
|
end
|
16
24
|
end
|
17
25
|
|
18
26
|
def chef_servers
|
19
27
|
chef_servers = Array.new
|
20
|
-
|
21
|
-
|
22
|
-
chef_servers << ChefServer.new(@servers.keys.first, @cluster_config)
|
23
|
-
when "tier"
|
24
|
-
chef_servers << ChefServer.new(@bootstrap_backend, @cluster_config)
|
28
|
+
chef_servers << ChefServer.new(@bootstrap_backend, @cluster_config)
|
29
|
+
if @topology == "tier"
|
25
30
|
@frontends.each do |frontend_name|
|
26
31
|
chef_servers << ChefServer.new(frontend_name, @cluster_config)
|
27
32
|
end
|
28
33
|
end
|
34
|
+
chef_servers << ChefServer.new(@analytics_server, @cluster_config) if @analytics_server
|
29
35
|
chef_servers
|
30
36
|
end
|
31
37
|
|
32
38
|
def status
|
33
39
|
puts "Cluster is available at https://#{@api_fqdn}"
|
40
|
+
puts "Analytics is available at https://#{@analytics_fqdn}" if @analytics_fqdn
|
34
41
|
chef_servers.each { |cs| cs.status }
|
35
42
|
end
|
36
43
|
|
37
44
|
def abspath(rootfs_path)
|
38
45
|
abspath = Array.new
|
39
|
-
chef_servers.each { |cs| abspath << cs.abspath(rootfs_path) }
|
46
|
+
chef_servers.each { |cs| abspath << cs.abspath(rootfs_path) unless cs.role == 'analytics' }
|
40
47
|
abspath.compact
|
41
48
|
end
|
42
49
|
|
43
50
|
def chef_repo
|
44
|
-
|
45
|
-
when "open-source"
|
51
|
+
if @topology == "open-source"
|
46
52
|
puts "Unable to create a chef-repo for an Open Source Chef Server"
|
47
53
|
exit 1
|
48
|
-
when "standalone"
|
49
|
-
chef_server = ChefServer.new(@servers.keys.first, @cluster_config)
|
50
|
-
when "tier"
|
51
|
-
chef_server = ChefServer.new(@bootstrap_backend, @cluster_config)
|
52
54
|
end
|
55
|
+
chef_server = ChefServer.new(@bootstrap_backend, @cluster_config)
|
53
56
|
if ! chef_server.server.defined?
|
54
57
|
puts "The '#{chef_server.server.name}' Chef Server does not exist. Please create it first."
|
55
58
|
exit 1
|
@@ -59,7 +62,7 @@ module DevLXC
|
|
59
62
|
knife_rb = %Q(
|
60
63
|
current_dir = File.dirname(__FILE__)
|
61
64
|
|
62
|
-
chef_server_url "https://#{api_fqdn}/organizations/ponyville"
|
65
|
+
chef_server_url "https://#{@api_fqdn}/organizations/ponyville"
|
63
66
|
|
64
67
|
node_name "rainbowdash"
|
65
68
|
client_key "\#{current_dir}/rainbowdash.pem"
|
@@ -79,7 +82,7 @@ knife[:chef_repo_path] = Dir.pwd
|
|
79
82
|
end
|
80
83
|
|
81
84
|
def run_command(command)
|
82
|
-
chef_servers.each { |cs| cs.run_command(command) }
|
85
|
+
chef_servers.each { |cs| cs.run_command(command) unless cs.role == 'analytics' }
|
83
86
|
end
|
84
87
|
|
85
88
|
def start
|
@@ -98,16 +101,7 @@ knife[:chef_repo_path] = Dir.pwd
|
|
98
101
|
end
|
99
102
|
|
100
103
|
def destroy_container(type)
|
101
|
-
|
102
|
-
when :unique
|
103
|
-
@servers.keys.each do |server_name|
|
104
|
-
DevLXC::ChefServer.new(server_name, @cluster_config).destroy_container(:unique)
|
105
|
-
end
|
106
|
-
when :shared
|
107
|
-
DevLXC::ChefServer.new(@servers.keys.first, @cluster_config).destroy_container(:shared)
|
108
|
-
when :platform
|
109
|
-
DevLXC::ChefServer.new(@servers.keys.first, @cluster_config).destroy_container(:platform)
|
110
|
-
end
|
104
|
+
chef_servers.each { |cs| cs.destroy_container(type) }
|
111
105
|
end
|
112
106
|
|
113
107
|
def chef_server_config
|
data/lib/dev-lxc/chef-server.rb
CHANGED
@@ -3,7 +3,7 @@ require "dev-lxc/chef-cluster"
|
|
3
3
|
|
4
4
|
module DevLXC
|
5
5
|
class ChefServer
|
6
|
-
attr_reader :
|
6
|
+
attr_reader :role, :server
|
7
7
|
|
8
8
|
def initialize(name, cluster_config)
|
9
9
|
unless cluster_config["servers"].keys.include?(name)
|
@@ -13,17 +13,12 @@ module DevLXC
|
|
13
13
|
@server = DevLXC::Container.new(name)
|
14
14
|
@config = cluster_config["servers"][@server.name]
|
15
15
|
@ipaddress = @config["ipaddress"]
|
16
|
-
|
17
|
-
when "open-source", "standalone"
|
18
|
-
@role = cluster.topology
|
19
|
-
when "tier"
|
20
|
-
@role = "bootstrap_backend" if @server.name == cluster.bootstrap_backend
|
21
|
-
@role = "frontend" if cluster.frontends.include?(@server.name)
|
22
|
-
end
|
16
|
+
@role = @config["role"] ? @config["role"] : cluster_config['topology']
|
23
17
|
@mounts = cluster_config["mounts"]
|
24
18
|
@bootstrap_backend = cluster.bootstrap_backend
|
25
19
|
@chef_server_config = cluster.chef_server_config
|
26
|
-
@api_fqdn =
|
20
|
+
@api_fqdn = cluster_config["api_fqdn"]
|
21
|
+
@analytics_fqdn = cluster_config["analytics_fqdn"]
|
27
22
|
@platform_container_name = cluster_config["platform_container"]
|
28
23
|
@packages = cluster_config["packages"]
|
29
24
|
|
@@ -32,21 +27,26 @@ module DevLXC
|
|
32
27
|
@chef_server_version = Regexp.last_match[2].gsub(".", "-")
|
33
28
|
end
|
34
29
|
|
35
|
-
@
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
@
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
30
|
+
if @role == 'analytics'
|
31
|
+
@shared_container_name = "s#{@platform_container_name[1..-1]}"
|
32
|
+
@shared_container_name += "-analytics-#{Regexp.last_match[1].gsub(".", "-")}" if @packages["analytics"].to_s.match(/[_-]((\d+\.?){3,})-/)
|
33
|
+
else
|
34
|
+
@shared_container_name = "s#{@platform_container_name[1..-1]}"
|
35
|
+
case @chef_server_type
|
36
|
+
when 'chef-server-core'
|
37
|
+
@shared_container_name += '-cs'
|
38
|
+
@server_ctl = 'chef-server'
|
39
|
+
when 'private-chef'
|
40
|
+
@shared_container_name += '-ec'
|
41
|
+
@server_ctl = 'private-chef'
|
42
|
+
when 'chef-server'
|
43
|
+
@shared_container_name += '-osc'
|
44
|
+
@server_ctl = 'chef-server'
|
45
|
+
end
|
46
|
+
@shared_container_name += "-#{@chef_server_version}"
|
47
|
+
@shared_container_name += "-reporting-#{Regexp.last_match[1].gsub(".", "-")}" if @packages["reporting"].to_s.match(/[_-]((\d+\.?){3,})-/)
|
48
|
+
@shared_container_name += "-pushy-#{Regexp.last_match[1].gsub(".", "-")}" if @packages["push-jobs-server"].to_s.match(/[_-]((\d+\.?){3,})-/)
|
46
49
|
end
|
47
|
-
@shared_container_name += "-#{@chef_server_version}"
|
48
|
-
@shared_container_name += "-reporting-#{Regexp.last_match[1].gsub(".", "-")}" if @packages["reporting"].to_s.match(/[_-]((\d+\.?){3,})-/)
|
49
|
-
@shared_container_name += "-pushy-#{Regexp.last_match[1].gsub(".", "-")}" if @packages["push-jobs-server"].to_s.match(/[_-]((\d+\.?){3,})-/)
|
50
50
|
end
|
51
51
|
|
52
52
|
def status
|
@@ -76,6 +76,7 @@ module DevLXC
|
|
76
76
|
create
|
77
77
|
hwaddr = @server.config_item("lxc.network.0.hwaddr")
|
78
78
|
DevLXC.assign_ip_address(@ipaddress, @server.name, hwaddr)
|
79
|
+
DevLXC.create_dns_record(@analytics_fqdn, @server.name, @ipaddress) if @role == 'analytics'
|
79
80
|
DevLXC.create_dns_record(@api_fqdn, @server.name, @ipaddress) if %w(open-source standalone frontend).include?(@role)
|
80
81
|
@server.sync_mounts(@mounts)
|
81
82
|
@server.start
|
@@ -126,7 +127,7 @@ module DevLXC
|
|
126
127
|
return
|
127
128
|
else
|
128
129
|
puts "Creating container #{@server.name}"
|
129
|
-
unless
|
130
|
+
unless @server.name == @bootstrap_backend || DevLXC::Container.new(@bootstrap_backend).defined?
|
130
131
|
raise "The bootstrap backend server must be created first."
|
131
132
|
end
|
132
133
|
shared_container = create_shared_container
|
@@ -139,18 +140,23 @@ module DevLXC
|
|
139
140
|
hwaddr = @server.config_item("lxc.network.0.hwaddr")
|
140
141
|
raise "#{@server.name} needs to have an lxc.network.hwaddr entry" if hwaddr.empty?
|
141
142
|
DevLXC.assign_ip_address(@ipaddress, @server.name, hwaddr)
|
143
|
+
DevLXC.create_dns_record(@analytics_fqdn, @server.name, @ipaddress) if @role == 'analytics'
|
142
144
|
DevLXC.create_dns_record(@api_fqdn, @server.name, @ipaddress) if %w(open-source standalone frontend).include?(@role)
|
143
145
|
@server.sync_mounts(@mounts)
|
144
146
|
@server.start
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
147
|
+
configure_analytics if @role == 'analytics'
|
148
|
+
unless @role == 'analytics' || @packages["server"].nil?
|
149
|
+
configure_server
|
150
|
+
create_users if %w(standalone backend).include?(@role)
|
151
|
+
if %w(standalone frontend).include?(@role) && ! @packages["manage"].nil?
|
152
|
+
@server.install_package(@packages["manage"])
|
153
|
+
configure_manage
|
154
|
+
end
|
155
|
+
if %w(standalone backend frontend).include?(@role)
|
156
|
+
configure_reporting unless @packages["reporting"].nil?
|
157
|
+
configure_push_jobs_server unless @packages["push-jobs-server"].nil?
|
158
|
+
configure_chef_server_for_analytics unless ! %w(standalone backend).include?(@role) || @packages["analytics"].nil?
|
159
|
+
end
|
154
160
|
end
|
155
161
|
@server.stop
|
156
162
|
puts "Cloning container #{@server.name} into unique container #{unique_container.name}"
|
@@ -183,9 +189,13 @@ module DevLXC
|
|
183
189
|
end
|
184
190
|
shared_container.sync_mounts(@mounts)
|
185
191
|
shared_container.start
|
186
|
-
|
187
|
-
|
188
|
-
|
192
|
+
if @role == 'analytics'
|
193
|
+
shared_container.install_package(@packages["analytics"]) unless @packages["analytics"].nil?
|
194
|
+
else
|
195
|
+
shared_container.install_package(@packages["server"]) unless @packages["server"].nil?
|
196
|
+
shared_container.install_package(@packages["reporting"]) unless @packages["reporting"].nil?
|
197
|
+
shared_container.install_package(@packages["push-jobs-server"]) unless @packages["push-jobs-server"].nil?
|
198
|
+
end
|
189
199
|
shared_container.stop
|
190
200
|
return shared_container
|
191
201
|
end
|
@@ -197,7 +207,7 @@ module DevLXC
|
|
197
207
|
FileUtils.mkdir_p("#{@server.config_item('lxc.rootfs')}/etc/chef-server")
|
198
208
|
IO.write("#{@server.config_item('lxc.rootfs')}/etc/chef-server/chef-server.rb", @chef_server_config)
|
199
209
|
run_ctl(@server_ctl, "reconfigure")
|
200
|
-
when "standalone", "
|
210
|
+
when "standalone", "backend"
|
201
211
|
case @chef_server_type
|
202
212
|
when 'private-chef'
|
203
213
|
puts "Creating /etc/opscode/private-chef.rb"
|
@@ -242,6 +252,40 @@ module DevLXC
|
|
242
252
|
run_ctl("opscode-manage", "reconfigure")
|
243
253
|
end
|
244
254
|
|
255
|
+
def configure_chef_server_for_analytics
|
256
|
+
puts "Configuring for Analytics"
|
257
|
+
case @chef_server_type
|
258
|
+
when 'private-chef'
|
259
|
+
DevLXC.append_line_to_file("#{@server.config_item('lxc.rootfs')}/etc/opscode/private-chef.rb",
|
260
|
+
"\noc_id['applications'] = {\n 'analytics' => {\n 'redirect_uri' => 'https://#{@analytics_fqdn}/'\n }\n}\n")
|
261
|
+
|
262
|
+
DevLXC.append_line_to_file("#{@server.config_item('lxc.rootfs')}/etc/opscode/private-chef.rb",
|
263
|
+
"\nrabbitmq['vip'] = '#{@bootstrap_backend}'\nrabbitmq['node_ip_address'] = '0.0.0.0'\n")
|
264
|
+
when 'chef-server-core'
|
265
|
+
DevLXC.append_line_to_file("#{@server.config_item('lxc.rootfs')}/etc/opscode/chef-server.rb",
|
266
|
+
"\noc_id['applications'] = {\n 'analytics' => {\n 'redirect_uri' => 'https://#{@analytics_fqdn}/'\n }\n}\n")
|
267
|
+
|
268
|
+
DevLXC.append_line_to_file("#{@server.config_item('lxc.rootfs')}/etc/opscode/chef-server.rb",
|
269
|
+
"\nrabbitmq['vip'] = '#{@bootstrap_backend}'\nrabbitmq['node_ip_address'] = '0.0.0.0'\n")
|
270
|
+
end
|
271
|
+
|
272
|
+
run_ctl(@server_ctl, "stop")
|
273
|
+
run_ctl(@server_ctl, "reconfigure")
|
274
|
+
run_ctl(@server_ctl, "restart")
|
275
|
+
run_ctl("opscode-manage", "reconfigure") if @role == 'frontend'
|
276
|
+
end
|
277
|
+
|
278
|
+
def configure_analytics
|
279
|
+
puts "Copying /etc/opscode-analytics from Chef Server bootstrap backend"
|
280
|
+
FileUtils.cp_r("#{LXC::Container.new(@bootstrap_backend).config_item('lxc.rootfs')}/etc/opscode-analytics",
|
281
|
+
"#{@server.config_item('lxc.rootfs')}/etc")
|
282
|
+
|
283
|
+
IO.write("#{@server.config_item('lxc.rootfs')}/etc/opscode-analytics/opscode-analytics.rb",
|
284
|
+
"analytics_fqdn '#{@analytics_fqdn}'\ntopology 'standalone'\n")
|
285
|
+
|
286
|
+
run_ctl("opscode-analytics", "reconfigure")
|
287
|
+
end
|
288
|
+
|
245
289
|
def run_ctl(component, subcommand)
|
246
290
|
puts "Running `#{component}-ctl #{subcommand}` in #{@server.name}"
|
247
291
|
@server.run_command("#{component}-ctl #{subcommand}")
|
data/lib/dev-lxc/cli.rb
CHANGED
@@ -26,13 +26,13 @@ module DevLXC::CLI
|
|
26
26
|
puts IO.read("#{File.dirname(__FILE__)}/../../files/configs/#{topology}.yml")
|
27
27
|
end
|
28
28
|
|
29
|
-
desc "status", "Show status of
|
29
|
+
desc "status", "Show status of all servers"
|
30
30
|
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
31
31
|
def status
|
32
32
|
get_cluster(options[:config]).status
|
33
33
|
end
|
34
34
|
|
35
|
-
desc "abspath [ROOTFS_PATH]", "Returns the absolute path to a file
|
35
|
+
desc "abspath [ROOTFS_PATH]", "Returns the absolute path to a file in each Chef Server (not in an Analytics server)"
|
36
36
|
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
37
37
|
def abspath(rootfs_path)
|
38
38
|
puts get_cluster(options[:config]).abspath(rootfs_path).join(" ")
|
@@ -44,29 +44,29 @@ module DevLXC::CLI
|
|
44
44
|
get_cluster(options[:config]).chef_repo
|
45
45
|
end
|
46
46
|
|
47
|
-
desc "run_command [COMMAND]", "Runs a command in each Chef
|
47
|
+
desc "run_command [COMMAND]", "Runs a command in each Chef Server (not in an Analytics server)"
|
48
48
|
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
49
49
|
def run_command(command)
|
50
50
|
get_cluster(options[:config]).run_command(command)
|
51
51
|
end
|
52
52
|
|
53
|
-
desc "start", "Start
|
53
|
+
desc "start", "Start all servers"
|
54
54
|
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
55
55
|
def start
|
56
56
|
get_cluster(options[:config]).start
|
57
57
|
end
|
58
58
|
|
59
|
-
desc "stop", "Stop
|
59
|
+
desc "stop", "Stop all servers"
|
60
60
|
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
61
61
|
def stop
|
62
62
|
get_cluster(options[:config]).stop
|
63
63
|
end
|
64
64
|
|
65
|
-
desc "destroy", "Destroy
|
65
|
+
desc "destroy", "Destroy all servers"
|
66
66
|
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
67
|
-
option :unique, :aliases => "-u", :type => :boolean, :desc => "Also destroy the
|
68
|
-
option :shared, :aliases => "-s", :type => :boolean, :desc => "Also destroy the
|
69
|
-
option :platform, :aliases => "-p", :type => :boolean, :desc => "Also destroy the
|
67
|
+
option :unique, :aliases => "-u", :type => :boolean, :desc => "Also destroy the unique containers"
|
68
|
+
option :shared, :aliases => "-s", :type => :boolean, :desc => "Also destroy the shared container"
|
69
|
+
option :platform, :aliases => "-p", :type => :boolean, :desc => "Also destroy the platform container"
|
70
70
|
def destroy
|
71
71
|
cluster = get_cluster(options[:config])
|
72
72
|
cluster.destroy
|
@@ -87,41 +87,41 @@ module DevLXC::CLI
|
|
87
87
|
end
|
88
88
|
}
|
89
89
|
|
90
|
-
desc "status [NAME]", "Show status of a
|
90
|
+
desc "status [NAME]", "Show status of a server"
|
91
91
|
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
92
92
|
def status(name)
|
93
93
|
get_server(name, options[:config]).status
|
94
94
|
end
|
95
95
|
|
96
|
-
desc "abspath [NAME] [ROOTFS_PATH]", "Returns the absolute path to a file in a
|
96
|
+
desc "abspath [NAME] [ROOTFS_PATH]", "Returns the absolute path to a file in a server"
|
97
97
|
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
98
98
|
def abspath(name, rootfs_path)
|
99
99
|
puts get_server(name, options[:config]).abspath(rootfs_path)
|
100
100
|
end
|
101
101
|
|
102
|
-
desc "run_command [NAME] [COMMAND]", "Runs a command in a
|
102
|
+
desc "run_command [NAME] [COMMAND]", "Runs a command in a server"
|
103
103
|
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
104
104
|
def run_command(name, command)
|
105
105
|
get_server(name, options[:config]).run_command(command)
|
106
106
|
end
|
107
107
|
|
108
|
-
desc "start [NAME]", "Start a
|
108
|
+
desc "start [NAME]", "Start a server"
|
109
109
|
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
110
110
|
def start(name)
|
111
111
|
get_server(name, options[:config]).start
|
112
112
|
end
|
113
113
|
|
114
|
-
desc "stop [NAME]", "Stop a
|
114
|
+
desc "stop [NAME]", "Stop a server"
|
115
115
|
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
116
116
|
def stop(name)
|
117
117
|
get_server(name, options[:config]).stop
|
118
118
|
end
|
119
119
|
|
120
|
-
desc "destroy [NAME]", "Destroy a
|
120
|
+
desc "destroy [NAME]", "Destroy a server"
|
121
121
|
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
122
|
-
option :unique, :aliases => "-u", :type => :boolean, :desc => "Also destroy the
|
123
|
-
option :shared, :aliases => "-s", :type => :boolean, :desc => "Also destroy the
|
124
|
-
option :platform, :aliases => "-p", :type => :boolean, :desc => "Also destroy the
|
122
|
+
option :unique, :aliases => "-u", :type => :boolean, :desc => "Also destroy the unique container"
|
123
|
+
option :shared, :aliases => "-s", :type => :boolean, :desc => "Also destroy the shared container"
|
124
|
+
option :platform, :aliases => "-p", :type => :boolean, :desc => "Also destroy the platform container"
|
125
125
|
def destroy(name)
|
126
126
|
server = get_server(name, options[:config])
|
127
127
|
server.destroy
|
@@ -144,10 +144,10 @@ module DevLXC::CLI
|
|
144
144
|
::DevLXC.create_platform_container(platform_container_name)
|
145
145
|
end
|
146
146
|
|
147
|
-
desc "cluster SUBCOMMAND ...ARGS", "Manage
|
147
|
+
desc "cluster SUBCOMMAND ...ARGS", "Manage cluster"
|
148
148
|
subcommand "cluster", Cluster
|
149
149
|
|
150
|
-
desc "server SUBCOMMAND ...ARGS", "Manage
|
150
|
+
desc "server SUBCOMMAND ...ARGS", "Manage server"
|
151
151
|
subcommand "server", Server
|
152
152
|
end
|
153
153
|
end
|
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: 0.
|
4
|
+
version: 0.4.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-
|
11
|
+
date: 2015-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|