dev-lxc 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +75 -22
- data/lib/dev-lxc/chef-cluster.rb +10 -4
- data/lib/dev-lxc/chef-server.rb +9 -4
- data/lib/dev-lxc/cli.rb +12 -4
- data/lib/dev-lxc/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -42,6 +42,13 @@ Please follow the dev-lxc-platform usage instructions to create a suitable platf
|
|
42
42
|
|
43
43
|
The cookbook will automatically install this dev-lxc tool.
|
44
44
|
|
45
|
+
### Use root
|
46
|
+
|
47
|
+
Once you login to the Vagrant VM you should run `sudo -i` to login as the root user.
|
48
|
+
|
49
|
+
Consider using `byobu` or `tmux` for a terminal multiplexer as `dev-lxc-platform` README
|
50
|
+
describes.
|
51
|
+
|
45
52
|
### Mounts and Packages (batteries not included)
|
46
53
|
|
47
54
|
As described below `dev-lxc` uses a YAML config file for each cluster.
|
@@ -67,43 +74,71 @@ the Vagrant VM and then reprovision the VM using `vagrant provision`.
|
|
67
74
|
|
68
75
|
## Usage
|
69
76
|
|
70
|
-
###
|
77
|
+
### Base Containers Explained
|
71
78
|
|
72
|
-
|
73
|
-
instructions I will use `dev-lxc`.
|
79
|
+
One of the key things this tool uses is the concept of "base" containers.
|
74
80
|
|
75
|
-
|
81
|
+
`dev-lxc` creates containers with "b-" prepended to the name to distinguish it as
|
82
|
+
a base container.
|
76
83
|
|
77
|
-
|
84
|
+
Base containers are then snapshot cloned using the btrfs filesystem to provide very
|
85
|
+
quick, lightweight duplicates of the base container that are either used to build
|
86
|
+
another base container or a container that will actually be run.
|
78
87
|
|
79
|
-
|
88
|
+
During a cluster build process the base containers that get created fall into three categories.
|
80
89
|
|
81
|
-
|
82
|
-
dl cl i
|
90
|
+
1. Platform
|
83
91
|
|
84
|
-
|
85
|
-
dl cl start
|
92
|
+
The platform base container is the first to get created.
|
86
93
|
|
87
|
-
|
88
|
-
|
94
|
+
It is just the chosen OS platform and version (e.g. b-ubuntu-1204). A typical LXC container
|
95
|
+
has minimal packages installed so `dev-lxc` makes sure that the same packages used in Chef's
|
96
|
+
[bento boxes](https://github.com/opscode/bento) are installed to provide a more typical
|
97
|
+
server environment. A few additional packages are also installed.
|
89
98
|
|
90
|
-
|
99
|
+
Once this platform base container is created there is rarely a need to delete it
|
100
|
+
or recreate it.
|
91
101
|
|
92
|
-
|
93
|
-
It creates servers with "b-" prepended to the name to signify it as a base server.
|
94
|
-
Base servers are then snapshot cloned using the btrfs filesystem to provide very
|
95
|
-
quick, lightweight duplicates of the base server that are either used to build
|
96
|
-
another base server or a usable server.
|
102
|
+
2. Shared
|
97
103
|
|
98
|
-
The
|
99
|
-
let's go ahead and start creating an Ubuntu 12.04 base server now.
|
104
|
+
The shared base container is the second to get created.
|
100
105
|
|
101
|
-
|
106
|
+
Common Chef packages such as Chef server, opscode-reporting and opscode-push-jobs-server are
|
107
|
+
installed using `dpkg` or `rpm`.
|
108
|
+
|
109
|
+
Note the manage package will not be installed at this point since it is not common to all
|
110
|
+
servers (i.e. it does not get installed on backend servers).
|
111
|
+
|
112
|
+
Since no configuration actually happens yet there is rarely a need to delete this container.
|
113
|
+
If another cluster is configured to use the same packages that are installed in this container
|
114
|
+
then time is saved by just cloning this container for the new cluster to use.
|
115
|
+
|
116
|
+
3. Unique
|
117
|
+
|
118
|
+
The unique base container is the last to get created.
|
119
|
+
|
120
|
+
Each unique Chef server (e.g. standalone, backend or frontend) is created.
|
121
|
+
|
122
|
+
* The specified hostname is assigned.
|
123
|
+
* dnsmasq is configured to reserve the specified IP address for the container's MAC address.
|
124
|
+
* A DNS entry is created in dnsmasq if appropriate.
|
125
|
+
* All installed Chef packages are configured.
|
126
|
+
* The opscode-manage package is installed and configured if specified.
|
127
|
+
|
128
|
+
### Using `dev-lxc` to manually create a platform base container
|
102
129
|
|
103
|
-
|
130
|
+
Platform base containers can be used for purposes other than building clusters. For example, they can
|
131
|
+
be used as Chef nodes for testing purposes.
|
132
|
+
|
133
|
+
You can see a menu of platform base containers this tool can create by using the following command.
|
104
134
|
|
105
135
|
dev-lxc create
|
106
136
|
|
137
|
+
The initial creation of platform base containers can take awhile so let's go ahead and start creating
|
138
|
+
an Ubuntu 12.04 base container now.
|
139
|
+
|
140
|
+
dev-lxc create b-ubuntu-1204
|
141
|
+
|
107
142
|
### Cluster Config Files
|
108
143
|
|
109
144
|
dev-lxc uses a yaml configuration file to define a cluster.
|
@@ -195,6 +230,24 @@ more clusters you have to maintain uniqueness across the YAML config files for t
|
|
195
230
|
|
196
231
|
Use unique IP's from that range when configuring clusters.
|
197
232
|
|
233
|
+
### Shorter Commands are Faster (to type that is :)
|
234
|
+
|
235
|
+
The root user's `~/.bashrc` file has aliased `dl` to `dev-lxc` for ease of use but for most
|
236
|
+
instructions in this README I will use `dev-lxc`.
|
237
|
+
|
238
|
+
You only have to type enough of a `dev-lxc` subcommand to make it unique.
|
239
|
+
|
240
|
+
The following commands are equivalent:
|
241
|
+
|
242
|
+
dev-lxc cluster init standalone
|
243
|
+
dl cl i standalone
|
244
|
+
|
245
|
+
dev-lxc cluster start
|
246
|
+
dl cl start
|
247
|
+
|
248
|
+
dev-lxc cluster destroy
|
249
|
+
dl cl d
|
250
|
+
|
198
251
|
### Create and Manage a Cluster
|
199
252
|
|
200
253
|
The following instructions will use a tier cluster for demonstration purposes.
|
data/lib/dev-lxc/chef-cluster.rb
CHANGED
@@ -68,11 +68,17 @@ module DevLXC
|
|
68
68
|
chef_servers.reverse_each { |cs| cs.destroy }
|
69
69
|
end
|
70
70
|
|
71
|
-
def
|
72
|
-
|
73
|
-
|
71
|
+
def destroy_base_container(type)
|
72
|
+
case type
|
73
|
+
when :unique
|
74
|
+
@servers.keys.each do |server_name|
|
75
|
+
DevLXC::ChefServer.new(server_name, @cluster_config).destroy_base_container(:unique)
|
76
|
+
end
|
77
|
+
when :shared
|
78
|
+
DevLXC::ChefServer.new(@servers.keys.first, @cluster_config).destroy_base_container(:shared)
|
79
|
+
when :platform
|
80
|
+
DevLXC::ChefServer.new(@servers.keys.first, @cluster_config).destroy_base_container(:platform)
|
74
81
|
end
|
75
|
-
DevLXC::Container.new(DevLXC::ChefServer.new(@servers.keys.first, @cluster_config).base_server_name).destroy
|
76
82
|
end
|
77
83
|
|
78
84
|
def chef_server_config
|
data/lib/dev-lxc/chef-server.rb
CHANGED
@@ -88,10 +88,15 @@ module DevLXC
|
|
88
88
|
DevLXC.reload_dnsmasq
|
89
89
|
end
|
90
90
|
|
91
|
-
def
|
92
|
-
|
93
|
-
|
94
|
-
|
91
|
+
def destroy_base_container(type)
|
92
|
+
case type
|
93
|
+
when :unique
|
94
|
+
DevLXC::Container.new("b-#{@server.name}").destroy
|
95
|
+
when :shared
|
96
|
+
DevLXC::Container.new(@base_server_name).destroy
|
97
|
+
when :platform
|
98
|
+
DevLXC::Container.new(@base_platform).destroy
|
99
|
+
end
|
95
100
|
end
|
96
101
|
|
97
102
|
def create
|
data/lib/dev-lxc/cli.rb
CHANGED
@@ -57,11 +57,15 @@ module DevLXC::CLI
|
|
57
57
|
|
58
58
|
desc "destroy", "Destroy a cluster's Chef servers"
|
59
59
|
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yaml will be used by default"
|
60
|
-
option :
|
60
|
+
option :unique, :aliases => "-u", :type => :boolean, :desc => "Also destroy the cluster's unique base containers"
|
61
|
+
option :shared, :aliases => "-s", :type => :boolean, :desc => "Also destroy the cluster's shared base container"
|
62
|
+
option :platform, :aliases => "-p", :type => :boolean, :desc => "Also destroy the cluster's platform base container"
|
61
63
|
def destroy
|
62
64
|
cluster = get_cluster(options[:config])
|
63
65
|
cluster.destroy
|
64
|
-
cluster.
|
66
|
+
cluster.destroy_base_container(:unique) if options[:unique]
|
67
|
+
cluster.destroy_base_container(:shared) if options[:shared]
|
68
|
+
cluster.destroy_base_container(:platform) if options[:platform]
|
65
69
|
end
|
66
70
|
end
|
67
71
|
|
@@ -107,11 +111,15 @@ module DevLXC::CLI
|
|
107
111
|
|
108
112
|
desc "destroy [NAME]", "Destroy a cluster's Chef server"
|
109
113
|
option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yaml will be used by default"
|
110
|
-
option :
|
114
|
+
option :unique, :aliases => "-u", :type => :boolean, :desc => "Also destroy the server's unique base container"
|
115
|
+
option :shared, :aliases => "-s", :type => :boolean, :desc => "Also destroy the server's shared base container"
|
116
|
+
option :platform, :aliases => "-p", :type => :boolean, :desc => "Also destroy the server's platform base container"
|
111
117
|
def destroy(name)
|
112
118
|
server = get_server(name, options[:config])
|
113
119
|
server.destroy
|
114
|
-
server.
|
120
|
+
server.destroy_base_container(:unique) if options[:unique]
|
121
|
+
server.destroy_base_container(:shared) if options[:shared]
|
122
|
+
server.destroy_base_container(:platform) if options[:platform]
|
115
123
|
end
|
116
124
|
end
|
117
125
|
|
data/lib/dev-lxc/version.rb
CHANGED