dev-lxc 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +216 -169
- data/lib/dev-lxc/cli.rb +16 -14
- data/lib/dev-lxc/version.rb +1 -1
- metadata +5 -5
- /data/files/configs/{open-source.yaml → open-source.yml} +0 -0
- /data/files/configs/{standalone.yaml → standalone.yml} +0 -0
- /data/files/configs/{tier.yaml → tier.yml} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 841cacca8acef16b9e66f7db479afabb2916b89a
|
4
|
+
data.tar.gz: d88b7c22a5c072a5d644c5195f2fb92f4bd51d90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 498d1b7a98e1e91dcc0065e34c99242607df4121c480d1a8894597b37a5193715899746bd71a8c1797bb35546d79626ce0c350cb9a4d03dff7d7385c99822278
|
7
|
+
data.tar.gz: 282aac56f0d9b189c276de30d3c104c8020f5c03d070015e719091a77a07157b8194e08c0817da8cb1e53104e7ceca3967278e32efe706e3a1b1cbfe4bdddea0
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@ cluster builds for demo purposes, as well as general experimentation and explora
|
|
16
16
|
4. Base containers - Containers that are built to resemble a traditional server
|
17
17
|
5. ruby-lxc - Ruby bindings for liblxc
|
18
18
|
6. YAML - Simple, customizable definition of clusters; No more setting ENV variables
|
19
|
-
7. Build process closely
|
19
|
+
7. Build process closely follows online installation documentation
|
20
20
|
|
21
21
|
Its containers, standard init, networking and build process are designed to be similar
|
22
22
|
to what you would build if you follow the online installation documentation so the end
|
@@ -26,159 +26,195 @@ The Btrfs backed clones provide a quick clean slate which is helpful especially
|
|
26
26
|
experimenting and troubleshooting. Or it can be used to build a customized cluster
|
27
27
|
for demo purposes and be able to bring it up quickly and reliably.
|
28
28
|
|
29
|
-
While most of the plumbing is already in place for an HA cluster it actually can't be
|
30
|
-
used since I haven't been able to get DRBD working inside containers yet.
|
31
|
-
|
32
29
|
If you aren't familiar with using containers please read this introduction.
|
33
30
|
|
34
31
|
[LXC 1.0 Introduction](https://www.stgraber.org/2013/12/20/lxc-1-0-blog-post-series/)
|
35
32
|
|
36
33
|
## Requirements
|
37
34
|
|
38
|
-
|
39
|
-
[dev-lxc-platform](https://github.com/jeremiahsnapp/dev-lxc-platform) cookbook.
|
35
|
+
* dev-lxc-platform
|
40
36
|
|
41
|
-
|
37
|
+
The `dev-lxc` tool is designed to be used in a platform built by
|
38
|
+
[dev-lxc-platform](https://github.com/jeremiahsnapp/dev-lxc-platform).
|
42
39
|
|
43
|
-
|
40
|
+
Please follow the dev-lxc-platform usage instructions to create a suitable platform.
|
44
41
|
|
45
|
-
|
42
|
+
The dev-lxc-platform will automatically install this `dev-lxc` tool.
|
46
43
|
|
47
|
-
|
44
|
+
* Use root user
|
48
45
|
|
49
|
-
|
50
|
-
describes.
|
46
|
+
Once you login to the Vagrant VM platform you should run `sudo -i` to login as the root user.
|
51
47
|
|
52
|
-
|
48
|
+
Consider using `byobu` or `tmux` for a terminal multiplexer as [dev-lxc-platform README
|
49
|
+
describes](https://github.com/jeremiahsnapp/dev-lxc-platform#use-a-terminal-multiplexer).
|
53
50
|
|
54
|
-
|
51
|
+
* Setup Mounts and Packages
|
55
52
|
|
56
|
-
|
57
|
-
|
58
|
-
|
53
|
+
As [described below](https://github.com/jeremiahsnapp/dev-lxc#cluster-config-files)
|
54
|
+
`dev-lxc` uses a `dev-lxc.yml` config file for each cluster.
|
55
|
+
Be sure that you configure the `mounts` and `packages` lists in `dev-lxc.yml` to match your
|
56
|
+
particular environment.
|
59
57
|
|
60
|
-
|
61
|
-
configs are just examples. You need to make sure that you have each package you want to
|
62
|
-
use downloaded to appropriate directories that will be available to the container when
|
63
|
-
it is started.
|
58
|
+
## Update dev-lxc gem
|
64
59
|
|
65
|
-
|
66
|
-
Then configure the `dev-lxc-platform` `Vagrantfile` to mount that directory in the
|
67
|
-
Vagrant VM. Finally, configure the cluster's mount entries to mount the Vagrant
|
68
|
-
VM directory into each container.
|
60
|
+
Run `gem update dev-lxc` inside the Vagrant VM platform to ensure you have the latest version.
|
69
61
|
|
70
|
-
##
|
62
|
+
## Usage
|
71
63
|
|
72
|
-
|
64
|
+
### Shorter Commands are Faster (to type that is :)
|
73
65
|
|
74
|
-
|
66
|
+
The dev-lxc-platform's root user's `~/.bashrc` file has aliased `dl` to `dev-lxc` for ease of use but
|
67
|
+
for most instructions in this README I will use `dev-lxc` for clarity.
|
75
68
|
|
76
|
-
|
69
|
+
You only have to type enough of a `dev-lxc` subcommand to make it unique.
|
77
70
|
|
78
|
-
|
71
|
+
The following commands are equivalent:
|
79
72
|
|
80
|
-
|
81
|
-
|
73
|
+
```
|
74
|
+
dev-lxc cluster init standalone > dev-lxc.yml
|
75
|
+
dl cl i standalone > dev-lxc.yml
|
76
|
+
```
|
82
77
|
|
83
|
-
|
84
|
-
|
85
|
-
|
78
|
+
```
|
79
|
+
dev-lxc cluster start
|
80
|
+
dl cl start
|
81
|
+
```
|
86
82
|
|
87
|
-
|
83
|
+
```
|
84
|
+
dev-lxc cluster status
|
85
|
+
dl cl stat
|
86
|
+
```
|
88
87
|
|
89
|
-
|
88
|
+
```
|
89
|
+
dev-lxc cluster destroy
|
90
|
+
dl cl d
|
91
|
+
```
|
90
92
|
|
91
|
-
|
92
|
-
"p-" prefix on the container name.
|
93
|
+
### Create and Manage a Cluster
|
93
94
|
|
94
|
-
|
95
|
+
The following instructions will use a tier cluster for demonstration purposes.
|
96
|
+
The size of this cluster uses about 3GB ram and takes a long time for the first
|
97
|
+
build of the servers. Feel free to try the standalone config first.
|
95
98
|
|
96
|
-
|
97
|
-
A typical LXC container has minimal packages installed so `dev-lxc` makes sure that the
|
98
|
-
same packages used in Chef's [bento boxes](https://github.com/opscode/bento) are
|
99
|
-
installed to provide a more typical server environment.
|
100
|
-
A few additional packages are also installed.
|
99
|
+
#### Define cluster
|
101
100
|
|
102
|
-
|
101
|
+
The following command saves a predefined config to dev-lxc.yml.
|
103
102
|
|
104
|
-
|
103
|
+
Be sure you configure the
|
104
|
+
[mounts and packages entries](https://github.com/jeremiahsnapp/dev-lxc#cluster-config-files)
|
105
|
+
appropriately.
|
105
106
|
|
106
|
-
|
107
|
-
"s-" prefix on the container name.
|
107
|
+
dev-lxc cluster init tier > dev-lxc.yml
|
108
108
|
|
109
|
-
|
109
|
+
#### Start cluster
|
110
110
|
|
111
|
-
|
112
|
-
opscode-reporting and opscode-push-jobs-server are installed using `dpkg` or `rpm`.
|
111
|
+
Starting the cluster the first time takes awhile since it has a lot to build.
|
113
112
|
|
114
|
-
|
115
|
-
|
113
|
+
The tool automatically creates snapshot clones at appropriate times so future
|
114
|
+
creation of the cluster's servers is very quick.
|
116
115
|
|
117
|
-
|
118
|
-
get installed which makes this base container easy to be reused by another cluster that is
|
119
|
-
configured to use the same Chef packages.
|
116
|
+
dev-lxc cluster start
|
120
117
|
|
121
|
-
|
118
|
+
A test org, user, knife.rb and keys are automatically created in
|
119
|
+
the bootstrap backend server in `/root/chef-repo/.chef` for testing purposes.
|
122
120
|
|
123
|
-
|
121
|
+
The `knife-opc` plugin is installed in the embedded ruby environment of the
|
122
|
+
Private Chef and Enterprise Chef server to facilitate the creation of the test
|
123
|
+
org and user.
|
124
124
|
|
125
|
-
|
126
|
-
"u-" prefix on the container name.
|
125
|
+
#### Cluster status
|
127
126
|
|
128
|
-
|
127
|
+
Run the following command to see the status of the cluster.
|
129
128
|
|
130
|
-
|
129
|
+
dev-lxc cluster status
|
131
130
|
|
132
|
-
|
133
|
-
* dnsmasq is configured to reserve the specified IP address for the container's MAC address.
|
134
|
-
* A DNS entry is created in dnsmasq if appropriate.
|
135
|
-
* All installed Chef packages are configured.
|
136
|
-
* Test users and orgs are created.
|
137
|
-
* The opscode-manage package is installed and configured if specified.
|
131
|
+
This is an example of the output.
|
138
132
|
|
139
|
-
|
140
|
-
|
141
|
-
|
133
|
+
Cluster is available at https://chef-tier.lxc
|
134
|
+
be-tier.lxc running 10.0.3.202
|
135
|
+
fe1-tier.lxc running 10.0.3.203
|
142
136
|
|
143
|
-
|
137
|
+
[https://chef-tier.lxc](https://chef-tier.lxc) resolves to the frontend.
|
144
138
|
|
145
|
-
|
146
|
-
to destroy a single Chef server you have the option to also destroy any or all of the three types
|
147
|
-
of base containers associated with the cluster or server.
|
139
|
+
#### Create chef-repo
|
148
140
|
|
149
|
-
|
141
|
+
Create a local chef-repo with appropriate knife.rb and pem files.
|
150
142
|
|
151
|
-
dev-lxc cluster
|
143
|
+
dev-lxc cluster chef-repo
|
152
144
|
|
153
|
-
|
145
|
+
Now you can easily use knife to access the cluster.
|
154
146
|
|
155
|
-
|
147
|
+
cd chef-repo
|
148
|
+
knife ssl fetch
|
149
|
+
knife client list
|
156
150
|
|
157
|
-
|
151
|
+
#### Cheap cluster rebuilds
|
158
152
|
|
159
|
-
|
153
|
+
Clones of the servers as they existed immediately after initial installation, configuration and
|
154
|
+
test org and user creation are available so you can destroy the cluster and "rebuild" it within
|
155
|
+
seconds effectively starting with a clean slate very easily.
|
160
156
|
|
161
|
-
|
162
|
-
|
157
|
+
dev-lxc cluster destroy
|
158
|
+
dev-lxc cluster start
|
163
159
|
|
164
|
-
|
160
|
+
#### Stop and start the cluster
|
165
161
|
|
166
|
-
|
162
|
+
dev-lxc cluster stop
|
163
|
+
dev-lxc cluster start
|
167
164
|
|
168
|
-
|
169
|
-
an Ubuntu 12.04 base container now.
|
165
|
+
#### Backdoor access to each server's filesystem
|
170
166
|
|
171
|
-
|
167
|
+
The abspath subcommand can be used to prepend each server's rootfs path to a particular file.
|
168
|
+
|
169
|
+
For example, you can use the following command to edit each server's chef-server.rb file without
|
170
|
+
logging into the containers.
|
172
171
|
|
173
|
-
|
172
|
+
emacs $(dev-lxc cluster abspath /etc/opscode/chef-server.rb)
|
174
173
|
|
175
|
-
|
174
|
+
#### Run arbitrary commands in each server
|
175
|
+
|
176
|
+
After modifying the chef-server.rb you could use the run_command subcommand to tell each server
|
177
|
+
to run `chef-server-ctl reconfigure`.
|
178
|
+
|
179
|
+
dev-lxc cluster run_command 'chef-server-ctl reconfigure'
|
180
|
+
|
181
|
+
#### Destroy cluster
|
182
|
+
|
183
|
+
Use the following command to destroy the cluster's servers and also destroy their unique and shared
|
184
|
+
base containers if you want to build them from scratch.
|
185
|
+
|
186
|
+
dev-lxc cluster destroy -u -s
|
187
|
+
|
188
|
+
#### Use commands against a specific server
|
189
|
+
You can also run most of these commands against individual servers by using the server subcommand.
|
190
|
+
|
191
|
+
dev-lxc server ...
|
192
|
+
|
193
|
+
### Using the dev-lxc library
|
194
|
+
|
195
|
+
dev-lxc can also be used as a library.
|
196
|
+
|
197
|
+
require 'yaml'
|
198
|
+
require 'dev-lxc'
|
199
|
+
cluster = DevLXC::ChefCluster.new(YAML.load(IO.read('dev-lxc.yml')))
|
200
|
+
cluster.start
|
201
|
+
cluster.status
|
202
|
+
cluster.run_command("uptime")
|
203
|
+
server = DevLXC::ChefServer.new("fe1-tier.lxc", YAML.load(IO.read('dev-lxc.yml')))
|
204
|
+
server.stop
|
205
|
+
server.start
|
206
|
+
server.run_command("chef-server-ctl reconfigure")
|
207
|
+
cluster.destroy
|
208
|
+
|
209
|
+
## Cluster Config Files
|
210
|
+
|
211
|
+
dev-lxc uses a YAML configuration file named `dev-lxc.yml` to define a cluster.
|
176
212
|
|
177
213
|
The following command generates sample config files for various cluster topologies.
|
178
214
|
|
179
215
|
dev-lxc cluster init
|
180
216
|
|
181
|
-
`dev-lxc cluster init tier`
|
217
|
+
`dev-lxc cluster init tier > dev-lxc.yml` creates a `dev-lxc.yml` file with the following content:
|
182
218
|
|
183
219
|
platform_container: p-ubuntu-1404
|
184
220
|
topology: tier
|
@@ -203,26 +239,42 @@ The following command generates sample config files for various cluster topologi
|
|
203
239
|
# ipaddress: 10.0.3.204
|
204
240
|
|
205
241
|
This config defines a tier cluster consisting of a single backend and a single frontend.
|
206
|
-
A second frontend is commented out to conserve resources.
|
207
242
|
|
208
|
-
|
209
|
-
|
243
|
+
A second frontend is commented out to conserve resources. If you uncomment the second
|
244
|
+
frontend then both frontends will be created and dnsmasq will resolve the `api_fqdn`
|
245
|
+
[chef-tier.lxc](chef-tier.lxc) to both frontends using a round-robin policy.
|
210
246
|
|
211
247
|
The config file is very customizable. You can add or remove mounts, packages or servers,
|
212
248
|
change ip addresses, change server names, change the base_platform and more.
|
213
249
|
|
214
|
-
|
250
|
+
The `mounts` list describes what directories get mounted from the Vagrant VM platform into
|
251
|
+
each container. You need to make sure that you configure the mount entries to be
|
252
|
+
appropriate for your environment.
|
253
|
+
|
254
|
+
The same is true for the `packages` list. The paths that are provided in the default configs are just examples.
|
255
|
+
You need to make sure that you have each package you want to use downloaded to appropriate directories
|
256
|
+
that will be available to the container when it is started.
|
257
|
+
|
258
|
+
I recommend downloading the packages to a directory on your workstation.
|
259
|
+
Then configure the
|
260
|
+
[dev-lxc-platform's .kitchen.yml](https://github.com/jeremiahsnapp/dev-lxc-platform#description)
|
261
|
+
to mount that directory in the Vagrant VM platform.
|
262
|
+
Then configure the cluster's mount entries in `dev-lxc.yml` to mount the Vagrant VM platform's
|
263
|
+
directory into each container.
|
264
|
+
|
265
|
+
Make sure the mounts and packages represent actual paths that are available in your environment.
|
215
266
|
|
216
267
|
### Managing Multiple Clusters
|
217
268
|
|
218
|
-
By default, `dev-lxc` looks for a `dev-lxc.
|
269
|
+
By default, `dev-lxc` looks for a `dev-lxc.yml` file in the present working directory.
|
219
270
|
You can also specify a particular config file as an option for most dev-lxc commands.
|
220
271
|
|
221
|
-
|
272
|
+
The following is an example of managing multiple clusters while still avoiding specifying
|
273
|
+
each cluster's config file.
|
222
274
|
|
223
275
|
mkdir -p ~/clusters/{clusterA,clusterB}
|
224
|
-
dev-lxc cluster init tier > ~/clusters/clusterA/dev-lxc.
|
225
|
-
dev-lxc cluster init standalone > ~/clusters/clusterB/dev-lxc.
|
276
|
+
dev-lxc cluster init tier > ~/clusters/clusterA/dev-lxc.yml
|
277
|
+
dev-lxc cluster init standalone > ~/clusters/clusterB/dev-lxc.yml
|
226
278
|
cd ~/clusters/clusterA && dev-lxc cluster start # starts clusterA
|
227
279
|
cd ~/clusters/clusterB && dev-lxc cluster start # starts clusterB
|
228
280
|
|
@@ -231,7 +283,7 @@ I use the following strategy to avoid specifying each cluster's config file whil
|
|
231
283
|
The default cluster configs are already designed to be unique from each other but as you build
|
232
284
|
more clusters you have to maintain uniqueness across the YAML config files for the following items.
|
233
285
|
|
234
|
-
|
286
|
+
* Server names and `api_fqdn`
|
235
287
|
|
236
288
|
Server names should really be unique across all clusters.
|
237
289
|
|
@@ -246,9 +298,9 @@ more clusters you have to maintain uniqueness across the YAML config files for t
|
|
246
298
|
It is easy to provide uniqueness. For example, you can use the following command to replace `-tier`
|
247
299
|
with `-1234` in a tier cluster's config.
|
248
300
|
|
249
|
-
sed -i 's/-tier/-1234/' dev-lxc.
|
301
|
+
sed -i 's/-tier/-1234/' dev-lxc.yml
|
250
302
|
|
251
|
-
|
303
|
+
* IP Addresses
|
252
304
|
|
253
305
|
IP addresses uniqueness only matters when clusters with the same IP's are running.
|
254
306
|
|
@@ -261,107 +313,102 @@ more clusters you have to maintain uniqueness across the YAML config files for t
|
|
261
313
|
|
262
314
|
Use unique IP's from that range when configuring clusters.
|
263
315
|
|
264
|
-
##
|
316
|
+
## Base Containers
|
265
317
|
|
266
|
-
|
318
|
+
One of the key things this tool uses is the concept of "base" containers.
|
267
319
|
|
268
|
-
|
269
|
-
|
320
|
+
`dev-lxc` creates base containers with a "p-", "s-" or "u-" prefix on the name to distinguish it as
|
321
|
+
a "platform", "shared" or "unique" base container.
|
270
322
|
|
271
|
-
|
323
|
+
Base containers are then snapshot cloned using the btrfs filesystem to very quickly
|
324
|
+
provide a lightweight duplicate of the base container. This clone is either used to build
|
325
|
+
another base container or a container that will actually be run.
|
272
326
|
|
273
|
-
|
327
|
+
During a cluster build process the base containers that get created fall into three categories.
|
274
328
|
|
275
|
-
|
276
|
-
dl cl i standalone
|
329
|
+
1. Platform
|
277
330
|
|
278
|
-
|
279
|
-
|
331
|
+
The platform base container is the first to get created and is identified by the
|
332
|
+
"p-" prefix on the container name.
|
280
333
|
|
281
|
-
|
282
|
-
dl cl d
|
334
|
+
`DevLXC#create_base_platform` controls the creation of a platform base container.
|
283
335
|
|
284
|
-
|
336
|
+
This container provides the chosen OS platform and version (e.g. p-ubuntu-1404).
|
337
|
+
A typical LXC container has minimal packages installed so `dev-lxc` makes sure that the
|
338
|
+
same packages used in Chef's [bento boxes](https://github.com/opscode/bento) are
|
339
|
+
installed to provide a more typical server environment.
|
340
|
+
A few additional packages are also installed.
|
285
341
|
|
286
|
-
|
287
|
-
The size of this cluster uses about 3GB ram and takes a long time for the first
|
288
|
-
build of the servers. Feel free to try the standalone config first.
|
342
|
+
*Once this platform base container is created there is rarely a need to delete it.*
|
289
343
|
|
290
|
-
|
344
|
+
2. Shared
|
291
345
|
|
292
|
-
|
346
|
+
The shared base container is the second to get created and is identified by the
|
347
|
+
"s-" prefix on the container name.
|
293
348
|
|
294
|
-
|
349
|
+
`DevLXC::ChefServer#create_base_server` controls the creation of a shared base container.
|
295
350
|
|
296
|
-
|
297
|
-
|
351
|
+
Chef packages that are common to all servers in a Chef cluster, such as Chef server,
|
352
|
+
opscode-reporting and opscode-push-jobs-server are installed using `dpkg` or `rpm`.
|
298
353
|
|
299
|
-
|
354
|
+
Note the manage package will not be installed at this point since it is not common to all
|
355
|
+
servers (i.e. it does not get installed on backend servers).
|
300
356
|
|
301
|
-
|
357
|
+
The name of this base container is built from the names and versions of the Chef packages that
|
358
|
+
get installed which makes this base container easy to be reused by another cluster that is
|
359
|
+
configured to use the same Chef packages.
|
302
360
|
|
303
|
-
|
304
|
-
the bootstrap backend server in /root/chef-repo/.chef for testing purposes.
|
305
|
-
The `knife-opc` plugin is installed in the embedded ruby environment of the
|
306
|
-
Private Chef and Enterprise Chef server to facilitate the creation of the test
|
307
|
-
org and user.
|
361
|
+
*Since no configuration actually happens yet there is rarely a need to delete this container.*
|
308
362
|
|
309
|
-
|
363
|
+
3. Unique
|
310
364
|
|
311
|
-
|
365
|
+
The unique base container is the last to get created and is identified by the
|
366
|
+
"u-" prefix on the container name.
|
312
367
|
|
313
|
-
|
314
|
-
This makes it easy to use knife.
|
368
|
+
`DevLXC::ChefServer#create` controls the creation of a unique base container.
|
315
369
|
|
316
|
-
|
317
|
-
cd chef-repo
|
318
|
-
knife ssl fetch
|
319
|
-
knife client list
|
370
|
+
Each unique Chef server (e.g. standalone, backend or frontend) is created.
|
320
371
|
|
321
|
-
|
372
|
+
* The specified hostname is assigned.
|
373
|
+
* dnsmasq is configured to reserve the specified IP address for the container's MAC address.
|
374
|
+
* A DNS entry is created in dnsmasq if appropriate.
|
375
|
+
* All installed Chef packages are configured.
|
376
|
+
* Test users and orgs are created.
|
377
|
+
* The opscode-manage package is installed and configured if specified.
|
322
378
|
|
323
|
-
|
379
|
+
After each server is fully configured a snapshot clone of it is made resulting in the server's
|
380
|
+
unique base container. These unique base containers make it very easy to quickly recreate
|
381
|
+
a Chef cluster from a clean starting point.
|
324
382
|
|
325
|
-
|
326
|
-
are available so you can destroy the cluster and "rebuild" it within seconds effectively starting
|
327
|
-
with a clean slate.
|
383
|
+
### Destroying Base Containers
|
328
384
|
|
329
|
-
|
330
|
-
|
385
|
+
When using `dev-lxc cluster destroy` to destroy an entire Chef cluster or `dev-lxc server destroy [NAME]`
|
386
|
+
to destroy a single Chef server you have the option to also destroy any or all of the three types
|
387
|
+
of base containers associated with the cluster or server.
|
331
388
|
|
332
|
-
|
389
|
+
Either of the following commands will list the options available.
|
333
390
|
|
334
|
-
|
391
|
+
dev-lxc cluster help destroy
|
335
392
|
|
336
|
-
|
393
|
+
dev-lxc server help destroy
|
337
394
|
|
338
|
-
|
339
|
-
to run `private-chef-ctl reconfigure`.
|
395
|
+
Of course, you can also just use the standard LXC commands to destroy any container.
|
340
396
|
|
341
|
-
|
397
|
+
lxc-destroy -n [NAME]
|
342
398
|
|
343
|
-
|
344
|
-
base containers so you can build them from scratch.
|
399
|
+
### Manually Create a Platform Base Container
|
345
400
|
|
346
|
-
|
401
|
+
Platform base containers can be used for purposes other than building clusters. For example, they can
|
402
|
+
be used as Chef nodes for testing purposes.
|
347
403
|
|
348
|
-
You can
|
404
|
+
You can see a menu of platform base containers this tool can create by using the following command.
|
349
405
|
|
350
|
-
dev-lxc
|
406
|
+
dev-lxc create
|
351
407
|
|
352
|
-
|
408
|
+
The initial creation of platform base containers can take awhile so let's go ahead and start creating
|
409
|
+
an Ubuntu 12.04 base container now.
|
353
410
|
|
354
|
-
dev-lxc
|
355
|
-
|
356
|
-
irb(main):001:0> require 'yaml'
|
357
|
-
irb(main):002:0> require 'dev-lxc'
|
358
|
-
irb(main):003:0> cluster = DevLXC::ChefCluster.new(YAML.load(IO.read('dev-lxc.yaml')))
|
359
|
-
irb(main):004:0> cluster.start
|
360
|
-
irb(main):005:0> server = DevLXC::ChefServer.new("fe1-tier.lxc", YAML.load(IO.read('dev-lxc.yaml')))
|
361
|
-
irb(main):006:0> server.stop
|
362
|
-
irb(main):007:0> server.start
|
363
|
-
irb(main):008:0> server.run_command("private-chef-ctl reconfigure")
|
364
|
-
irb(main):009:0> cluster.destroy
|
411
|
+
dev-lxc create p-ubuntu-1404
|
365
412
|
|
366
413
|
## Contributing
|
367
414
|
|
data/lib/dev-lxc/cli.rb
CHANGED
@@ -7,6 +7,7 @@ module DevLXC::CLI
|
|
7
7
|
no_commands{
|
8
8
|
def get_cluster(config_option)
|
9
9
|
config = "dev-lxc.yaml" if File.exists?("dev-lxc.yaml")
|
10
|
+
config = "dev-lxc.yml" if File.exists?("dev-lxc.yml")
|
10
11
|
config = config_option unless config_option.nil?
|
11
12
|
raise "A cluster config file must be provided" if config.nil?
|
12
13
|
::DevLXC::ChefCluster.new(YAML.load(IO.read(config)))
|
@@ -22,47 +23,47 @@ module DevLXC::CLI
|
|
22
23
|
selection = ask("Which cluster topology do you want to use?", :limited_to => topologies_with_index.map{|c| c[0].to_s})
|
23
24
|
topology = topologies[selection.to_i - 1]
|
24
25
|
end
|
25
|
-
puts IO.read("#{File.dirname(__FILE__)}/../../files/configs/#{topology}.
|
26
|
+
puts IO.read("#{File.dirname(__FILE__)}/../../files/configs/#{topology}.yml")
|
26
27
|
end
|
27
28
|
|
28
29
|
desc "status", "Show status of a cluster's Chef servers"
|
29
|
-
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.
|
30
|
+
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
30
31
|
def status
|
31
32
|
get_cluster(options[:config]).status
|
32
33
|
end
|
33
34
|
|
34
35
|
desc "abspath [ROOTFS_PATH]", "Returns the absolute path to a file for each Chef server in a cluster"
|
35
|
-
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.
|
36
|
+
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
36
37
|
def abspath(rootfs_path)
|
37
38
|
puts get_cluster(options[:config]).abspath(rootfs_path).join(" ")
|
38
39
|
end
|
39
40
|
|
40
41
|
desc "chef-repo", "Creates a chef-repo in the current directory using files from the cluster's backend /root/chef-repo"
|
41
|
-
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.
|
42
|
+
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
42
43
|
def chef_repo
|
43
44
|
get_cluster(options[:config]).chef_repo
|
44
45
|
end
|
45
46
|
|
46
47
|
desc "run_command [COMMAND]", "Runs a command in each Chef server in a cluster"
|
47
|
-
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.
|
48
|
+
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
48
49
|
def run_command(command)
|
49
50
|
get_cluster(options[:config]).run_command(command)
|
50
51
|
end
|
51
52
|
|
52
53
|
desc "start", "Start a cluster's Chef servers"
|
53
|
-
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.
|
54
|
+
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
54
55
|
def start
|
55
56
|
get_cluster(options[:config]).start
|
56
57
|
end
|
57
58
|
|
58
59
|
desc "stop", "Stop a cluster's Chef servers"
|
59
|
-
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.
|
60
|
+
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
60
61
|
def stop
|
61
62
|
get_cluster(options[:config]).stop
|
62
63
|
end
|
63
64
|
|
64
65
|
desc "destroy", "Destroy a cluster's Chef servers"
|
65
|
-
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.
|
66
|
+
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
66
67
|
option :unique, :aliases => "-u", :type => :boolean, :desc => "Also destroy the cluster's unique containers"
|
67
68
|
option :shared, :aliases => "-s", :type => :boolean, :desc => "Also destroy the cluster's shared container"
|
68
69
|
option :platform, :aliases => "-p", :type => :boolean, :desc => "Also destroy the cluster's platform container"
|
@@ -79,6 +80,7 @@ module DevLXC::CLI
|
|
79
80
|
no_commands{
|
80
81
|
def get_server(name, config_option)
|
81
82
|
config = "dev-lxc.yaml" if File.exists?("dev-lxc.yaml")
|
83
|
+
config = "dev-lxc.yml" if File.exists?("dev-lxc.yml")
|
82
84
|
config = config_option unless config_option.nil?
|
83
85
|
raise "A cluster config file must be provided" if config.nil?
|
84
86
|
::DevLXC::ChefServer.new(name, YAML.load(IO.read(config)))
|
@@ -86,37 +88,37 @@ module DevLXC::CLI
|
|
86
88
|
}
|
87
89
|
|
88
90
|
desc "status [NAME]", "Show status of a cluster's Chef server"
|
89
|
-
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.
|
91
|
+
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
90
92
|
def status(name)
|
91
93
|
get_server(name, options[:config]).status
|
92
94
|
end
|
93
95
|
|
94
96
|
desc "abspath [NAME] [ROOTFS_PATH]", "Returns the absolute path to a file in a cluster's Chef server"
|
95
|
-
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.
|
97
|
+
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
96
98
|
def abspath(name, rootfs_path)
|
97
99
|
puts get_server(name, options[:config]).abspath(rootfs_path)
|
98
100
|
end
|
99
101
|
|
100
102
|
desc "run_command [NAME] [COMMAND]", "Runs a command in a cluster's Chef server"
|
101
|
-
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.
|
103
|
+
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
102
104
|
def run_command(name, command)
|
103
105
|
get_server(name, options[:config]).run_command(command)
|
104
106
|
end
|
105
107
|
|
106
108
|
desc "start [NAME]", "Start a cluster's Chef server"
|
107
|
-
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.
|
109
|
+
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
108
110
|
def start(name)
|
109
111
|
get_server(name, options[:config]).start
|
110
112
|
end
|
111
113
|
|
112
114
|
desc "stop [NAME]", "Stop a cluster's Chef server"
|
113
|
-
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.
|
115
|
+
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
114
116
|
def stop(name)
|
115
117
|
get_server(name, options[:config]).stop
|
116
118
|
end
|
117
119
|
|
118
120
|
desc "destroy [NAME]", "Destroy a cluster's Chef server"
|
119
|
-
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.
|
121
|
+
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
|
120
122
|
option :unique, :aliases => "-u", :type => :boolean, :desc => "Also destroy the server's unique container"
|
121
123
|
option :shared, :aliases => "-s", :type => :boolean, :desc => "Also destroy the server's shared container"
|
122
124
|
option :platform, :aliases => "-p", :type => :boolean, :desc => "Also destroy the server's platform container"
|
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.3.
|
4
|
+
version: 0.3.1
|
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-02-
|
11
|
+
date: 2015-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -81,9 +81,9 @@ files:
|
|
81
81
|
- Rakefile
|
82
82
|
- bin/dev-lxc
|
83
83
|
- dev-lxc.gemspec
|
84
|
-
- files/configs/open-source.
|
85
|
-
- files/configs/standalone.
|
86
|
-
- files/configs/tier.
|
84
|
+
- files/configs/open-source.yml
|
85
|
+
- files/configs/standalone.yml
|
86
|
+
- files/configs/tier.yml
|
87
87
|
- lib/dev-lxc.rb
|
88
88
|
- lib/dev-lxc/chef-cluster.rb
|
89
89
|
- lib/dev-lxc/chef-server.rb
|
File without changes
|
File without changes
|
File without changes
|