knife-topo 0.0.5 → 0.0.6
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 +57 -37
- data/knife-topo.gemspec +1 -2
- data/lib/chef/knife/topo/version.rb +1 -1
- data/lib/chef/knife/topo_create.rb +6 -6
- data/lib/chef/knife/topo_update.rb +6 -1
- metadata +2 -21
- data/test-repo/.chef/dummy.pem +0 -27
- data/test-repo/.chef/knife.rb +0 -13
- data/test-repo/Berksfile +0 -4
- data/test-repo/Instructions.md +0 -131
- data/test-repo/Vagrantfile +0 -62
- data/test-repo/Vagrantfile_bridged +0 -59
- data/test-repo/cookbooks/README.md +0 -54
- data/test-repo/cookbooks/testapp/CHANGELOG.md +0 -10
- data/test-repo/cookbooks/testapp/README.md +0 -26
- data/test-repo/cookbooks/testapp/files/default/index.html +0 -13
- data/test-repo/cookbooks/testapp/files/default/package.json +0 -14
- data/test-repo/cookbooks/testapp/files/default/server.js +0 -42
- data/test-repo/cookbooks/testapp/metadata.rb +0 -9
- data/test-repo/cookbooks/testapp/recipes/appserver.rb +0 -8
- data/test-repo/cookbooks/testapp/recipes/db.rb +0 -9
- data/test-repo/cookbooks/testapp/recipes/default.rb +0 -11
- data/test-repo/cookbooks/testapp/recipes/deploy.rb +0 -50
- data/test-repo/cookbooks/testapp/templates/default/nodejs.upstart.conf.erb +0 -9
- data/test-repo/topology.json +0 -124
data/README.md
CHANGED
@@ -1,48 +1,65 @@
|
|
1
1
|
knife topo
|
2
2
|
==========
|
3
3
|
|
4
|
-
|
5
|
-
consisting of multiple nodes
|
4
|
+
The knife-topo plugin allows you to create and update topologies
|
5
|
+
consisting of multiple nodes using single knife commands, based on
|
6
|
+
a JSON definition of the topology. The plugin:
|
7
|
+
* creates a data bag for the topology
|
8
|
+
* generates attribute file(s) in a topology-specific cookbook
|
9
|
+
* sets and updates the run list, chef environment and properties of nodes
|
10
|
+
* uploads the topology-specific cookbook and bootstraps nodes
|
11
|
+
|
12
|
+
You may find this plugin useful if you are
|
6
13
|
regularly updating a system consisting of multiple nodes, and would
|
7
|
-
like to manage its dynamic configuration (
|
14
|
+
like to manage its dynamic configuration (e.g. changing software versions)
|
8
15
|
through a single (json) configuration file. It may also be useful
|
9
16
|
if you are regularly bringing up multi-node systems with similar
|
10
17
|
topologies but differences in their configuration details.
|
11
18
|
|
19
|
+
|
12
20
|
# Installation #
|
13
21
|
|
14
|
-
|
22
|
+
[Download the latest knife-topo release](http://github.com/christinedraper/knife-topo/releases/latest),
|
23
|
+
unzip and copy `lib/chef/knife` into your plugin directory, e.g.:
|
15
24
|
|
16
|
-
$
|
17
|
-
$
|
25
|
+
$ unzip knife-topo-0.0.6.zip -d ~
|
26
|
+
$ cd ~/knife-topo-0.0.6
|
27
|
+
$ mkdir -p ~/.chef/plugins/knife
|
28
|
+
$ cp lib/chef/knife/* ~/.chef/plugins/knife
|
18
29
|
|
19
30
|
or install knife-topo as a gem
|
20
31
|
|
21
|
-
$
|
32
|
+
$ gem install knife-topo
|
33
|
+
|
34
|
+
You may need to use `sudo gem install knife-topo`, depending on your setup.
|
35
|
+
|
36
|
+
This plugin has been tested with Chef Version 11.12 on Ubuntu 14.04 LTS.
|
22
37
|
|
23
|
-
|
38
|
+
Note: I've encountered a case (on a Mac) where knife was not configured to use
|
39
|
+
gems on the gem path. If the gem install succeeds but `knife topo`
|
40
|
+
is not a recognized knife command, try the first approach (copy
|
41
|
+
the ruby plugin scripts into ~/.chef/plugins/knife).
|
24
42
|
|
25
43
|
# Usage #
|
26
44
|
|
27
|
-
Define one or more topologies in a [topology file](#topology-file).
|
45
|
+
Define one or more topologies in a [topology file](#topology-file). Import
|
46
|
+
that file into your Chef workspace using [knife topo import](#import),
|
47
|
+
then create and bootstrap the nodes using a single command [knife topo create](#create).
|
48
|
+
Update the topology file as the configuration changes (e.g., when you
|
49
|
+
need to update software versions), import those changes and run one command
|
50
|
+
[knife topo update](#update) to update all of the nodes.
|
28
51
|
|
29
|
-
Import the topology file into your local chef repo using
|
30
|
-
[knife topo import](#import). Create and optionally
|
31
|
-
bootstrap a topology on the Chef server using
|
32
|
-
[knife topo create](#create), and update it
|
33
|
-
using [knife topo update](#update).
|
34
52
|
|
35
53
|
# Getting Started #
|
36
54
|
|
37
|
-
Try out this plugin using a [test
|
38
|
-
|
39
|
-
[Instructions](Instructions.md) for a
|
55
|
+
Try out this plugin using a [test-repo](test-repo) provided in the knife-topo github repository.
|
56
|
+
[Download the latest knife-topo release](http://github.com/christinedraper/knife-topo/releases/latest)
|
57
|
+
and unzip it, then follow the [Instructions](test-repo/Instructions.md) for a
|
40
58
|
demo script, explanation, and troubleshooting.
|
41
59
|
|
42
|
-
The instructions assume you have
|
43
|
-
[chefDK](http://www.getchef.com/downloads/chef-dk/)
|
60
|
+
The instructions assume you have [chefDK](http://www.getchef.com/downloads/chef-dk/)
|
44
61
|
or equivalent installed and working with Vagrant and VirtualBox, but
|
45
|
-
none of these are requirements
|
62
|
+
none of these are requirements to use the knife-topo plugin.
|
46
63
|
|
47
64
|
# Topology File <a name="topology-file"></a>#
|
48
65
|
|
@@ -86,8 +103,8 @@ Each topology contains a list of `nodes`.
|
|
86
103
|
{
|
87
104
|
"name": "test1",
|
88
105
|
...
|
89
|
-
"nodes":
|
90
|
-
|
106
|
+
"nodes": [
|
107
|
+
{
|
91
108
|
"name": "buildserver01",
|
92
109
|
"ssh_host": "192.168.1.201",
|
93
110
|
"ssh_port": "2224",
|
@@ -101,11 +118,8 @@ Each topology contains a list of `nodes`.
|
|
101
118
|
"tags": ["build"]
|
102
119
|
},
|
103
120
|
...
|
104
|
-
|
105
|
-
|
106
|
-
},
|
107
|
-
...
|
108
|
-
]}
|
121
|
+
]
|
122
|
+
}
|
109
123
|
```
|
110
124
|
Within `nodes`, the `name` field is the node name that will be used in Chef.
|
111
125
|
The fields `chef_environment`, `run_list`, `tags` and the attributes
|
@@ -277,11 +291,11 @@ topology test1.
|
|
277
291
|
knife topo create TOPOLOGY
|
278
292
|
|
279
293
|
Creates the specified topology in the chef server as an item in the
|
280
|
-
|
281
|
-
with the
|
282
|
-
topology cookbooks.
|
283
|
-
|
284
|
-
specified
|
294
|
+
topology data bag. Creates the chef environment associated
|
295
|
+
with the topology, if it does not already exist. Uploads any
|
296
|
+
topology cookbooks. Updates existing nodes based on the topology
|
297
|
+
information. New nodes will be created if the bootstrap option is
|
298
|
+
specified.
|
285
299
|
|
286
300
|
### Options:
|
287
301
|
|
@@ -291,7 +305,7 @@ Option | Description
|
|
291
305
|
------------ | -----------
|
292
306
|
--bootstrap | Bootstrap the topology (see [topo bootstrap](#bootstrap))
|
293
307
|
See [knife bootstrap](http://docs.opscode.com/knife_bootstrap.html) | Options supported by `knife bootstrap` are passed through to the bootstrap command
|
294
|
-
--
|
308
|
+
--disable-upload | Do not upload topology cookbooks
|
295
309
|
|
296
310
|
### Examples:
|
297
311
|
The following will create the 'test1' topology, and bootstrap it.
|
@@ -301,7 +315,7 @@ The following will create the 'test1' topology, and bootstrap it.
|
|
301
315
|
The following will create the 'test1' topology but will not bootstrap it
|
302
316
|
or upload topology cookbooks.
|
303
317
|
|
304
|
-
$ knife topo create test1 --
|
318
|
+
$ knife topo create test1 --disable-upload
|
305
319
|
|
306
320
|
## knife topo export <a name="export"></a>
|
307
321
|
|
@@ -330,8 +344,8 @@ The following will create an outline for a new topology called 'christine_test'
|
|
330
344
|
|
331
345
|
knife topo import [ TOPOLOGY_FILE [ TOPOLOGY ... ]]
|
332
346
|
|
333
|
-
Imports the
|
334
|
-
[topology file](#
|
347
|
+
Imports the topologies from a
|
348
|
+
[topology file](#topology-file) into the local repo. If no topology
|
335
349
|
file is specified, attempts to read from a file called 'topology.json'
|
336
350
|
in the current directory. Generates the topology cookbook attribute
|
337
351
|
files and attributes described in the 'cookbook_attributes' property.
|
@@ -354,9 +368,15 @@ Updates the specified topology. Creates or updates nodes
|
|
354
368
|
identified in the topology, using information specified in the
|
355
369
|
topology for the specific node.
|
356
370
|
|
357
|
-
If no topology is specified, all existing topologies
|
371
|
+
If no topology is specified, all existing topologies
|
358
372
|
will be updated.
|
359
373
|
|
374
|
+
Option | Description
|
375
|
+
------------ | -----------
|
376
|
+
--bootstrap | Bootstrap the topology (see [topo bootstrap](#bootstrap))
|
377
|
+
See [knife bootstrap](http://docs.opscode.com/knife_bootstrap.html) | Options supported by `knife bootstrap` are passed through to the bootstrap command
|
378
|
+
--disable-upload | Do not upload topology cookbooks
|
379
|
+
|
360
380
|
### Examples:
|
361
381
|
The following will update the 'test1' topology.
|
362
382
|
|
data/knife-topo.gemspec
CHANGED
@@ -13,8 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "https://github.com/christinedraper/knife-topo"
|
14
14
|
spec.license = "Apache License (2.0)"
|
15
15
|
|
16
|
-
spec.files = Dir.glob("{lib
|
17
|
-
Dir.glob("test-repo/.chef/*") +
|
16
|
+
spec.files = Dir.glob("{lib}/**/*") +
|
18
17
|
['LICENSE', 'README.md', __FILE__]
|
19
18
|
spec.require_paths = ["lib"]
|
20
19
|
|
@@ -40,12 +40,12 @@ class Chef
|
|
40
40
|
option :bootstrap,
|
41
41
|
:long => "--bootstrap",
|
42
42
|
:description => "Whether to bootstrap newly created nodes",
|
43
|
-
:boolean =>
|
43
|
+
:boolean => true
|
44
44
|
|
45
|
-
option :
|
46
|
-
:long => "--
|
47
|
-
:description => "Do not upload cookbooks",
|
48
|
-
:boolean =>
|
45
|
+
option :disable_upload,
|
46
|
+
:long => "--disable-upload",
|
47
|
+
:description => "Do not upload topo cookbooks",
|
48
|
+
:boolean => true
|
49
49
|
|
50
50
|
# Make called command options available
|
51
51
|
opts = self.options
|
@@ -90,7 +90,7 @@ class Chef
|
|
90
90
|
|
91
91
|
# make sure env and cookbooks are in place
|
92
92
|
check_chef_env(topo['chef_environment']) if topo['chef_environment']
|
93
|
-
upload_cookbooks(@topo_upload_args) if (!config[:
|
93
|
+
upload_cookbooks(@topo_upload_args) if (!config[:disable_upload])
|
94
94
|
|
95
95
|
# update any existing nodes
|
96
96
|
topo_hash = topo.raw_data
|
@@ -34,6 +34,11 @@ class Chef
|
|
34
34
|
:long => "--data-bag DATA_BAG",
|
35
35
|
:description => "The data bag the topologies are stored in"
|
36
36
|
|
37
|
+
option :disable_upload,
|
38
|
+
:long => "--disable-upload",
|
39
|
+
:description => "Do not upload topo cookbooks",
|
40
|
+
:boolean => true
|
41
|
+
|
37
42
|
# Make called command options available
|
38
43
|
self.options = Chef::Knife::TopoCookbookUpload.options.merge(self.options)
|
39
44
|
|
@@ -99,7 +104,7 @@ class Chef
|
|
99
104
|
def update_topo(topo)
|
100
105
|
topo.save
|
101
106
|
@topo_upload_args[3] = topo['name']
|
102
|
-
upload_cookbooks(@topo_upload_args) if (!config[:
|
107
|
+
upload_cookbooks(@topo_upload_args) if (!config[:disable_upload])
|
103
108
|
|
104
109
|
topo_hash = topo.raw_data
|
105
110
|
nodes = merge_topo_properties(topo_hash['nodes'], topo_hash)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-topo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-07-
|
12
|
+
date: 2014-07-22 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Knife plugin that to manage topologies of nodes
|
15
15
|
email:
|
@@ -27,25 +27,6 @@ files:
|
|
27
27
|
- lib/chef/knife/topo_import.rb
|
28
28
|
- lib/chef/knife/topology_helper.rb
|
29
29
|
- lib/chef/knife/topo_cookbook_upload.rb
|
30
|
-
- test-repo/topology.json
|
31
|
-
- test-repo/Berksfile
|
32
|
-
- test-repo/Vagrantfile
|
33
|
-
- test-repo/Instructions.md
|
34
|
-
- test-repo/Vagrantfile_bridged
|
35
|
-
- test-repo/cookbooks/testapp/recipes/appserver.rb
|
36
|
-
- test-repo/cookbooks/testapp/recipes/deploy.rb
|
37
|
-
- test-repo/cookbooks/testapp/recipes/default.rb
|
38
|
-
- test-repo/cookbooks/testapp/recipes/db.rb
|
39
|
-
- test-repo/cookbooks/testapp/templates/default/nodejs.upstart.conf.erb
|
40
|
-
- test-repo/cookbooks/testapp/CHANGELOG.md
|
41
|
-
- test-repo/cookbooks/testapp/metadata.rb
|
42
|
-
- test-repo/cookbooks/testapp/README.md
|
43
|
-
- test-repo/cookbooks/testapp/files/default/index.html
|
44
|
-
- test-repo/cookbooks/testapp/files/default/package.json
|
45
|
-
- test-repo/cookbooks/testapp/files/default/server.js
|
46
|
-
- test-repo/cookbooks/README.md
|
47
|
-
- test-repo/.chef/knife.rb
|
48
|
-
- test-repo/.chef/dummy.pem
|
49
30
|
- LICENSE
|
50
31
|
- README.md
|
51
32
|
- knife-topo.gemspec
|
data/test-repo/.chef/dummy.pem
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
-----BEGIN RSA PRIVATE KEY-----
|
2
|
-
MIIEogIBAAKCAQEAqZszg6n+ukMvore53ROFNQAAZhEfW0H9erLqC/4Go/lkRhwl
|
3
|
-
d/BOu3bexV2bQFh8Eqg/0VfP0/eOGx4pt6lOP1W20isWr0sGnf8DID2oB/Vi/NhS
|
4
|
-
+zfnos/TMXbJSvXryfpMUB6YKhraC645Q0zuBDHm+3fjGol6nND/tVWCW9h+og7d
|
5
|
-
WTZLOVUbbD949F7WBVEcbNp66e49AaZ5yYevVJtjCQRQQ1E9d+/WsMM0Nv24VEc2
|
6
|
-
oEmbH4U0/+g+WKiJB4m/IDJ4RXco3JtFNpkM/HeKHcc0Niw1A8aLVv5Bp3hYkEnh
|
7
|
-
VidA+H2nZ7IxNOzF3wzJAUwxmg89hC2X1t9WUQIDAQABAoIBAGCZrBKOrS3LfIMy
|
8
|
-
H6NiLdmNAa0gjXp9sHDFHHbuHTwhnFIuT8zrSvyM7L7+3KEehLRfrdF/MTjqY77g
|
9
|
-
RCR+QrniCPnVXttCYSd2CoK/e0flJJccYs8A/WaG9iPTIz0VqlFkxThQ5Jv+pThH
|
10
|
-
6AeD9oDfJ08M7oW7zeEpTKssY84JKE7iAPjBoRF8wMjJPbJB6HEDKPT6pPL9fyjF
|
11
|
-
+FkD01XxaI4Ip5vXsc0+Lckf9uItD5SP4CDcFVxFtU+4m/iJjBrUxeUDrzWCzOY4
|
12
|
-
SgfD9aJ3J79acQ4omtvD0iGUSu/4CwSpAyuw0qzBOS2tmYyaiz0EK2YGg3IbE9xz
|
13
|
-
jPjnj40CgYEA1ai6cb/9PBfF82sG6e23fie2odHN6Lt5Ex7AmCjGg7yVly1rLm7f
|
14
|
-
LxCA+bJfwyOmx7/rptECAFnQeahVcsLQ3KXDwm0IP8Ow60s83Tk0HNrejlIK7f5i
|
15
|
-
8PlvO7Z+bhbTqKDI12YuKJ74pBw4WCP7U4fmxWNryFj1/7o8gPgsqesCgYEAyzeZ
|
16
|
-
3lbya3Txl3gYhS5Ppeuqave/q1jcCYUmoTqCfyZxqQyCmuVpMN/S6zx/vTAlFqHK
|
17
|
-
OsE5v9GD+NuvfhXga4+9FH4nMdbdhYntHLSwgAW/WPShVsNM2WCibIZtkOoI3Bkl
|
18
|
-
wYQF+PZNGPmAChaEsE7oq6vavHD5DHeVmn3M1bMCgYBbLeZjJMutGXggqUwKCKiF
|
19
|
-
7ezCogZ9i4Pf5P/L75rIHXK5UWisKCSWsTRZWwYDAPPryruGNSvlem69fFj64KjB
|
20
|
-
gPxJvL4IeDrILxOKVR8oMT9I/Tos1qLis5AEq5zI3nT1Qah0Q+bu7uitIF3rP2/B
|
21
|
-
9f1Fv2f/1/cjaxbm8wIcgQKBgBx4t8gc6m3/vnF4VAcky+f1MrU17Na25m03CIiC
|
22
|
-
SBJEcpw6snm9NpWwZj6rBUKeYjPfixPcSpkDY7gUH2xM6FppkxYx7o/fCL5S6rOg
|
23
|
-
5TGqnHp8G7aqOjQig98snmE1SPR9WXrZYnTVHUwoeLXxHboN9C9JLqZENcB3aLBy
|
24
|
-
e6ZdAoGACeT2RLyEngm2XVcdNeiXbtwu8+qhoK4FHX5eFKmO2hm+xDo/601acaH+
|
25
|
-
LdFDMKfGevjqTCVS9ZD3SgELSk+KpAvXpVmOzXaX/n/eGCVOYxsWPEKhwpEUsIml
|
26
|
-
9rq1jU/phQw7627WvP8UbwMbNl1u1SDCJwFTFssVmZ3pDI4nth8=
|
27
|
-
-----END RSA PRIVATE KEY-----
|
data/test-repo/.chef/knife.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# See http://docs.opscode.com/config_rb_knife.html for more information on knife configuration options
|
2
|
-
|
3
|
-
current_dir = File.dirname(__FILE__)
|
4
|
-
log_level :info
|
5
|
-
log_location STDOUT
|
6
|
-
node_name "workstation"
|
7
|
-
client_key "#{current_dir}/dummy.pem"
|
8
|
-
validation_client_name "validator"
|
9
|
-
validation_key "#{current_dir}/dummy.pem"
|
10
|
-
chef_server_url "http://10.0.1.1:8889"
|
11
|
-
cache_type 'BasicFile'
|
12
|
-
cache_options( :path => "#{ENV['HOME']}/.chef/checksums" )
|
13
|
-
cookbook_path ["#{current_dir}/../cookbooks"]
|
data/test-repo/Berksfile
DELETED
data/test-repo/Instructions.md
DELETED
@@ -1,131 +0,0 @@
|
|
1
|
-
##Setup
|
2
|
-
|
3
|
-
Assumptions for this demo: chefDK, Vagrant, VirtualBox and chef-zero
|
4
|
-
|
5
|
-
* [chefDK](http://www.getchef.com/downloads/chef-dk/)
|
6
|
-
|
7
|
-
* [Vagrant](https://www.vagrantup.com/downloads.html)
|
8
|
-
|
9
|
-
* [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
|
10
|
-
|
11
|
-
If you have chefDK installed, you can use the embedded chef-zero at
|
12
|
-
/opt/chefdk/embedded/bin/chef-zero
|
13
|
-
|
14
|
-
or install it:
|
15
|
-
|
16
|
-
sudo gem install chef-zero
|
17
|
-
|
18
|
-
Copy `test-repo` into a working directory, either downloading it from
|
19
|
-
github or copying it from the installed knife-topo gem. You can use:
|
20
|
-
|
21
|
-
gem env
|
22
|
-
|
23
|
-
to get the path to your gems and then
|
24
|
-
|
25
|
-
```
|
26
|
-
cp -R <gem-path>/gems/knife-topo/test-repo ~
|
27
|
-
cd ~/test-repo
|
28
|
-
```
|
29
|
-
|
30
|
-
## Demo
|
31
|
-
|
32
|
-
This demo will create and bootstrap two nodes in a topology called test1:
|
33
|
-
|
34
|
-
* an application server with a specific version of nodejs (0.10.28), running
|
35
|
-
a test application
|
36
|
-
* a database server with a specific version of mongodb (2.6.1)
|
37
|
-
|
38
|
-
Each node in the topology will be tagged with 'testsys' and will
|
39
|
-
have an 'owner' and 'node_type' normal attribute.
|
40
|
-
|
41
|
-
The test1 topology will also contain a third node called buildserver01,
|
42
|
-
which is created but not bootstrapped. This node:
|
43
|
-
|
44
|
-
* Is in a different chef environment ('dev')
|
45
|
-
* Requires a different version of mongodb
|
46
|
-
|
47
|
-
In this demo
|
48
|
-
|
49
|
-
### Running the demo
|
50
|
-
|
51
|
-
From the test-repo, do the following. Note: you may be prompted to select the network to bridge to
|
52
|
-
|
53
|
-
vagrant up
|
54
|
-
|
55
|
-
This will start the virtual machines on a
|
56
|
-
private network using vagrant. Once the virtual machines are created,
|
57
|
-
start chef-zero listening on the same private network:
|
58
|
-
|
59
|
-
chef-zero -H 10.0.1.1
|
60
|
-
|
61
|
-
In another terminal, in test-repo:
|
62
|
-
|
63
|
-
```
|
64
|
-
berks install
|
65
|
-
berks upload
|
66
|
-
```
|
67
|
-
|
68
|
-
To create and bootstrap the test1 topology:
|
69
|
-
|
70
|
-
```
|
71
|
-
knife topo import topology.json
|
72
|
-
knife topo create test1 --bootstrap -x vagrant -P vagrant --sudo
|
73
|
-
```
|
74
|
-
|
75
|
-
To check the bootstrap has succeeded, browse to:
|
76
|
-
[http://localhost:3031](http://localhost:3031).
|
77
|
-
You should see a "Welcome" message.
|
78
|
-
|
79
|
-
You can see the results on the Chef server
|
80
|
-
using standard knife commands, for example:
|
81
|
-
|
82
|
-
```
|
83
|
-
knife node list
|
84
|
-
knife node show appserver01
|
85
|
-
knife node show appserver01 -a normal
|
86
|
-
knife data bag show topologies test1
|
87
|
-
```
|
88
|
-
|
89
|
-
You can try your own modifications to the topologies.json file. To
|
90
|
-
update the topology with the modified configuration:
|
91
|
-
|
92
|
-
```
|
93
|
-
knife topo import your_topology.json
|
94
|
-
knife topo update test1
|
95
|
-
```
|
96
|
-
|
97
|
-
|
98
|
-
####Troubleshooting
|
99
|
-
|
100
|
-
If you are having trouble with berks (`read server certificate B:
|
101
|
-
certificate verify failed (Faraday::SSLError)`
|
102
|
-
try following the instructions
|
103
|
-
[here](https://gist.github.com/fnichol/867550#the-manual-way-boring)
|
104
|
-
to add CA certificates for OpenSSL
|
105
|
-
|
106
|
-
If the bootstrap fails with 'ERROR: 412 "Precondition Failed"', make sure
|
107
|
-
you have run `berks upload` since you started chef-zero.
|
108
|
-
|
109
|
-
I encountered some problems getting chef-zero to run on a private network
|
110
|
-
on Windows 8.1 (it responded really really slowly).
|
111
|
-
If you have similar problems, you can use hosted Chef
|
112
|
-
(sign up for a free account [here](https://manage.opscode.com/signup))
|
113
|
-
or your own Chef server. Copy your knife settings and certificates (e.g.,
|
114
|
-
the contents of chef-repo/.chef in the "Getting Started" download) into
|
115
|
-
test-repo/.chef, and replace the Vagrantfile in test-repo with
|
116
|
-
Vagrantfile_bridged (which will allow the VMs to connect to addresses
|
117
|
-
outside of the host).
|
118
|
-
|
119
|
-
If you modify the cookbook_attributes for mongodb and this causes
|
120
|
-
a downgrade, the Chef run may fail to converge.
|
121
|
-
There is an [issue](https://github.com/edelight/chef-mongodb/pull/305)
|
122
|
-
in the current cookbook which has been fixed but
|
123
|
-
not released (as of 19 July 2014). Run the following to remove the
|
124
|
-
installed mongodb and then retry the knife topo bootstrap:
|
125
|
-
|
126
|
-
vagrant ssh dbserver -c 'sudo apt-get remove mongodb'
|
127
|
-
|
128
|
-
If you have changed the nodejs version, you need to also change the
|
129
|
-
SHA256 checksum. This can be found at
|
130
|
-
http://nodejs.org/dist/v0.xx.xx/SHASUMS256.txt. The one you want is
|
131
|
-
for 'node-v0.xx.xx-linux-x64.tar.gz'
|
data/test-repo/Vagrantfile
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
# -*- mode: ruby -*-
|
2
|
-
# vi: set ft=ruby :
|
3
|
-
|
4
|
-
# This Vagrantfile was inspired by Joshua Timberman's blog
|
5
|
-
# http://jtimberman.housepub.org/blog/2012/03/18/multivm-vagrantfile-for-chef/
|
6
|
-
|
7
|
-
#
|
8
|
-
# Vagrantfile for two-machine test topology. Runs with a private network
|
9
|
-
# and port forwarding from 3001 on appserver guest, to port 303n on host (i.e. 3031 for topo with id 1).
|
10
|
-
# ipaddresses are 10.0.1.2, 10.0.1.3 for dbserver, appserver.
|
11
|
-
|
12
|
-
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
|
13
|
-
VAGRANTFILE_API_VERSION = "2"
|
14
|
-
|
15
|
-
id = 1
|
16
|
-
qual = "0#{id}"
|
17
|
-
|
18
|
-
# Define the options for each node
|
19
|
-
nodes = {
|
20
|
-
:dbserver => {
|
21
|
-
:hostname => "dbserver#{qual}",
|
22
|
-
:private_ipaddress => "10.0.#{id}.2"
|
23
|
-
},
|
24
|
-
:appserver => {
|
25
|
-
:hostname => "appserver#{qual}",
|
26
|
-
:private_ipaddress => "10.0.#{id}.3",
|
27
|
-
:forwardports => [
|
28
|
-
{
|
29
|
-
:guest => 3001,
|
30
|
-
:host => (3030 + id)
|
31
|
-
}
|
32
|
-
]
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
37
|
-
|
38
|
-
# setup each node using config ("options") defined above
|
39
|
-
nodes.each do |node, options|
|
40
|
-
config.vm.define node do |node_config|
|
41
|
-
|
42
|
-
# setup networking using private network, with port forwarding where needed to access, and optional bridge
|
43
|
-
node_config.vm.network :public_network if options.has_key?(:public)
|
44
|
-
node_config.vm.network :private_network, ip: options[:private_ipaddress] if options.has_key?(:private_ipaddress)
|
45
|
-
|
46
|
-
if options.has_key?(:forwardports)
|
47
|
-
options[:forwardports].each do |port|
|
48
|
-
node_config.vm.network :forwarded_port, guest: port[:guest], host: port[:host]
|
49
|
-
end
|
50
|
-
end
|
51
|
-
node_config.vm.hostname = options[:hostname]
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# Setup the generic config across both servers
|
56
|
-
config.vm.box = "ubuntu64"
|
57
|
-
|
58
|
-
# The url from where the 'config.vm.box' box will be fetched if it
|
59
|
-
# doesn't already exist on the user's system.
|
60
|
-
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
|
61
|
-
|
62
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
# -*- mode: ruby -*-
|
2
|
-
# vi: set ft=ruby :
|
3
|
-
|
4
|
-
# This Vagrantfile was inspired by Joshua Timberman's blog
|
5
|
-
# http://jtimberman.housepub.org/blog/2012/03/18/multivm-vagrantfile-for-chef/
|
6
|
-
|
7
|
-
#
|
8
|
-
# Vagrantfile for two-machine test topology. Runs with a bridged network
|
9
|
-
# and port forwarding from 3001 on appserver guest, to port 303n on host (i.e. 3031 for topo with id 1).
|
10
|
-
# ipaddresses are 10.0.1.2, 10.0.1.3 for dbserver, appserver.
|
11
|
-
|
12
|
-
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
|
13
|
-
VAGRANTFILE_API_VERSION = "2"
|
14
|
-
|
15
|
-
id = 1
|
16
|
-
qual = "0#{id}"
|
17
|
-
|
18
|
-
# Define the options for each node
|
19
|
-
nodes = {
|
20
|
-
:dbserver => {
|
21
|
-
:hostname => "dbserver#{qual}",
|
22
|
-
:private_ipaddress => "10.0.#{id}.2",
|
23
|
-
:public => true
|
24
|
-
},
|
25
|
-
:appserver => {
|
26
|
-
:hostname => "appserver#{qual}",
|
27
|
-
:private_ipaddress => "10.0.#{id}.3",
|
28
|
-
:public => true,
|
29
|
-
:forwardports => [
|
30
|
-
{
|
31
|
-
:guest => 3001,
|
32
|
-
:host => (3030 + id)
|
33
|
-
}
|
34
|
-
]
|
35
|
-
}
|
36
|
-
}
|
37
|
-
|
38
|
-
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
39
|
-
|
40
|
-
# setup each node using config ("options") defined above
|
41
|
-
nodes.each do |node, options|
|
42
|
-
config.vm.define node do |node_config|
|
43
|
-
|
44
|
-
# setup networking using private network, with port forwarding where needed to access, and optional bridge
|
45
|
-
node_config.vm.network :public_network if options.has_key?(:public)
|
46
|
-
node_config.vm.network :private_network, ip: options[:private_ipaddress] if options.has_key?(:private_ipaddress)
|
47
|
-
|
48
|
-
node_config.vm.hostname = options[:hostname]
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# Setup the generic config across both servers
|
53
|
-
config.vm.box = "ubuntu64"
|
54
|
-
|
55
|
-
# The url from where the 'config.vm.box' box will be fetched if it
|
56
|
-
# doesn't already exist on the user's system.
|
57
|
-
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
|
58
|
-
|
59
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
This directory contains the cookbooks used to configure systems in your infrastructure with Chef.
|
2
|
-
|
3
|
-
Knife needs to be configured to know where the cookbooks are located with the `cookbook_path` setting. If this is not set, then several cookbook operations will fail to work properly.
|
4
|
-
|
5
|
-
cookbook_path ["./cookbooks"]
|
6
|
-
|
7
|
-
This setting tells knife to look for the cookbooks directory in the present working directory. This means the knife cookbook subcommands need to be run in the `chef-repo` directory itself. To make sure that the cookbooks can be found elsewhere inside the repository, use an absolute path. This is a Ruby file, so something like the following can be used:
|
8
|
-
|
9
|
-
current_dir = File.dirname(__FILE__)
|
10
|
-
cookbook_path ["#{current_dir}/../cookbooks"]
|
11
|
-
|
12
|
-
Which will set `current_dir` to the location of the knife.rb file itself (e.g. `~/chef-repo/.chef/knife.rb`).
|
13
|
-
|
14
|
-
Configure knife to use your preferred copyright holder, email contact and license. Add the following lines to `.chef/knife.rb`.
|
15
|
-
|
16
|
-
cookbook_copyright "Example, Com."
|
17
|
-
cookbook_email "cookbooks@example.com"
|
18
|
-
cookbook_license "apachev2"
|
19
|
-
|
20
|
-
Supported values for `cookbook_license` are "apachev2", "mit","gplv2","gplv3", or "none". These settings are used to prefill comments in the default recipe, and the corresponding values in the metadata.rb. You are free to change the the comments in those files.
|
21
|
-
|
22
|
-
Create new cookbooks in this directory with Knife.
|
23
|
-
|
24
|
-
knife cookbook create COOKBOOK
|
25
|
-
|
26
|
-
This will create all the cookbook directory components. You don't need to use them all, and can delete the ones you don't need. It also creates a README file, metadata.rb and default recipe.
|
27
|
-
|
28
|
-
You can also download cookbooks directly from the Opscode Cookbook Site. There are two subcommands to help with this depending on what your preference is.
|
29
|
-
|
30
|
-
The first and recommended method is to use a vendor branch if you're using Git. This is automatically handled with Knife.
|
31
|
-
|
32
|
-
knife cookbook site install COOKBOOK
|
33
|
-
|
34
|
-
This will:
|
35
|
-
|
36
|
-
* Download the cookbook tarball from cookbooks.opscode.com.
|
37
|
-
* Ensure its on the git master branch.
|
38
|
-
* Checks for an existing vendor branch, and creates if it doesn't.
|
39
|
-
* Checks out the vendor branch (chef-vendor-COOKBOOK).
|
40
|
-
* Removes the existing (old) version.
|
41
|
-
* Untars the cookbook tarball it downloaded in the first step.
|
42
|
-
* Adds the cookbook files to the git index and commits.
|
43
|
-
* Creates a tag for the version downloaded.
|
44
|
-
* Checks out the master branch again.
|
45
|
-
* Merges the cookbook into master.
|
46
|
-
* Repeats the above for all the cookbooks dependencies, downloading them from the community site
|
47
|
-
|
48
|
-
The last step will ensure that any local changes or modifications you have made to the cookbook are preserved, so you can keep your changes through upstream updates.
|
49
|
-
|
50
|
-
If you're not using Git, use the site download subcommand to download the tarball.
|
51
|
-
|
52
|
-
knife cookbook site download COOKBOOK
|
53
|
-
|
54
|
-
This creates the COOKBOOK.tar.gz from in the current directory (e.g., `~/chef-repo`). We recommend following a workflow similar to the above for your version control tool.
|
@@ -1,26 +0,0 @@
|
|
1
|
-
Test Application Cookbook
|
2
|
-
=========================
|
3
|
-
A simple nodejs application that puts up a welcome page.
|
4
|
-
|
5
|
-
Requirements
|
6
|
-
------------
|
7
|
-
Tested on Ubuntu 12.04 LTS.
|
8
|
-
|
9
|
-
#### packages
|
10
|
-
- `nodejs` - The test application is a nodejs application
|
11
|
-
- ` mongodb` - In the future, the test application will have a connection to a database
|
12
|
-
|
13
|
-
Attributes
|
14
|
-
----------
|
15
|
-
None
|
16
|
-
|
17
|
-
|
18
|
-
Recipes
|
19
|
-
-------
|
20
|
-
#### testapp::default
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
License and Authors
|
25
|
-
-------------------
|
26
|
-
Authors: Christine Draper, ThirdWave Insights, LLC
|
@@ -1,13 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8">
|
5
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
6
|
-
<title>YPO Test Application</title>
|
7
|
-
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
<p> Welcome ! You can find the knife topo plugin on Github:</p>
|
11
|
-
<a href="https://github.com">https://github.com/thirdwaveinsights/knife-topo</a>
|
12
|
-
</body>
|
13
|
-
</html>
|
@@ -1,14 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": "testapp",
|
3
|
-
"description": "A dummy application for testing knife-topo",
|
4
|
-
"author": "ThirdWave Insights LLC <contact@thirdwaveinsights.com>",
|
5
|
-
"version": "0.0.1",
|
6
|
-
"private": true,
|
7
|
-
"main": "server.js",
|
8
|
-
"dependencies": {
|
9
|
-
"express": "3.3.4",
|
10
|
-
"ejs": "0.8.4",
|
11
|
-
"connect": "2.8.4"
|
12
|
-
},
|
13
|
-
"engine": "node 0.10.15"
|
14
|
-
}
|
@@ -1,42 +0,0 @@
|
|
1
|
-
/*jslint node: true */
|
2
|
-
"use strict";
|
3
|
-
|
4
|
-
/**
|
5
|
-
* Module dependencies.
|
6
|
-
*/
|
7
|
-
|
8
|
-
var express = require('express')
|
9
|
-
, ejs = require('ejs')
|
10
|
-
, http = require('http')
|
11
|
-
;
|
12
|
-
|
13
|
-
// APPLICATION INITIALIZATION
|
14
|
-
|
15
|
-
|
16
|
-
/*
|
17
|
-
* Setup the express middleware pipeline.
|
18
|
-
*/
|
19
|
-
var app = express();
|
20
|
-
|
21
|
-
app.set('port', 3001 );
|
22
|
-
app.set('views', __dirname);
|
23
|
-
app.set('view engine', 'html'); // default extension to use if omitted
|
24
|
-
app.engine('html', ejs.renderFile); // Use ejs engine for routed html
|
25
|
-
app.use(app.router); // Enables routing
|
26
|
-
|
27
|
-
|
28
|
-
//render the index page
|
29
|
-
app.get('/', function(req, res) {
|
30
|
-
var username = (req.user && req.user.userName) ? req.user.userName : "";
|
31
|
-
res.render('index.html');
|
32
|
-
});
|
33
|
-
|
34
|
-
|
35
|
-
/*
|
36
|
-
* Startup the http server
|
37
|
-
*/
|
38
|
-
http.createServer(app).listen(app.get('port'), function(){
|
39
|
-
console.log("YPO example application server started and listening on port " + app.get('port'));
|
40
|
-
});
|
41
|
-
|
42
|
-
|
@@ -1,9 +0,0 @@
|
|
1
|
-
name 'testapp'
|
2
|
-
maintainer 'ThirdWave Insights LLC'
|
3
|
-
maintainer_email 'christine_draper@thirdwaveinsights.com'
|
4
|
-
license 'Apache v2.0'
|
5
|
-
description 'Installs/Configures test application'
|
6
|
-
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
7
|
-
version '0.1'
|
8
|
-
depends 'mongodb'
|
9
|
-
depends 'nodejs'
|
@@ -1,50 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Cookbook Name:: testapp
|
3
|
-
# Recipe:: deploy
|
4
|
-
#
|
5
|
-
# Copyright 2014, ThirdWave Insights
|
6
|
-
#
|
7
|
-
#
|
8
|
-
|
9
|
-
directory "/home/vagrant/ypo" do
|
10
|
-
owner "vagrant"
|
11
|
-
group "vagrant"
|
12
|
-
mode 00750
|
13
|
-
action :create
|
14
|
-
end
|
15
|
-
|
16
|
-
cookbook_file "/home/vagrant/ypo/server.js" do
|
17
|
-
source 'server.js'
|
18
|
-
end
|
19
|
-
|
20
|
-
cookbook_file "/home/vagrant/ypo/package.json" do
|
21
|
-
source 'package.json'
|
22
|
-
end
|
23
|
-
|
24
|
-
cookbook_file "/home/vagrant/ypo/index.html" do
|
25
|
-
source 'index.html'
|
26
|
-
end
|
27
|
-
|
28
|
-
execute 'install_ypo' do
|
29
|
-
cwd "/home/vagrant/ypo"
|
30
|
-
user "vagrant"
|
31
|
-
command "npm install"
|
32
|
-
end
|
33
|
-
|
34
|
-
template "ypo.upstart.conf" do
|
35
|
-
path "/etc/init/ypo.conf"
|
36
|
-
source 'nodejs.upstart.conf.erb'
|
37
|
-
mode '0644'
|
38
|
-
variables(
|
39
|
-
:user => 'vagrant',
|
40
|
-
:node_dir => '/usr/local',
|
41
|
-
:app_dir => '/home/vagrant',
|
42
|
-
:entry => 'ypo'
|
43
|
-
)
|
44
|
-
end
|
45
|
-
|
46
|
-
service 'ypo' do
|
47
|
-
provider Chef::Provider::Service::Upstart
|
48
|
-
supports :restart => true, :start => true, :stop => true
|
49
|
-
action [:restart]
|
50
|
-
end
|
data/test-repo/topology.json
DELETED
@@ -1,124 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": "test1",
|
3
|
-
"chef_environment": "test",
|
4
|
-
"tags":
|
5
|
-
[
|
6
|
-
"testsys"
|
7
|
-
],
|
8
|
-
"normal":
|
9
|
-
{
|
10
|
-
"owner": {
|
11
|
-
"name": "Christine Draper",
|
12
|
-
"phone": "512-xxx-xxxx",
|
13
|
-
"email": "christine_draper@thirdwaveinsights.com"
|
14
|
-
}
|
15
|
-
},
|
16
|
-
"nodes":
|
17
|
-
[
|
18
|
-
{
|
19
|
-
"name": "appserver01",
|
20
|
-
"ssh_host": "10.0.1.3",
|
21
|
-
"run_list":
|
22
|
-
[
|
23
|
-
"recipe[apt]",
|
24
|
-
"recipe[testapp::appserver]",
|
25
|
-
"testapp::deploy",
|
26
|
-
"testsys_test1"
|
27
|
-
],
|
28
|
-
|
29
|
-
"normal":
|
30
|
-
{
|
31
|
-
"topo":
|
32
|
-
{
|
33
|
-
"node_type": "appserver"
|
34
|
-
}
|
35
|
-
}
|
36
|
-
},
|
37
|
-
{
|
38
|
-
"name": "dbserver01",
|
39
|
-
"ssh_host": "10.0.1.2",
|
40
|
-
"run_list":
|
41
|
-
[
|
42
|
-
"recipe[apt]",
|
43
|
-
"recipe[testapp::db]",
|
44
|
-
"testsys_test1"
|
45
|
-
],
|
46
|
-
|
47
|
-
"tags":
|
48
|
-
[
|
49
|
-
"testapp_database"
|
50
|
-
],
|
51
|
-
|
52
|
-
"normal":
|
53
|
-
{
|
54
|
-
"topo":
|
55
|
-
{
|
56
|
-
"node_type": "dbserver"
|
57
|
-
}
|
58
|
-
}
|
59
|
-
},
|
60
|
-
{
|
61
|
-
"name": "buildserver01",
|
62
|
-
"chef_environment": "dev",
|
63
|
-
"run_list":
|
64
|
-
[
|
65
|
-
"recipe[apt]",
|
66
|
-
"recipe[testapp::db]",
|
67
|
-
"recipe[testapp::appserver]",
|
68
|
-
"recipe[testapp::deploy]",
|
69
|
-
"testsys_test1"
|
70
|
-
],
|
71
|
-
|
72
|
-
"tags":
|
73
|
-
[
|
74
|
-
],
|
75
|
-
|
76
|
-
"normal":
|
77
|
-
{
|
78
|
-
"topo":
|
79
|
-
{
|
80
|
-
"node_type": "buildserver"
|
81
|
-
}
|
82
|
-
}
|
83
|
-
}
|
84
|
-
],
|
85
|
-
|
86
|
-
"cookbook_attributes":
|
87
|
-
[
|
88
|
-
{
|
89
|
-
"cookbook": "testsys_test1",
|
90
|
-
"filename": "softwareversion",
|
91
|
-
"normal":
|
92
|
-
{
|
93
|
-
"nodejs":
|
94
|
-
{
|
95
|
-
"version": "0.10.28",
|
96
|
-
"checksum_linux_x64": "5f41f4a90861bddaea92addc5dfba5357de40962031c2281b1683277a0f75932"
|
97
|
-
},
|
98
|
-
|
99
|
-
"testapp":
|
100
|
-
{
|
101
|
-
"version": "0.0.3"
|
102
|
-
},
|
103
|
-
|
104
|
-
"mongodb":
|
105
|
-
{
|
106
|
-
"package_version": "2.6.1"
|
107
|
-
}
|
108
|
-
},
|
109
|
-
"conditional" : [
|
110
|
-
{
|
111
|
-
"qualifier": "node_type",
|
112
|
-
"value" : "buildserver",
|
113
|
-
"normal":
|
114
|
-
{
|
115
|
-
"mongodb":
|
116
|
-
{
|
117
|
-
"package_version": "2.5.1"
|
118
|
-
}
|
119
|
-
}
|
120
|
-
}
|
121
|
-
]
|
122
|
-
}
|
123
|
-
]
|
124
|
-
}
|