dev-lxc 2.0.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +99 -363
- data/docs/adhoc_clusters.md +22 -0
- data/docs/base_containers.md +44 -0
- data/docs/configuration.md +182 -0
- data/docs/dev-lxc_version_2.md +10 -0
- data/docs/manage_multiple_clusters.md +30 -0
- data/docs/prerequisites.md +75 -0
- data/docs/usage.md +187 -0
- data/lib/dev-lxc/cli.rb +74 -0
- data/lib/dev-lxc/cluster.rb +371 -206
- data/lib/dev-lxc/version.rb +1 -1
- metadata +10 -3
@@ -0,0 +1,44 @@
|
|
1
|
+
### Base Containers
|
2
|
+
|
3
|
+
The container that is used as the base container for a cluster's containers must exist before
|
4
|
+
the cluster can be built. The cluster's containers are cloned from the base container using
|
5
|
+
the btrfs filesystem to very quickly provide a lightweight duplicate of the container.
|
6
|
+
|
7
|
+
This container provides the chosen OS platform and version (e.g. b-ubuntu-1404).
|
8
|
+
|
9
|
+
A typical LXC container has minimal packages installed so `dev-lxc` makes sure that the
|
10
|
+
same packages used in Chef's [bento boxes](https://github.com/opscode/bento) are
|
11
|
+
installed to provide a more typical server environment.
|
12
|
+
A few additional packages are also installed.
|
13
|
+
|
14
|
+
Base containers have openssh-server installed and running with unique SSH Host Keys.
|
15
|
+
|
16
|
+
Base containers have a "dev-lxc" user with "dev-lxc" password and passwordless sudo.
|
17
|
+
|
18
|
+
*Once this base container is created there is rarely a need to delete it.*
|
19
|
+
|
20
|
+
### Create a dev-lxc Base Container
|
21
|
+
|
22
|
+
dev-lxc is able to create base containers that have openssh-server installed and running with unique SSH Host Keys.
|
23
|
+
|
24
|
+
dev-lxc base containers have a "dev-lxc" user with "dev-lxc" password and passwordless sudo.
|
25
|
+
|
26
|
+
You can see a menu of base containers that `dev-lxc` can create by using the following command.
|
27
|
+
|
28
|
+
```
|
29
|
+
dev-lxc create-base-container
|
30
|
+
```
|
31
|
+
|
32
|
+
The initial creation of base containers can take awhile so let's go ahead and start creating
|
33
|
+
an Ubuntu 14.04 container now.
|
34
|
+
|
35
|
+
```
|
36
|
+
dev-lxc create-base-container b-ubuntu-1404
|
37
|
+
```
|
38
|
+
|
39
|
+
Note: It is possible to pass additional arguments to the underlying LXC create command.
|
40
|
+
For example:
|
41
|
+
|
42
|
+
```
|
43
|
+
dev-lxc create-base-container b-ubuntu-1404 -o -- '--no-validate --keyserver http://my.key.server.com'
|
44
|
+
```
|
@@ -0,0 +1,182 @@
|
|
1
|
+
### dev-lxc.yml Config Files
|
2
|
+
|
3
|
+
dev-lxc uses a YAML configuration file named `dev-lxc.yml` to define a cluster.
|
4
|
+
|
5
|
+
The `init` command generates sample config files for various server types.
|
6
|
+
|
7
|
+
Let's generate a config for a cluster with a standalone Chef Server, Chef Automate server,
|
8
|
+
private Supermarket server, build node and an infrastructure node.
|
9
|
+
|
10
|
+
```
|
11
|
+
dev-lxc init --chef --automate --supermarket --build-nodes --nodes > dev-lxc.yml
|
12
|
+
```
|
13
|
+
|
14
|
+
The contents of `dev-lxc.yml` should look like this.
|
15
|
+
|
16
|
+
```
|
17
|
+
# base_container must be the name of an existing container
|
18
|
+
base_container: b-ubuntu-1404
|
19
|
+
|
20
|
+
# list any host directories you want mounted into the servers
|
21
|
+
#mounts:
|
22
|
+
# - /root/dev root/dev
|
23
|
+
|
24
|
+
# list any SSH public keys you want added to /home/dev-lxc/.ssh/authorized_keys
|
25
|
+
#ssh-keys:
|
26
|
+
# - /root/dev/clusters/id_rsa.pub
|
27
|
+
|
28
|
+
# DHCP reserved (static) IPs must be selected from the IP range 10.0.3.150 - 254
|
29
|
+
|
30
|
+
chef-server:
|
31
|
+
users: # a user's password will be the same as its username
|
32
|
+
- mary-admin
|
33
|
+
- joe-user
|
34
|
+
orgs:
|
35
|
+
demo:
|
36
|
+
admins:
|
37
|
+
- mary-admin
|
38
|
+
non-admins:
|
39
|
+
- joe-user
|
40
|
+
servers:
|
41
|
+
chef.lxc:
|
42
|
+
ipaddress: 10.0.3.203
|
43
|
+
products:
|
44
|
+
chef-server:
|
45
|
+
manage:
|
46
|
+
push-jobs-server:
|
47
|
+
reporting:
|
48
|
+
|
49
|
+
supermarket:
|
50
|
+
servers:
|
51
|
+
supermarket.lxc:
|
52
|
+
ipaddress: 10.0.3.206
|
53
|
+
products:
|
54
|
+
supermarket:
|
55
|
+
|
56
|
+
automate:
|
57
|
+
servers:
|
58
|
+
automate.lxc:
|
59
|
+
ipaddress: 10.0.3.200
|
60
|
+
products:
|
61
|
+
delivery:
|
62
|
+
chefdk: # downloaded only for build nodes
|
63
|
+
license_path: /CHANGE/ME
|
64
|
+
chef_org: delivery
|
65
|
+
enterprise_name: demo-ent
|
66
|
+
|
67
|
+
build-nodes:
|
68
|
+
servers:
|
69
|
+
build-node-1.lxc:
|
70
|
+
|
71
|
+
nodes:
|
72
|
+
chef_server_url: https://chef.lxc/organizations/demo
|
73
|
+
validation_client_name: demo-validator
|
74
|
+
# comment out or remove the validation_key path to use chef-server keys generated by dev-lxc
|
75
|
+
validation_key: # /path/to/org/validation/key
|
76
|
+
servers:
|
77
|
+
node-1.lxc:
|
78
|
+
products:
|
79
|
+
chef:
|
80
|
+
```
|
81
|
+
|
82
|
+
The dev-lxc.yml config file is very customizable. You can add or remove mounts, products or servers,
|
83
|
+
change ip addresses, server names, the base_container and more.
|
84
|
+
|
85
|
+
As you can see there are four server types represented by five servers.
|
86
|
+
|
87
|
+
1. chef-server - chef.lxc
|
88
|
+
2. analytics - analytics.lxc
|
89
|
+
3. supermarket - supermarket.lxc
|
90
|
+
4. nodes - node-1.lxc
|
91
|
+
|
92
|
+
#### Global Settings
|
93
|
+
|
94
|
+
The global settings used by each of the server types are the `base_container`, a list of `mounts` and
|
95
|
+
a list of `ssh-keys`. These settings are described in the config comments.
|
96
|
+
|
97
|
+
Be sure to set `base_container` in the `dev-lxc.yml` to an existing container's name.
|
98
|
+
This container will be cloned to create each container in the cluster.
|
99
|
+
If you don't already have a container to use as a `base_container` then you can follow the instructions in the
|
100
|
+
[Create a dev-lxc Base Container section](https://github.com/jeremiahsnapp/dev-lxc#create-a-dev-lxc-base-container) to create one.
|
101
|
+
|
102
|
+
#### Server Specific Settings
|
103
|
+
|
104
|
+
It is possible to define different values for `base_container`, `mounts` or `ssh-keys` for a particular server type or even for a particular server as you can see in the following snippet.
|
105
|
+
|
106
|
+
```
|
107
|
+
nodes:
|
108
|
+
base_container: b-ubuntu-1404
|
109
|
+
servers:
|
110
|
+
node-1.lxc:
|
111
|
+
base_container: b-centos-6
|
112
|
+
node-2.lxc:
|
113
|
+
```
|
114
|
+
|
115
|
+
IP addresses from the range 10.0.3.150 - 254 can be assigned to the servers. If an IP address
|
116
|
+
is not specified then a dynamic IP address is assigned when the server starts.
|
117
|
+
|
118
|
+
#### mixlib-install Library Automatically Manages a Cache of Product Packages
|
119
|
+
|
120
|
+
dev-lxc uses the [mixlib-install](https://github.com/chef/mixlib-install) library to download Chef products
|
121
|
+
to a cache in `/var/dev-lxc` in the host VM. This cache is automatically mounted into each server when it starts.
|
122
|
+
|
123
|
+
A list of Chef products to be installed can be defined for each server
|
124
|
+
using [product names that mixlib-install understands](https://github.com/chef/mixlib-install/blob/master/PRODUCT_MATRIX.md).
|
125
|
+
|
126
|
+
The channel and version of the product can be defined also.
|
127
|
+
|
128
|
+
Channel can be `current`, `stable` or `unstable` with `stable` as the default.
|
129
|
+
Version can be `latest` or a version number with `latest` as the default.
|
130
|
+
|
131
|
+
For example, the following specifies the `current` channel and version `0.16.1` of the `chefdk` product.
|
132
|
+
|
133
|
+
```
|
134
|
+
nodes:
|
135
|
+
servers:
|
136
|
+
node-1.lxc:
|
137
|
+
products:
|
138
|
+
chefdk:
|
139
|
+
channel: current
|
140
|
+
version: 0.16.1
|
141
|
+
```
|
142
|
+
|
143
|
+
The `package_source` setting can be used to specify a package file on disk.
|
144
|
+
|
145
|
+
```
|
146
|
+
nodes:
|
147
|
+
servers:
|
148
|
+
node-1.lxc:
|
149
|
+
products:
|
150
|
+
chefdk:
|
151
|
+
package_source: /root/chefdk_0.16.1-1_amd64.deb
|
152
|
+
```
|
153
|
+
|
154
|
+
#### Chef Server Orgs/Users
|
155
|
+
|
156
|
+
When defining a Chef Server you can include organizations and users that will be automatically created and associated accordingly.
|
157
|
+
|
158
|
+
#### Automatic Integration Between Servers
|
159
|
+
|
160
|
+
dev-lxc knows how to automatically configure Chef Server standalone, Chef Server tier topology,
|
161
|
+
Chef Server HA 2.0 as well as Chef Automate, Chef Client, Analytics, Compliance and Supermarket.
|
162
|
+
|
163
|
+
If a Chef Automate, Analytics server or Supermarket server is defined in the same config file as
|
164
|
+
a Chef Server then each server will automatically be integrated with that Chef Server.
|
165
|
+
|
166
|
+
If a node server with Chef Client or Chef DK installed is defined in the same config file as
|
167
|
+
a Chef Server then the Chef Client will automatically be configured to use that Chef Server.
|
168
|
+
|
169
|
+
Alternatively, values for `chef_server_url`, `validation_client_name` and `validation_key` can
|
170
|
+
be set in the config file either for all nodes or for each individual node.
|
171
|
+
|
172
|
+
```
|
173
|
+
nodes:
|
174
|
+
chef_server_url: https://chef.lxc/organizations/demo
|
175
|
+
validation_client_name: demo-validator
|
176
|
+
# comment out or remove the validation_key path to use chef-server keys generated by dev-lxc
|
177
|
+
validation_key: # /path/to/org/validation/key
|
178
|
+
servers:
|
179
|
+
node-1.lxc:
|
180
|
+
products:
|
181
|
+
chef:
|
182
|
+
```
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# dev-lxc 2.0 is Available
|
2
|
+
|
3
|
+
Here are some of the new features which provide a significantly simplified and streamlined usage.
|
4
|
+
|
5
|
+
* mixlib-install library is used to automatically manage a cache of product packages
|
6
|
+
* Genuine container snapshot management (make as many snapshots as you want)
|
7
|
+
* New "nodes" server type which auto configures nodes for a Chef Server in the same cluster
|
8
|
+
* Removed all xc-... bash functions because the new "nodes" server type replaces this functionality
|
9
|
+
* Able to build Chef Server HA 2.0 cluster using chef-backend
|
10
|
+
* Updated and simplified READMEs
|
@@ -0,0 +1,30 @@
|
|
1
|
+
### Maintain Uniqueness Across Multiple Clusters
|
2
|
+
|
3
|
+
The default cluster configs are already designed to be unique from each other but as you build
|
4
|
+
more clusters you have to maintain uniqueness across the YAML config files for the following items.
|
5
|
+
|
6
|
+
* Server names, `api_fqdn` and `analytics_fqdn`
|
7
|
+
|
8
|
+
Server names should really be unique across all clusters.
|
9
|
+
|
10
|
+
Even when cluster A is shutdown, if cluster B uses the same server names when it is created it
|
11
|
+
will use the already existing servers from cluster A.
|
12
|
+
|
13
|
+
`api_fqdn` and `analytics_fqdn` uniqueness only matters when clusters with the same `api_fqdn`
|
14
|
+
and `analytics_fqdn` are running.
|
15
|
+
|
16
|
+
If cluster B is started with the same `api_fqdn` or `analytics_fqdn` as an already running cluster A,
|
17
|
+
then cluster B will overwrite cluster A's DNS resolution of `api_fqdn` or `analytics_fqdn`.
|
18
|
+
|
19
|
+
* IP Addresses
|
20
|
+
|
21
|
+
IP addresses uniqueness only matters when clusters with the same IP's are running.
|
22
|
+
|
23
|
+
If cluster B is started with the same IP's as an already running cluster A, then cluster B
|
24
|
+
will overwrite cluster A's DHCP reservation of the IP's but dnsmasq will still refuse to
|
25
|
+
assign the IP's to cluster B because they already in use by cluster A. dnsmasq then assigns
|
26
|
+
random IP's from the DHCP pool to cluster B leaving it in an unexpected state.
|
27
|
+
|
28
|
+
The `dev-lxc-platform` creates the IP range 10.0.3.150 - 254 for DHCP reserved IP's.
|
29
|
+
|
30
|
+
Use unique IP's from that range when configuring clusters.
|
@@ -0,0 +1,75 @@
|
|
1
|
+
|
2
|
+
#### Download and Install Prerequisites
|
3
|
+
|
4
|
+
Download and install [VirtualBox](https://www.virtualbox.org/wiki/Downloads).
|
5
|
+
|
6
|
+
Download and install [Vagrant](https://www.vagrantup.com/downloads.html).
|
7
|
+
|
8
|
+
Install the vagrant-persistent-storage plugin.
|
9
|
+
|
10
|
+
```
|
11
|
+
vagrant plugin install vagrant-persistent-storage
|
12
|
+
```
|
13
|
+
|
14
|
+
Download and install [ChefDK](http://downloads.chef.io/chef-dk/).
|
15
|
+
|
16
|
+
#### Download dev-lxc-platform
|
17
|
+
|
18
|
+
```
|
19
|
+
git clone https://github.com/jeremiahsnapp/dev-lxc-platform.git
|
20
|
+
```
|
21
|
+
|
22
|
+
#### Configure .kitchen.yml
|
23
|
+
|
24
|
+
The cpus and memory .kitchen.yml values are set high to give enough resources to comfortably run multiple containers.
|
25
|
+
|
26
|
+
Configure .kitchen.yml settings such as cpus, memory, synced_folders as desired.
|
27
|
+
|
28
|
+
#### Build the dev-lxc-platform VM
|
29
|
+
|
30
|
+
This should take less than 15 minutes.
|
31
|
+
|
32
|
+
While the VM is being created you are free to open a separate terminal and follow the remaining setup instructions.
|
33
|
+
|
34
|
+
```
|
35
|
+
cd dev-lxc-platform
|
36
|
+
kitchen converge
|
37
|
+
```
|
38
|
+
|
39
|
+
#### Enable Vagrant Control for VM
|
40
|
+
|
41
|
+
Typically we want to be able to shutdown and startup the dev-lxc-platform VM rather than use the usual kitchen model of converge and destroy so we need to enable Vagrant control over the VM for easier management.
|
42
|
+
|
43
|
+
Install [direnv](http://direnv.net/) to use the `.envrc` file included in the
|
44
|
+
dev-lxc-platform repo to automatically set `VAGRANT_CWD` upon entering the top level directory
|
45
|
+
of the dev-lxc-platform repo.
|
46
|
+
|
47
|
+
Vagrant commands run from this directory such as `vagrant up`, `vagrant ssh` and `vagrant halt` will manage the dev-lxc-platform VM.
|
48
|
+
|
49
|
+
```
|
50
|
+
brew install direnv
|
51
|
+
```
|
52
|
+
|
53
|
+
Be sure to follow the [direnv install instructions](http://direnv.net/) to add the appropriate line to your user's shell rc file.
|
54
|
+
|
55
|
+
#### Setup Networking
|
56
|
+
|
57
|
+
Your workstation needs to know how to resolve the .lxc domain that dev-lxc containers use.
|
58
|
+
|
59
|
+
For OS X you can run the following command.
|
60
|
+
|
61
|
+
```
|
62
|
+
sudo mkdir -p /etc/resolver
|
63
|
+
echo nameserver 10.0.3.1 | sudo tee /etc/resolver/lxc
|
64
|
+
```
|
65
|
+
|
66
|
+
Adding a route entry to the workstation enables direct communication between
|
67
|
+
the workstation and any dev-lxc container.
|
68
|
+
|
69
|
+
For OS X run the following command.
|
70
|
+
|
71
|
+
The route entry won't survive a workstation reboot. You will have to recreate it as needed.
|
72
|
+
|
73
|
+
```
|
74
|
+
sudo route -n add 10.0.3.0/24 33.33.34.13
|
75
|
+
```
|
data/docs/usage.md
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
## Usage
|
2
|
+
|
3
|
+
### Show Calculated Configuration
|
4
|
+
|
5
|
+
Mostly for debugging purposes you have the ability to print the calculated cluster configuration.
|
6
|
+
|
7
|
+
```
|
8
|
+
dev-lxc show-config
|
9
|
+
```
|
10
|
+
|
11
|
+
### Cluster status
|
12
|
+
|
13
|
+
Run the following command to see the status of the cluster.
|
14
|
+
|
15
|
+
```
|
16
|
+
dev-lxc status
|
17
|
+
```
|
18
|
+
|
19
|
+
This is an example of the output.
|
20
|
+
|
21
|
+
```
|
22
|
+
chef.lxc NOT_CREATED
|
23
|
+
|
24
|
+
analytics.lxc NOT_CREATED
|
25
|
+
|
26
|
+
supermarket.lxc NOT_CREATED
|
27
|
+
|
28
|
+
node-1.lxc NOT_CREATED
|
29
|
+
```
|
30
|
+
|
31
|
+
### Specifying a Subset of Servers
|
32
|
+
|
33
|
+
Many dev-lxc subcommands can act on a subset of the cluster's servers by specifying a regular expression that matches the desired server names.
|
34
|
+
|
35
|
+
For example, the following command will show the status of the Chef Server.
|
36
|
+
|
37
|
+
```
|
38
|
+
dev-lxc status chef
|
39
|
+
```
|
40
|
+
|
41
|
+
### cluster-view, tks, tls commands
|
42
|
+
|
43
|
+
The dev-lxc-platform comes with some commands that create and manage helpful
|
44
|
+
tmux/byobu sessions to more easily see the state of a cluster.
|
45
|
+
|
46
|
+
Running the `cluster-view` command in the same directory as a `dev-lxc.yml` file
|
47
|
+
creates a tmux/byobu session with the same name as the cluster's directory.
|
48
|
+
|
49
|
+
`cluster-view` can also be run with the parent directory of a `dev-lxc.yml` file
|
50
|
+
as the first argument and `cluster-view` will change to that directory before
|
51
|
+
creating the tmux/byobu session.
|
52
|
+
|
53
|
+
The session's first window is named "cluster".
|
54
|
+
|
55
|
+
The left side is for running dev-lxc commands.
|
56
|
+
|
57
|
+
The right side updates every 0.5 seconds with the cluster's status provided by `dev-lxc status`.
|
58
|
+
|
59
|
+
The session's second window is named "shell". It opens in the same directory as the
|
60
|
+
cluster's `dev-lxc.yml` file.
|
61
|
+
|
62
|
+
The `tls` and `tks` commands are really aliases.
|
63
|
+
|
64
|
+
`tls` is an alias for `tmux list-sessions` and is used to see what tmux/byobu sessions
|
65
|
+
are running.
|
66
|
+
|
67
|
+
`tks` is an alias for `tmux kill-session -t` and is used to kill tmux/byobu sessions.
|
68
|
+
When specifying the session to be killed you only need as many characters of the session
|
69
|
+
name that are required to make the name unique among the list of running sessions.
|
70
|
+
|
71
|
+
I recommend switching to a different running tmux/byobu session before killing the current
|
72
|
+
tmux/byobu session. Otherwise you will need to reattach to the remaining tmux/byobu session.
|
73
|
+
Use the keyboard shortcuts Alt-Up/Down to easily switch between tmux/byobu sessions.
|
74
|
+
|
75
|
+
### Start cluster
|
76
|
+
|
77
|
+
Starting the cluster the first time takes awhile since it has a lot to download and build.
|
78
|
+
|
79
|
+
```
|
80
|
+
dev-lxc up
|
81
|
+
```
|
82
|
+
|
83
|
+
A test org, users, knife.rb and keys are automatically created in
|
84
|
+
the bootstrap backend server in `/root/chef-repo/.chef` for testing purposes.
|
85
|
+
|
86
|
+
The `knife-opc` plugin is installed in the embedded ruby environment of the
|
87
|
+
Private Chef and Enterprise Chef server to facilitate the creation of the test
|
88
|
+
org and user.
|
89
|
+
|
90
|
+
Note: You also have the option of running the `prepare-product-cache` subcommand which downloads required product packages to the cache.
|
91
|
+
This can be helpful when you don't want to start building the cluster yet but you want the package cache ready when you build the cluster later.
|
92
|
+
|
93
|
+
```
|
94
|
+
dev-lxc prepare-product-cache
|
95
|
+
```
|
96
|
+
|
97
|
+
### Print Chef Automate Credentials
|
98
|
+
|
99
|
+
If the cluster has a Chef Automate server you can use the `print-automate-credentials` subcommand to see what the login credentials.
|
100
|
+
|
101
|
+
```
|
102
|
+
dev-lxc print-automate-credentials
|
103
|
+
```
|
104
|
+
|
105
|
+
### Create chef-repo
|
106
|
+
|
107
|
+
Create a local chef-repo with appropriate knife.rb and pem files.
|
108
|
+
|
109
|
+
Use the `-p` option to also get pivotal.pem and pivotal.rb files.
|
110
|
+
|
111
|
+
Use the `-f` option to overwrite existing knife.rb and pivotal.rb files.
|
112
|
+
|
113
|
+
```
|
114
|
+
dev-lxc chef-repo
|
115
|
+
```
|
116
|
+
|
117
|
+
Now you can easily use knife to access the cluster.
|
118
|
+
|
119
|
+
```
|
120
|
+
cd chef-repo
|
121
|
+
knife client list
|
122
|
+
```
|
123
|
+
|
124
|
+
### Stop and start the cluster
|
125
|
+
|
126
|
+
```
|
127
|
+
dev-lxc halt
|
128
|
+
dev-lxc up
|
129
|
+
```
|
130
|
+
|
131
|
+
### Run arbitrary commands in each server
|
132
|
+
|
133
|
+
```
|
134
|
+
dev-lxc run-command chef 'uptime'
|
135
|
+
```
|
136
|
+
|
137
|
+
### Attach the terminal to a server
|
138
|
+
|
139
|
+
Attach the terminal to a server in the cluster that matches the REGEX pattern given.
|
140
|
+
|
141
|
+
```
|
142
|
+
dev-lxc attach chef
|
143
|
+
```
|
144
|
+
|
145
|
+
### Create a snapshot of the servers
|
146
|
+
|
147
|
+
Save the changes in the servers to snapshots with a comment.
|
148
|
+
|
149
|
+
```
|
150
|
+
dev-lxc halt
|
151
|
+
dev-lxc snapshot -c 'this is a snapshot comment'
|
152
|
+
```
|
153
|
+
|
154
|
+
### List snapshots
|
155
|
+
|
156
|
+
```
|
157
|
+
dev-lxc snapshot -l
|
158
|
+
```
|
159
|
+
|
160
|
+
### Restore snapshots
|
161
|
+
|
162
|
+
Restore snapshots by name.
|
163
|
+
|
164
|
+
Leave out the snapshot name or specify `LAST` to restore the most recent snapshot.
|
165
|
+
|
166
|
+
```
|
167
|
+
dev-lxc snapshot -r
|
168
|
+
dev-lxc up
|
169
|
+
```
|
170
|
+
|
171
|
+
### Destroy snapshots
|
172
|
+
|
173
|
+
Destroy snapshots by name or destroy all snapshots by specifying `ALL`.
|
174
|
+
|
175
|
+
Leave out the snapshot name or specify `LAST` to destroy the most recent snapshots.
|
176
|
+
|
177
|
+
```
|
178
|
+
dev-lxc snapshot -d
|
179
|
+
```
|
180
|
+
|
181
|
+
### Destroy cluster
|
182
|
+
|
183
|
+
Use the following command to destroy the cluster's servers.
|
184
|
+
|
185
|
+
```
|
186
|
+
dev-lxc destroy
|
187
|
+
```
|
data/lib/dev-lxc/cli.rb
CHANGED
@@ -22,6 +22,12 @@ module DevLXC::CLI
|
|
22
22
|
end
|
23
23
|
}
|
24
24
|
|
25
|
+
desc "show-config", "Show calculated configuration"
|
26
|
+
option :config, :desc => "Specify a cluster's YAML config file. `./dev-lxc.yml` will be used by default"
|
27
|
+
def show_config
|
28
|
+
get_cluster(options[:config]).show_config
|
29
|
+
end
|
30
|
+
|
25
31
|
desc "create-base-container [BASE_CONTAINER_NAME]", "Create a base container"
|
26
32
|
option :options, :aliases => "-o", :desc => "Specify additional options for the lxc create"
|
27
33
|
def create_base_container(base_container_name=nil)
|
@@ -46,6 +52,8 @@ module DevLXC::CLI
|
|
46
52
|
option :analytics, :type => :boolean, :desc => "Analytics Server"
|
47
53
|
option :compliance, :type => :boolean, :desc => "Compliance Server"
|
48
54
|
option :supermarket, :type => :boolean, :desc => "Supermarket Server"
|
55
|
+
option :automate, :type => :boolean, :desc => "Automate Server"
|
56
|
+
option :build_nodes, :type => :boolean, :desc => "Build Nodes"
|
49
57
|
option :adhoc, :type => :boolean, :desc => "Adhoc Servers"
|
50
58
|
option :append, :aliases => "-a", :type => :boolean, :desc => "Do not generate the global config header"
|
51
59
|
option :filename, :aliases => "-f", :desc => "Write generated content to FILE rather than standard output."
|
@@ -67,6 +75,15 @@ base_container: b-ubuntu-1404
|
|
67
75
|
chef-server:
|
68
76
|
topology: tier
|
69
77
|
api_fqdn: chef.lxc
|
78
|
+
users: # a user's password will be the same as its username
|
79
|
+
- mary-admin
|
80
|
+
- joe-user
|
81
|
+
orgs:
|
82
|
+
demo:
|
83
|
+
admins:
|
84
|
+
- mary-admin
|
85
|
+
non-admins:
|
86
|
+
- joe-user
|
70
87
|
servers:
|
71
88
|
chef-be.lxc:
|
72
89
|
ipaddress: 10.0.3.201
|
@@ -87,6 +104,15 @@ chef-server:
|
|
87
104
|
)
|
88
105
|
chef_config = %Q(
|
89
106
|
chef-server:
|
107
|
+
users: # a user's password will be the same as its username
|
108
|
+
- mary-admin
|
109
|
+
- joe-user
|
110
|
+
orgs:
|
111
|
+
demo:
|
112
|
+
admins:
|
113
|
+
- mary-admin
|
114
|
+
non-admins:
|
115
|
+
- joe-user
|
90
116
|
servers:
|
91
117
|
chef.lxc:
|
92
118
|
ipaddress: 10.0.3.203
|
@@ -95,6 +121,23 @@ chef-server:
|
|
95
121
|
manage:
|
96
122
|
push-jobs-server:
|
97
123
|
reporting:
|
124
|
+
)
|
125
|
+
automate_config = %Q(
|
126
|
+
automate:
|
127
|
+
servers:
|
128
|
+
automate.lxc:
|
129
|
+
ipaddress: 10.0.3.200
|
130
|
+
products:
|
131
|
+
delivery:
|
132
|
+
chefdk: # downloaded only for build nodes
|
133
|
+
license_path: /CHANGE/ME
|
134
|
+
chef_org: delivery
|
135
|
+
enterprise_name: demo-ent
|
136
|
+
)
|
137
|
+
build_nodes_config = %Q(
|
138
|
+
build-nodes:
|
139
|
+
servers:
|
140
|
+
build-node-1.lxc:
|
98
141
|
)
|
99
142
|
analytics_config = %Q(
|
100
143
|
analytics:
|
@@ -129,6 +172,15 @@ adhoc:
|
|
129
172
|
chef_backend_config = %Q(
|
130
173
|
chef-backend:
|
131
174
|
api_fqdn: chef.lxc
|
175
|
+
users: # a user's password will be the same as its username
|
176
|
+
- mary-admin
|
177
|
+
- joe-user
|
178
|
+
orgs:
|
179
|
+
demo:
|
180
|
+
admins:
|
181
|
+
- mary-admin
|
182
|
+
non-admins:
|
183
|
+
- joe-user
|
132
184
|
servers:
|
133
185
|
chef-backend1.lxc:
|
134
186
|
ipaddress: 10.0.3.208
|
@@ -156,6 +208,10 @@ chef-backend:
|
|
156
208
|
)
|
157
209
|
nodes_config = %Q(
|
158
210
|
nodes:
|
211
|
+
chef_server_url: https://chef.lxc/organizations/demo
|
212
|
+
validation_client_name: demo-validator
|
213
|
+
# comment out or remove the validation_key path to use chef-server keys generated by dev-lxc
|
214
|
+
validation_key: # /path/to/org/validation/key
|
159
215
|
servers:
|
160
216
|
node-1.lxc:
|
161
217
|
products:
|
@@ -168,6 +224,8 @@ nodes:
|
|
168
224
|
config += analytics_config if options[:analytics]
|
169
225
|
config += compliance_config if options[:compliance]
|
170
226
|
config += supermarket_config if options[:supermarket]
|
227
|
+
config += automate_config if options[:automate]
|
228
|
+
config += build_nodes_config if options[:build_nodes]
|
171
229
|
config += adhoc_config if options[:adhoc]
|
172
230
|
config += chef_backend_config if options[:chef_backend]
|
173
231
|
config += nodes_config if options[:nodes]
|
@@ -241,6 +299,12 @@ nodes:
|
|
241
299
|
get_cluster(options[:config]).chef_repo(options[:force], options[:pivotal])
|
242
300
|
end
|
243
301
|
|
302
|
+
desc "print-automate-credentials", "Print Automate credentials"
|
303
|
+
option :config, :desc => "Specify a cluster's YAML config file. `./dev-lxc.yml` will be used by default"
|
304
|
+
def print_automate_credentials
|
305
|
+
get_cluster(options[:config]).print_automate_credentials
|
306
|
+
end
|
307
|
+
|
244
308
|
desc "run-command [SERVER_NAME_REGEX] [COMMAND]", "Runs a command in each server"
|
245
309
|
option :config, :desc => "Specify a cluster's YAML config file. `./dev-lxc.yml` will be used by default"
|
246
310
|
def run_command(server_name_regex=nil, command)
|
@@ -249,6 +313,16 @@ nodes:
|
|
249
313
|
print_elapsed_time(Time.now - start_time)
|
250
314
|
end
|
251
315
|
|
316
|
+
desc "prepare-product-cache [SERVER_NAME_REGEX]", "Download required product packages to cache"
|
317
|
+
option :config, :desc => "Specify a cluster's YAML config file. `./dev-lxc.yml` will be used by default"
|
318
|
+
def prepare_product_cache(server_name_regex=nil)
|
319
|
+
start_time = Time.now
|
320
|
+
cluster = get_cluster(options[:config])
|
321
|
+
servers = cluster.get_sorted_servers(server_name_regex)
|
322
|
+
cluster.prep_product_cache(servers, true)
|
323
|
+
print_elapsed_time(Time.now - start_time)
|
324
|
+
end
|
325
|
+
|
252
326
|
desc "up [SERVER_NAME_REGEX]", "Start servers - This is the default if no subcommand is given"
|
253
327
|
option :config, :desc => "Specify a cluster's YAML config file. `./dev-lxc.yml` will be used by default"
|
254
328
|
def up(server_name_regex=nil)
|