chef-tlc-workflow 0.1.3 → 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/Gemfile +0 -3
- data/README.md +90 -31
- data/Rakefile +46 -69
- data/chef-tlc-workflow.gemspec +3 -9
- data/lib/chef-tlc-workflow/version.rb +1 -1
- data/test/esx_fake/Vagrantfile +39 -0
- data/test/vagrant-1.x-bootstrap/.gitignore +3 -0
- data/test/vagrant-1.x-bootstrap/Gemfile +4 -0
- data/test/vagrant-1.x-bootstrap/Rakefile +13 -0
- data/test/vagrant-1.x-bootstrap/Vagrantfile +104 -0
- data/test/{ec2-bootstrap → vagrant-1.x-bootstrap}/app_cookbooks.yml +0 -6
- metadata +17 -102
- data/Vagrantfile +0 -33
- data/test/Gemfile +0 -7
- data/test/ec2-bootstrap/.chef/bootstrap/omnibus-chef.sh +0 -34
- data/test/ec2-bootstrap/.gitignore +0 -3
- data/test/ec2-bootstrap/Mccloudfile +0 -60
- data/test/ec2-bootstrap/Rakefile +0 -57
- data/test/esx-bootstrap/.chef/knife.rb +0 -10
- data/test/esx-bootstrap/.gitignore +0 -4
- data/test/esx-bootstrap/Rakefile +0 -58
- data/test/esx-bootstrap/app_cookbooks.yml +0 -12
- data/test/esx-bootstrap/nodes/33.33.77.10.json +0 -6
- data/test/local-bootstrap/.gitignore +0 -4
- data/test/local-bootstrap/Rakefile +0 -50
- data/test/local-bootstrap/Vagrantfile +0 -31
- data/test/local-bootstrap/app_cookbooks.yml +0 -12
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,13 +1,21 @@
|
|
1
|
-
#
|
1
|
+
# Chef "Top-Level Cookbooks" Workflow
|
2
2
|
|
3
|
-
|
3
|
+
`chef-tlc-workflow` supports an opiniated workflow for working with Chef. It is based on the strict distinction of top-level vs. dependent cookbooks (see below) and it's currently focussed on chef-solo only.
|
4
4
|
|
5
|
-
First of all, it provides
|
5
|
+
First of all, it provides a [working sample](https://github.com/tknerr/chef-tlc-workflow/tree/master/test/vagrant-1.x-bootstrap) for deployment to esx, ec2 and local from within single `Vagrantfile`.
|
6
6
|
|
7
|
-
Other than
|
7
|
+
Other than that it provides helper methods to use the dependencies defined in `metadata.rb` from within [librarian](https://github.com/applicationsonline/librarian) `Cheffile`s. This ensures consistency between the dependencies specified in metadata and resolved via librarian (**NOTE:** to be replaced with Berkshelf soon!)
|
8
8
|
|
9
9
|
Finally, it ensures a consistent gem set by declaring all the gems we use in our workflow in its own gemspec, i.e. `chef-tlc-workflow` is the only gem you need to depend on - everything else (like vagrant, mcloud, etc..) comes in as transitive dependencies.
|
10
10
|
|
11
|
+
|
12
|
+
## Terminology
|
13
|
+
|
14
|
+
* **infrastructure** is a Chef-Repo like structure which describes the nodes that are part of it and which services are to be installed on these nodes via *top-level cookbooks*
|
15
|
+
* **top-level cookbooks** are the top-level cookbooks that fully configure a node by combining a set of *dependent cookbooks*, configuring them appropriately and locking them at a specific version.
|
16
|
+
* **dependent cookbooks** are the finer-grained, reusable and flexible cookbooks that you typically leverage for building high-level services in terms of *top-level cookbooks*
|
17
|
+
|
18
|
+
|
11
19
|
## Installation
|
12
20
|
|
13
21
|
Add this line to your application's Gemfile:
|
@@ -23,63 +31,114 @@ Or install it yourself as:
|
|
23
31
|
$ gem install chef-tlc-workflow
|
24
32
|
|
25
33
|
|
34
|
+
## Prerequisites
|
35
|
+
|
36
|
+
You need Vagrant 1.2.x and the following plugins for the [sample Vagrantfile](https://github.com/tknerr/chef-tlc-workflow/tree/master/test/vagrant-1.x-bootstrap/Vagrantfile) to work:
|
37
|
+
|
38
|
+
```
|
39
|
+
vagrant plugin install vagrant-aws --plugin-version 0.2.2
|
40
|
+
vagrant plugin install vagrant-managed-servers --plugin-version 0.1.0
|
41
|
+
vagrant plugin install vagrant-omnibus --plugin-version 1.0.2
|
42
|
+
vagrant plugin install vagrant-cachier --plugin-version 0.1.0
|
43
|
+
```
|
44
|
+
|
26
45
|
## Usage
|
27
46
|
|
28
|
-
|
47
|
+
### Deployment to VirtualBox, AWS and Managed ESX Servers
|
48
|
+
|
49
|
+
Assuming you are in the `test/vagrant-1.x-bootstrap` directory you need to install the bundle first:
|
50
|
+
```
|
51
|
+
$ cd test/vagrant-1.x-bootstrap
|
52
|
+
$ bundle install
|
53
|
+
Fetching gem metadata from http://rubygems.org/..
|
54
|
+
Fetching gem metadata from https://gems.gemfury.com/psBbdHx94zqZrvxpiVmm/..
|
55
|
+
Using rake (0.9.6)
|
56
|
+
Using Platform (0.4.0)
|
57
|
+
Using ansi (1.4.3)
|
58
|
+
Using archive-tar-minitar (0.5.2)
|
59
|
+
Using multi_json (1.7.6)
|
60
|
+
...
|
61
|
+
```
|
62
|
+
|
63
|
+
Then you need to resolve the [sample-app](https://github.com/tknerr/chef-tlc-workflow/tree/master/test/sample-app) top-level cookbook along with all its dependencies into the `./cookbooks` directory:
|
64
|
+
```
|
65
|
+
$ rake resolve_sample_app
|
66
|
+
cd tmp/tlc/sample-app-0.1.0 && librarian-chef install --path D:/Repos/_github/chef-tlc-workflow/test/vagrant-1.x-bootstrap/cookbooks/sample-app-0.1.0
|
67
|
+
Installing apache2 (1.5.0)
|
68
|
+
Installing apt (1.3.2)
|
69
|
+
Installing sample-app (0.1.0)
|
70
|
+
```
|
29
71
|
|
30
|
-
|
72
|
+
See, the dependencies are now resolved per top-level cookbook (i.e. `sample-app-0.1.0` in this case) separately:
|
73
|
+
```
|
74
|
+
$ ls -la cookbooks/sample-app-0.1.0
|
75
|
+
total 12
|
76
|
+
drwxr-xr-x 5 tkn tkn 0 Jun 11 17:44 .
|
77
|
+
drwxr-xr-x 3 tkn tkn 0 Jun 11 17:44 ..
|
78
|
+
drwxr-xr-x 7 tkn tkn 4096 Jun 11 17:44 apache2
|
79
|
+
drwxr-xr-x 6 tkn tkn 4096 Jun 11 17:44 apt
|
80
|
+
drwxr-xr-x 6 tkn tkn 4096 Jun 11 17:44 sample-app
|
81
|
+
```
|
31
82
|
|
32
|
-
|
83
|
+
Deploy to VirtualBox:
|
33
84
|
|
34
|
-
|
35
|
-
|
36
|
-
|
85
|
+
```
|
86
|
+
vagrant up sample-app-vbox
|
87
|
+
```
|
37
88
|
|
38
|
-
|
89
|
+
Deploy to AWS via [vagrant-aws]:
|
90
|
+
```
|
91
|
+
vagrant up sample-app-aws --provider=aws
|
92
|
+
```
|
39
93
|
|
40
|
-
|
94
|
+
Deploy to a [managed](https://github.com/tknerr/vagrant-managed-servers) ESX Server:
|
95
|
+
```
|
96
|
+
vagrant up sample-app-esx --provider=managed
|
97
|
+
vagrant provision sample-app-esx
|
98
|
+
```
|
41
99
|
|
42
|
-
In addition, it provides a place for describing the nodes within that deployment environment. Depending on the environment this might be a `Vagrantfile`, `Mccloudfile` or `<node>.json` file. Again, see the examples in the `test/` directory.
|
43
100
|
|
44
101
|
### Librarian Helper
|
45
102
|
|
103
|
+
**NOTE:** this is going to be replaced with Berkshelf soon
|
104
|
+
|
46
105
|
Since librarian does not support reading the cookbook dependencies from `metadata.rb`, the `ChefTLCWorkflow::Helpers` module adds this functionality.
|
47
106
|
|
48
107
|
In the trivial case you can use it in your cookbook project's `Cheffile` like so:
|
49
108
|
|
50
|
-
|
109
|
+
```ruby
|
110
|
+
require 'chef-tlc-workflow/helpers'
|
51
111
|
|
52
|
-
|
53
|
-
|
54
|
-
|
112
|
+
ChefTLCWorkflow::Helpers::from_metadata.each do |cb_name, cb_version|
|
113
|
+
cookbook cb_name, cb_version
|
114
|
+
end
|
115
|
+
```
|
55
116
|
|
56
117
|
If some of the cookbooks defined in metadata.rb are not available from the community site, you can define your overrides like so:
|
57
118
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
119
|
+
```ruby
|
120
|
+
...
|
121
|
+
@overrides = {
|
122
|
+
'tlc-base' => { :git => 'https://github.com/tknerr/cookbook-tlc-base.git', :ref => 'master' },
|
123
|
+
}
|
62
124
|
|
63
|
-
|
64
|
-
|
65
|
-
|
125
|
+
ChefTLCWorkflow::Helpers::from_metadata.each do |cb_name, cb_version|
|
126
|
+
cookbook cb_name, cb_version, @overrides[cb_name]
|
127
|
+
end
|
128
|
+
```
|
66
129
|
|
67
130
|
|
68
131
|
### Single Gemfile Dependency
|
69
132
|
|
70
133
|
It references all gems we need for our Chef workflow, this means that your `Gemfile` basically looks like this:
|
71
134
|
|
72
|
-
```
|
135
|
+
```ruby
|
73
136
|
source :rubygems
|
74
137
|
|
75
|
-
|
76
|
-
source 'https://gems.gemfury.com/hUe8s8nSyzxs7JMMSZV8/' # vagrant-1.0.5.1
|
77
|
-
source 'https://gems.gemfury.com/psBbdHx94zqZrvxpiVmm/' # librarian-0.0.26.2
|
78
|
-
|
79
|
-
gem "chef-tlc-workflow", "0.1.0"
|
138
|
+
gem "chef-tlc-workflow", "0.2.0"
|
80
139
|
```
|
81
140
|
|
82
|
-
This brings in all the transitive gem dependencies as defined in the `chef-tlc-workflow.gemspec`, e.g.
|
141
|
+
This brings in all the transitive gem dependencies as defined in the `chef-tlc-workflow.gemspec`, e.g. librarian, chef, foodcritic, etc...
|
83
142
|
|
84
143
|
While this is not ideal in terms of keeping the LOAD_PATH as small as possible, it's a tradeoff in favor of convenience and consistency.
|
85
144
|
|
data/Rakefile
CHANGED
@@ -2,9 +2,9 @@ require "bundler/gem_tasks"
|
|
2
2
|
|
3
3
|
desc "run all tests"
|
4
4
|
task :test => [
|
5
|
-
:
|
6
|
-
:
|
7
|
-
:
|
5
|
+
:test_vagrant_esx_bootstrap,
|
6
|
+
:test_vagrant_aws_bootstrap,
|
7
|
+
:test_vagrant_vbox_bootstrap
|
8
8
|
]
|
9
9
|
|
10
10
|
#
|
@@ -13,98 +13,75 @@ task :test => [
|
|
13
13
|
# * check for apache default page
|
14
14
|
# * more realistic scenario: e.g. scaffold infra, create Cheffile and node.json on the fly, etc...
|
15
15
|
#
|
16
|
-
desc "tests bootstrapping
|
17
|
-
task :
|
18
|
-
|
19
|
-
app = 'sample-app@0.1.0'
|
20
|
-
user = 'vagrant'
|
21
|
-
host = '33.33.77.10'
|
22
|
-
ssh_key = 'W:/home/.vagrant.d/insecure_private_key'
|
16
|
+
desc "tests bootstrapping in an esx-like environment via vagrant-managed-servers provider"
|
17
|
+
task :test_vagrant_esx_bootstrap do
|
23
18
|
|
24
19
|
begin
|
25
20
|
# simulate esx-like environment using vagrant and a bare-os basebox
|
26
|
-
|
27
|
-
|
21
|
+
run_cmd_esx "vagrant destroy esx_like_vm -f"
|
22
|
+
run_cmd_esx "vagrant up esx_like_vm" do |ok, res|
|
28
23
|
puts "ok: #{ok}\nres: #{res}" # ignore vagrant error for bare-os vm
|
29
24
|
end
|
30
25
|
|
31
|
-
|
32
|
-
run_cmd_esx "rake resolve_deps"
|
33
|
-
# bootstrap node with chef
|
34
|
-
run_cmd_esx "rake bootstrap[#{host},#{user},#{ssh_key}]"
|
35
|
-
# provision node with app
|
36
|
-
run_cmd_esx "rake provision[#{app},#{host},#{user},#{ssh_key}]"
|
37
|
-
# remove chef-solo traces from node
|
38
|
-
run_cmd_esx "rake cleanup[#{host},#{user},#{ssh_key}]"
|
39
|
-
|
40
|
-
# TODO: test if sample app works
|
26
|
+
test_vagrant_commands(:esx)
|
41
27
|
ensure
|
42
28
|
# cleanup
|
43
|
-
|
29
|
+
run_cmd_esx "vagrant destroy esx_like_vm -f"
|
44
30
|
end
|
45
31
|
end
|
46
32
|
|
47
33
|
|
48
|
-
desc "tests bootstrapping
|
49
|
-
task :
|
50
|
-
|
51
|
-
vm_name = 'sample-app'
|
52
|
-
|
53
|
-
begin
|
54
|
-
# resolve deps
|
55
|
-
run_cmd_ec2 "rake resolve_deps"
|
56
|
-
# bring up ec2 instance, bootstrap with chef and provision
|
57
|
-
run_cmd_ec2 "rake up[#{vm_name}]"
|
58
|
-
# re-provison ec2 instance
|
59
|
-
run_cmd_ec2 "rake provision[#{vm_name}]"
|
60
|
-
# show status of ec2 instances
|
61
|
-
run_cmd_ec2 "rake status"
|
62
|
-
|
63
|
-
|
64
|
-
# TODO: test if sample app works
|
65
|
-
ensure
|
66
|
-
# destroy ec2 instance
|
67
|
-
run_cmd_ec2 "rake destroy[#{vm_name}]"
|
68
|
-
end
|
34
|
+
desc "tests bootstrapping in AWS via vagrant-aws provider"
|
35
|
+
task :test_vagrant_aws_bootstrap do
|
36
|
+
test_vagrant_commands(:aws)
|
69
37
|
end
|
70
38
|
|
71
39
|
|
72
|
-
desc "tests bootstrapping with local Vagrant VMs"
|
73
|
-
task :
|
40
|
+
desc "tests bootstrapping with local Vagrant VMs via default virtualbox provider"
|
41
|
+
task :test_vagrant_vbox_bootstrap do
|
42
|
+
test_vagrant_commands(:vbox)
|
43
|
+
end
|
74
44
|
|
75
|
-
vm_name = 'sample-app'
|
76
45
|
|
46
|
+
def test_vagrant_commands(suffix)
|
77
47
|
begin
|
78
|
-
# resolve deps
|
79
|
-
|
80
|
-
#
|
81
|
-
|
82
|
-
#
|
83
|
-
|
84
|
-
#
|
85
|
-
|
86
|
-
|
48
|
+
# resolve deps and provision node
|
49
|
+
bundle_exec "rake resolve_deps"
|
50
|
+
# create VM
|
51
|
+
run_cmd "vagrant up sample-app-#{suffix} --provider=#{provider(suffix)}"
|
52
|
+
# provision node with app
|
53
|
+
run_cmd "vagrant provision sample-app-#{suffix}"
|
54
|
+
# check ssh
|
55
|
+
run_cmd "vagrant ssh sample-app-#{suffix} -c 'ohai ipaddress'"
|
56
|
+
# check status
|
57
|
+
run_cmd "vagrant status sample-app-#{suffix}"
|
58
|
+
|
87
59
|
# TODO: test if sample app works
|
88
60
|
ensure
|
89
|
-
# destroy
|
90
|
-
|
61
|
+
# destroy
|
62
|
+
run_cmd "vagrant destroy sample-app-#{suffix} -f"
|
91
63
|
end
|
92
64
|
end
|
93
65
|
|
94
|
-
|
95
|
-
|
96
|
-
|
66
|
+
def provider(suffix)
|
67
|
+
providers = {
|
68
|
+
:aws => "aws",
|
69
|
+
:esx => "managed",
|
70
|
+
:vbox => "virtualbox"
|
71
|
+
}
|
72
|
+
providers[suffix]
|
97
73
|
end
|
98
74
|
|
99
|
-
|
100
|
-
|
75
|
+
|
76
|
+
def bundle_exec(command, cwd = "test/vagrant-1.x-bootstrap")
|
77
|
+
fail "need #{cwd}/Gemfile for a clean environment" unless File.exist? "#{cwd}/Gemfile"
|
78
|
+
sh "cd #{cwd} && bundle exec #{command}"
|
101
79
|
end
|
102
80
|
|
103
|
-
def
|
104
|
-
|
81
|
+
def run_cmd(command, cwd = "test/vagrant-1.x-bootstrap")
|
82
|
+
sh "cd #{cwd} && #{command}"
|
105
83
|
end
|
106
84
|
|
107
|
-
def
|
108
|
-
|
109
|
-
|
110
|
-
end
|
85
|
+
def run_cmd_esx(command)
|
86
|
+
run_cmd command, "test/esx_fake"
|
87
|
+
end
|
data/chef-tlc-workflow.gemspec
CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.version = ChefTLCWorkflow::VERSION
|
9
9
|
gem.authors = ["Torben Knerr"]
|
10
10
|
gem.email = ["tkn@zuehlke.com"]
|
11
|
-
gem.description = %q{
|
12
|
-
gem.summary = %q{
|
13
|
-
gem.homepage = ""
|
11
|
+
gem.description = %q{Chef Workflow based on the idea of Top-Level Cookbooks }
|
12
|
+
gem.summary = %q{Chef Workflow based on the idea of Top-Level Cookbooks }
|
13
|
+
gem.homepage = "https://github.com/tknerr/chef-tlc-workflow"
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -28,18 +28,12 @@ Gem::Specification.new do |gem|
|
|
28
28
|
# so that the only dependency one needs in the `Gemfile` is `chef-tlc-workflow`
|
29
29
|
#
|
30
30
|
|
31
|
-
# for interaction with nodes in local/esx/ec2 environments
|
32
|
-
gem.add_dependency 'vagrant', '~> 1.0.5'
|
33
|
-
gem.add_dependency 'knife-solo', '0.3.0.pre4'
|
34
|
-
gem.add_dependency 'mccloud', '0.0.19'
|
35
|
-
|
36
31
|
# testing related
|
37
32
|
gem.add_dependency 'foodcritic', '1.7.0'
|
38
33
|
gem.add_dependency 'chefspec', '0.9.0'
|
39
34
|
gem.add_dependency 'fauxhai', '0.1.1'
|
40
35
|
|
41
36
|
# others
|
42
|
-
gem.add_dependency 'rake', '0.9.6'
|
43
37
|
gem.add_dependency 'sahara', '0.0.13'
|
44
38
|
gem.add_dependency 'knife-solo_data_bag', '0.3.1'
|
45
39
|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#
|
2
|
+
# Vagrantfile simulating an ESX-like environment for testing purposes:
|
3
|
+
#
|
4
|
+
# * assume ssh root access as the only prerequisite
|
5
|
+
# * using bare OS baseboxes with no Chef installed
|
6
|
+
#
|
7
|
+
Vagrant::configure("2") do |config|
|
8
|
+
|
9
|
+
# use provionerless baseboxes
|
10
|
+
config.vm.box = "opscode_ubuntu-13.04_provisionerless"
|
11
|
+
config.vm.box_url = "https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-13.04_provisionerless.box"
|
12
|
+
|
13
|
+
config.vm.define :esx_like_vm do | esx_like_vm_config |
|
14
|
+
|
15
|
+
esx_like_vm_config.vm.provider :virtualbox do |vbox|
|
16
|
+
vbox.customize ["modifyvm", :id,
|
17
|
+
"--memory", "1024",
|
18
|
+
"--name", "chef-tlc-workflow-esx-like-vm"]
|
19
|
+
end
|
20
|
+
esx_like_vm_config.vm.hostname = "chef-tlc-workflow-esx-like-vm.local"
|
21
|
+
esx_like_vm_config.vm.network :private_network, ip: "33.33.77.10"
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# dummy vm in the same network, keeping it on so that no additional
|
26
|
+
# user elevation dialogs appear for the other VMs
|
27
|
+
#
|
28
|
+
config.vm.define :dummy do | dummy_vm_config |
|
29
|
+
|
30
|
+
dummy_vm_config.vm.provider :virtualbox do |vbox|
|
31
|
+
vbox.customize ["modifyvm", :id,
|
32
|
+
"--memory", "256",
|
33
|
+
"--name", "chef-tlc-workflow-dummy-vm"]
|
34
|
+
end
|
35
|
+
dummy_vm_config.vm.hostname = "chef-tlc-workflow-dummy-vm.local"
|
36
|
+
dummy_vm_config.vm.network :private_network, ip: "33.33.77.2"
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'chef-workflow/tasks/tlc/deps'
|
3
|
+
|
4
|
+
desc "resolve application cookbook with all its dependencies"
|
5
|
+
task :resolve_deps, [:app_cookbook] do |t, args|
|
6
|
+
Rake::Task["tlc:deps:resolve_app_cookbook"].invoke(args[:app_cookbook])
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
desc "resolve sample-app"
|
11
|
+
task :resolve_sample_app do
|
12
|
+
Rake::Task["resolve_deps"].invoke("sample-app@0.1.0")
|
13
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
|
2
|
+
def configure_provider(provider, config, config_lambda)
|
3
|
+
config.vm.provider provider do |prvdr, override|
|
4
|
+
config_lambda.call(prvdr, override)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
def vbox_config(name, ip, memory_size = 384)
|
9
|
+
lambda do |vbox, override|
|
10
|
+
# override box url
|
11
|
+
override.vm.box = "opscode_ubuntu-13.04_provisionerless"
|
12
|
+
override.vm.box_url = "https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-13.04_provisionerless.box"
|
13
|
+
# configure host-only network
|
14
|
+
override.vm.hostname = "#{name}.local"
|
15
|
+
override.vm.network :private_network, ip: ip
|
16
|
+
# enable cachier for local vbox vms
|
17
|
+
override.cache.auto_detect = true
|
18
|
+
|
19
|
+
# virtualbox specific configuration
|
20
|
+
vbox.customize ["modifyvm", :id,
|
21
|
+
"--memory", memory_size,
|
22
|
+
"--name", name
|
23
|
+
]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def aws_config(instance_type)
|
28
|
+
lambda do |aws, override|
|
29
|
+
# use dummy box
|
30
|
+
override.vm.box = "aws_dummy_box"
|
31
|
+
override.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box"
|
32
|
+
# override ssh user and private key
|
33
|
+
override.ssh.username = "ubuntu"
|
34
|
+
override.ssh.private_key_path = "#{ENV['HOME']}/.ssh/mccloud_rsa"
|
35
|
+
|
36
|
+
# aws specific settings
|
37
|
+
aws.access_key_id = ENV['AWS_ACCESS_KEY']
|
38
|
+
aws.secret_access_key = ENV['AWS_SECRET_KEY']
|
39
|
+
aws.ami = "ami-524e4726"
|
40
|
+
aws.region = "eu-west-1"
|
41
|
+
aws.availability_zone = "eu-west-1c"
|
42
|
+
aws.instance_type = instance_type
|
43
|
+
aws.security_groups = [ "mccloud", "http" ]
|
44
|
+
aws.keypair_name = "mccloud-key-tlc"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def esx_config(server)
|
49
|
+
lambda do |managed, override|
|
50
|
+
# use dummy box
|
51
|
+
override.vm.box = "managed_dummy_box"
|
52
|
+
override.vm.box_url = "https://github.com/tknerr/vagrant-managed-servers/raw/master/dummy.box"
|
53
|
+
|
54
|
+
# link with this server
|
55
|
+
managed.server = server
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
#
|
60
|
+
# Vagrantfile for testing
|
61
|
+
#
|
62
|
+
# NOTE: you need the following plugins:
|
63
|
+
# - `vagrant plugin install vagrant-aws --plugin-version 0.2.2`
|
64
|
+
# - `vagrant plugin install vagrant-managed-servers --plugin-version 0.1.0`
|
65
|
+
# - `vagrant plugin install vagrant-omnibus --plugin-version 1.0.2`
|
66
|
+
# - `vagrant plugin install vagrant-cachier --plugin-version 0.1.0`
|
67
|
+
#
|
68
|
+
Vagrant::configure("2") do |config|
|
69
|
+
|
70
|
+
# the Chef version to use
|
71
|
+
config.omnibus.chef_version = "11.4.4"
|
72
|
+
|
73
|
+
#
|
74
|
+
# define a separate VMs for the 3 providers (vbox, aws, managed)
|
75
|
+
# because with Vagrant 1.2.2 you can run a VM with only one provider at once
|
76
|
+
#
|
77
|
+
[:aws, :vbox, :esx].each do |provider|
|
78
|
+
#
|
79
|
+
# Sample VM per provider
|
80
|
+
#
|
81
|
+
config.vm.define :"sample-app-#{provider}" do | sample_app_config |
|
82
|
+
|
83
|
+
case provider
|
84
|
+
when :vbox
|
85
|
+
configure_provider(:virtualbox, sample_app_config, vbox_config("sample-app", "33.33.40.10"))
|
86
|
+
when :aws
|
87
|
+
configure_provider(:aws, sample_app_config, aws_config("m1.small"))
|
88
|
+
when :esx
|
89
|
+
configure_provider(:managed, sample_app_config, esx_config("33.33.77.10"))
|
90
|
+
end
|
91
|
+
|
92
|
+
sample_app_config.vm.provision :chef_solo do |chef|
|
93
|
+
chef.cookbooks_path = [ './cookbooks/sample-app-0.1.0' ]
|
94
|
+
chef.add_recipe "sample-app"
|
95
|
+
chef.json = {
|
96
|
+
:sample_app => {
|
97
|
+
:words_of_wisdom => "Vagrant on #{provider} Rocks!"
|
98
|
+
}
|
99
|
+
}
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-tlc-workflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
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: 2013-
|
12
|
+
date: 2013-06-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef-workflow-tasklib
|
@@ -59,54 +59,6 @@ dependencies:
|
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 0.0.1
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: vagrant
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ~>
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 1.0.5
|
70
|
-
type: :runtime
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: 1.0.5
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: knife-solo
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - '='
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: 0.3.0.pre4
|
86
|
-
type: :runtime
|
87
|
-
prerelease: false
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - '='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: 0.3.0.pre4
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: mccloud
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
|
-
requirements:
|
99
|
-
- - '='
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: 0.0.19
|
102
|
-
type: :runtime
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - '='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: 0.0.19
|
110
62
|
- !ruby/object:Gem::Dependency
|
111
63
|
name: foodcritic
|
112
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -155,22 +107,6 @@ dependencies:
|
|
155
107
|
- - '='
|
156
108
|
- !ruby/object:Gem::Version
|
157
109
|
version: 0.1.1
|
158
|
-
- !ruby/object:Gem::Dependency
|
159
|
-
name: rake
|
160
|
-
requirement: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
|
-
requirements:
|
163
|
-
- - '='
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
version: 0.9.6
|
166
|
-
type: :runtime
|
167
|
-
prerelease: false
|
168
|
-
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
|
-
requirements:
|
171
|
-
- - '='
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: 0.9.6
|
174
110
|
- !ruby/object:Gem::Dependency
|
175
111
|
name: sahara
|
176
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -235,8 +171,7 @@ dependencies:
|
|
235
171
|
- - '='
|
236
172
|
- !ruby/object:Gem::Version
|
237
173
|
version: 0.7.2
|
238
|
-
description:
|
239
|
-
Rake tasks embodying the workflow
|
174
|
+
description: ! 'Chef Workflow based on the idea of Top-Level Cookbooks '
|
240
175
|
email:
|
241
176
|
- tkn@zuehlke.com
|
242
177
|
executables: []
|
@@ -249,7 +184,6 @@ files:
|
|
249
184
|
- LICENSE.txt
|
250
185
|
- README.md
|
251
186
|
- Rakefile
|
252
|
-
- Vagrantfile
|
253
187
|
- chef-tlc-workflow.gemspec
|
254
188
|
- docs/ApplicationVsLibraryVsForkedCookbooks.md
|
255
189
|
- docs/TmpLibrarianHelpers.md
|
@@ -260,21 +194,7 @@ files:
|
|
260
194
|
- lib/chef-workflow/tasks/tlc.rb
|
261
195
|
- lib/chef-workflow/tasks/tlc/deps.rb
|
262
196
|
- lib/chef-workflow/tasks/tlc/test.rb
|
263
|
-
- test/
|
264
|
-
- test/ec2-bootstrap/.chef/bootstrap/omnibus-chef.sh
|
265
|
-
- test/ec2-bootstrap/.gitignore
|
266
|
-
- test/ec2-bootstrap/Mccloudfile
|
267
|
-
- test/ec2-bootstrap/Rakefile
|
268
|
-
- test/ec2-bootstrap/app_cookbooks.yml
|
269
|
-
- test/esx-bootstrap/.chef/knife.rb
|
270
|
-
- test/esx-bootstrap/.gitignore
|
271
|
-
- test/esx-bootstrap/Rakefile
|
272
|
-
- test/esx-bootstrap/app_cookbooks.yml
|
273
|
-
- test/esx-bootstrap/nodes/33.33.77.10.json
|
274
|
-
- test/local-bootstrap/.gitignore
|
275
|
-
- test/local-bootstrap/Rakefile
|
276
|
-
- test/local-bootstrap/Vagrantfile
|
277
|
-
- test/local-bootstrap/app_cookbooks.yml
|
197
|
+
- test/esx_fake/Vagrantfile
|
278
198
|
- test/sample-app/CHANGELOG.md
|
279
199
|
- test/sample-app/Cheffile
|
280
200
|
- test/sample-app/README.md
|
@@ -282,7 +202,12 @@ files:
|
|
282
202
|
- test/sample-app/metadata.rb
|
283
203
|
- test/sample-app/recipes/default.rb
|
284
204
|
- test/sample-app/templates/default/sample.html.erb
|
285
|
-
|
205
|
+
- test/vagrant-1.x-bootstrap/.gitignore
|
206
|
+
- test/vagrant-1.x-bootstrap/Gemfile
|
207
|
+
- test/vagrant-1.x-bootstrap/Rakefile
|
208
|
+
- test/vagrant-1.x-bootstrap/Vagrantfile
|
209
|
+
- test/vagrant-1.x-bootstrap/app_cookbooks.yml
|
210
|
+
homepage: https://github.com/tknerr/chef-tlc-workflow
|
286
211
|
licenses: []
|
287
212
|
post_install_message:
|
288
213
|
rdoc_options: []
|
@@ -305,24 +230,9 @@ rubyforge_project:
|
|
305
230
|
rubygems_version: 1.8.24
|
306
231
|
signing_key:
|
307
232
|
specification_version: 3
|
308
|
-
summary:
|
309
|
-
tasks embodying the workflow
|
233
|
+
summary: Chef Workflow based on the idea of Top-Level Cookbooks
|
310
234
|
test_files:
|
311
|
-
- test/
|
312
|
-
- test/ec2-bootstrap/.chef/bootstrap/omnibus-chef.sh
|
313
|
-
- test/ec2-bootstrap/.gitignore
|
314
|
-
- test/ec2-bootstrap/Mccloudfile
|
315
|
-
- test/ec2-bootstrap/Rakefile
|
316
|
-
- test/ec2-bootstrap/app_cookbooks.yml
|
317
|
-
- test/esx-bootstrap/.chef/knife.rb
|
318
|
-
- test/esx-bootstrap/.gitignore
|
319
|
-
- test/esx-bootstrap/Rakefile
|
320
|
-
- test/esx-bootstrap/app_cookbooks.yml
|
321
|
-
- test/esx-bootstrap/nodes/33.33.77.10.json
|
322
|
-
- test/local-bootstrap/.gitignore
|
323
|
-
- test/local-bootstrap/Rakefile
|
324
|
-
- test/local-bootstrap/Vagrantfile
|
325
|
-
- test/local-bootstrap/app_cookbooks.yml
|
235
|
+
- test/esx_fake/Vagrantfile
|
326
236
|
- test/sample-app/CHANGELOG.md
|
327
237
|
- test/sample-app/Cheffile
|
328
238
|
- test/sample-app/README.md
|
@@ -330,3 +240,8 @@ test_files:
|
|
330
240
|
- test/sample-app/metadata.rb
|
331
241
|
- test/sample-app/recipes/default.rb
|
332
242
|
- test/sample-app/templates/default/sample.html.erb
|
243
|
+
- test/vagrant-1.x-bootstrap/.gitignore
|
244
|
+
- test/vagrant-1.x-bootstrap/Gemfile
|
245
|
+
- test/vagrant-1.x-bootstrap/Rakefile
|
246
|
+
- test/vagrant-1.x-bootstrap/Vagrantfile
|
247
|
+
- test/vagrant-1.x-bootstrap/app_cookbooks.yml
|
data/Vagrantfile
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Vagrantfile simulating an ESX-like environment for testing purposes:
|
3
|
-
#
|
4
|
-
# * assume ssh root access as the only prerequisite
|
5
|
-
# * using bare OS baseboxes with no Chef installed
|
6
|
-
#
|
7
|
-
Vagrant::Config.run do |config|
|
8
|
-
|
9
|
-
# use bare os baseboxes
|
10
|
-
config.vm.box = "ubuntu-12.04-server-amd64-bare-os"
|
11
|
-
config.vm.box_url = "http://dl.dropbox.com/u/13494216/ubuntu-12.04-server-amd64-bare-os.box"
|
12
|
-
|
13
|
-
config.vm.define :esx_like_vm do | esx_like_vm_config |
|
14
|
-
esx_like_vm_config.vm.customize ["modifyvm", :id,
|
15
|
-
"--memory", "1024",
|
16
|
-
"--name", "chef-tlc-workflow-esx-like-vm"]
|
17
|
-
esx_like_vm_config.vm.host_name = "chef-tlc-workflow-esx-like-vm.local"
|
18
|
-
esx_like_vm_config.vm.network :hostonly, "33.33.77.10"
|
19
|
-
end
|
20
|
-
|
21
|
-
#
|
22
|
-
# dummy vm in the same network, keeping it on so that no additional
|
23
|
-
# user elevation dialogs appear for the other VMs
|
24
|
-
#
|
25
|
-
config.vm.define :dummy do | dummy_vm_config |
|
26
|
-
dummy_vm_config.vm.customize ["modifyvm", :id,
|
27
|
-
"--memory", "256",
|
28
|
-
"--name", "chef-tlc-workflow-dummy-vm"]
|
29
|
-
dummy_vm_config.vm.host_name = "chef-tlc-workflow-dummy-vm.local"
|
30
|
-
dummy_vm_config.vm.network :hostonly, "33.33.77.2"
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
data/test/Gemfile
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
source :rubygems
|
2
|
-
|
3
|
-
source 'https://gems.gemfury.com/hUe8s8nSyzxs7JMMSZV8/' # vagrant-1.0.5.1
|
4
|
-
source 'https://gems.gemfury.com/psBbdHx94zqZrvxpiVmm/' # librarian-0.0.26.2
|
5
|
-
|
6
|
-
gem "chef-tlc-workflow", "0.1.3",
|
7
|
-
:path => "#{File.dirname(__FILE__)}/../../chef-tlc-workflow"
|
@@ -1,34 +0,0 @@
|
|
1
|
-
#!/bin/bash -ex
|
2
|
-
|
3
|
-
if which curl 2>/dev/null; then
|
4
|
-
HTTP_GET_CMD="curl -L"
|
5
|
-
else
|
6
|
-
HTTP_GET_CMD="wget -qO-"
|
7
|
-
fi
|
8
|
-
|
9
|
-
# read/parse user-data
|
10
|
-
USERDATA=`$HTTP_GET_CMD http://169.254.169.254/latest/user-data`
|
11
|
-
CHEF_VERSION=`echo $USERDATA | tr -s ',' '\n' | grep "chef_version" | cut -d'=' -f2`
|
12
|
-
FQDN=`echo $USERDATA | tr -s ',' '\n' | grep "fqdn" | cut -d'=' -f2`
|
13
|
-
|
14
|
-
# install Chef
|
15
|
-
if [ -z "$CHEF_VERSION" ]; then
|
16
|
-
$HTTP_GET_CMD https://www.opscode.com/chef/install.sh | sudo bash -s
|
17
|
-
else
|
18
|
-
$HTTP_GET_CMD https://www.opscode.com/chef/install.sh | sudo bash -s -- -v $CHEF_VERSION
|
19
|
-
fi
|
20
|
-
|
21
|
-
# set proper hostname
|
22
|
-
if [ "$FQDN" ]; then
|
23
|
-
HOSTNAME=`echo $FQDN | sed -r 's/\..*//'`
|
24
|
-
if [ "`grep "127.0.1.1" /etc/hosts`" ]; then
|
25
|
-
sudo sed -r -i "s/^(127[.]0[.]1[.]1[[:space:]]+).*$/\\1$FQDN $HOSTNAME/" /etc/hosts
|
26
|
-
else
|
27
|
-
sudo sed -r -i "s/^(127[.]0[.]0[.]1[[:space:]]+localhost[[:space:]]*)$/\\1\n127.0.1.1 $FQDN $HOSTNAME/" /etc/hosts
|
28
|
-
fi
|
29
|
-
sudo sed -i "s/.*$/$HOSTNAME/" /etc/hostname
|
30
|
-
sudo hostname -F /etc/hostname
|
31
|
-
fi
|
32
|
-
|
33
|
-
# XXX: ensure that file_cache_path configured in solo.rb exists (Mccloud does not create it)
|
34
|
-
sudo mkdir -p /var/chef-solo
|
@@ -1,60 +0,0 @@
|
|
1
|
-
Mccloud::Config.run do |config|
|
2
|
-
|
3
|
-
# identity / namespace
|
4
|
-
config.mccloud.prefix="mccloud"
|
5
|
-
config.mccloud.environment="tlc"
|
6
|
-
config.mccloud.identity=ENV['USERNAME']
|
7
|
-
|
8
|
-
# define AWS cloud provider for EU-West region
|
9
|
-
config.provider.define "aws-eu-west" do |provider_config|
|
10
|
-
provider_config.provider.flavor = :aws
|
11
|
-
provider_config.provider.options = { }
|
12
|
-
provider_config.provider.region = "eu-west-1"
|
13
|
-
provider_config.provider.check_keypairs = true
|
14
|
-
provider_config.provider.check_security_groups = true
|
15
|
-
provider_config.provider.namespace = "mccloud-tlc-#{ENV['USERNAME']}"
|
16
|
-
end
|
17
|
-
|
18
|
-
# ***********************************************
|
19
|
-
# VM Definitions
|
20
|
-
# ***********************************************
|
21
|
-
|
22
|
-
config.vm.define "sample-app" do |config|
|
23
|
-
|
24
|
-
# official Ubuntu 12.04 AMI
|
25
|
-
config.vm.ami = "ami-524e4726"
|
26
|
-
config.vm.provider= "aws-eu-west"
|
27
|
-
config.vm.flavor = "m1.small"
|
28
|
-
config.vm.zone = "eu-west-1c"
|
29
|
-
config.vm.user = "ubuntu"
|
30
|
-
|
31
|
-
# NOTE: the security groups must exist (e.g. create it beforehand via AWS console)
|
32
|
-
config.vm.security_groups = [ "mccloud", "http" ]
|
33
|
-
|
34
|
-
# see http://fog.io/1.1.2/rdoc/Fog/Compute/AWS/Servers.html
|
35
|
-
# and https://github.com/fog/fog/blob/v1.1.2/lib/fog/aws/requests/compute/run_instances.rb
|
36
|
-
config.vm.create_options = {
|
37
|
-
:user_data => "chef_version=10.18.2-1,fqdn=sample-app.example.com"
|
38
|
-
}
|
39
|
-
|
40
|
-
# NOTE: the keypair (for logging in to the VM) must exist (e.g. create it beforehand via AWS console)
|
41
|
-
config.vm.key_name = "mccloud-key-tlc"
|
42
|
-
config.vm.private_key_path = "#{ENV['HOME']}/.ssh/mccloud_rsa"
|
43
|
-
config.vm.public_key_path = "#{ENV['HOME']}/.ssh/mccloud_rsa.pub"
|
44
|
-
|
45
|
-
# bootstrap template (runs at first-boot only)
|
46
|
-
config.vm.bootstrap = ".chef/bootstrap/omnibus-chef.sh"
|
47
|
-
|
48
|
-
# provisioning sript (runs on each mccloud up or provision)
|
49
|
-
config.vm.provision :chef_solo do |chef|
|
50
|
-
chef.cookbooks_path = [ "cookbooks/sample-app-0.1.0" ]
|
51
|
-
chef.log_level = "info"
|
52
|
-
chef.add_recipe "sample-app"
|
53
|
-
chef.json.merge!({
|
54
|
-
:sample_app => {
|
55
|
-
:words_of_wisdom => "YEAH! I did it for the Lulz!"
|
56
|
-
}
|
57
|
-
})
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
data/test/ec2-bootstrap/Rakefile
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'bundler/setup'
|
2
|
-
require 'fileutils'
|
3
|
-
require 'chef-workflow/tasks/tlc/deps'
|
4
|
-
|
5
|
-
desc "resolve application cookbook with all its dependencies"
|
6
|
-
task :resolve_deps, [:app_cookbook] do |t, args|
|
7
|
-
Rake::Task["tlc:deps:resolve_app_cookbook"].invoke(args[:app_cookbook])
|
8
|
-
end
|
9
|
-
|
10
|
-
desc "bring up the mccloud \"VM\" as configured in the Mccloudfile"
|
11
|
-
task :up, [:vm_name] do |t, args|
|
12
|
-
vm_name = get_required_args(args, :vm_name)
|
13
|
-
sh "mccloud up #{vm_name}"
|
14
|
-
end
|
15
|
-
|
16
|
-
desc "provision the mccloud \"VM\" with the provisioners as defined in the Mccloudfile"
|
17
|
-
task :provision, [:vm_name] do |t, args|
|
18
|
-
vm_name = get_required_args(args, :vm_name)
|
19
|
-
sh "mccloud provision #{vm_name}"
|
20
|
-
end
|
21
|
-
|
22
|
-
desc "destroy the mccloud \"VM\" with the given name"
|
23
|
-
task :destroy, [:vm_name] do |t, args|
|
24
|
-
vm_name = get_required_args(args, :vm_name)
|
25
|
-
sh "mccloud destroy #{vm_name}"
|
26
|
-
end
|
27
|
-
|
28
|
-
desc "ssh into the mccloud \"VM\" with the given name"
|
29
|
-
task :ssh, [:vm_name] do |t, args|
|
30
|
-
vm_name = get_required_args(args, :vm_name)
|
31
|
-
sh "mccloud ssh #{vm_name}"
|
32
|
-
end
|
33
|
-
|
34
|
-
desc "show status of all mccloud \"VMs\" defined in the Mccloudfile"
|
35
|
-
task :status do
|
36
|
-
sh "mccloud status"
|
37
|
-
end
|
38
|
-
|
39
|
-
desc "returns the ip address of the mccloud \"VM\" with the given name"
|
40
|
-
task :get_ip, [:vm_name] do |t, args|
|
41
|
-
vm_name = get_required_args(args, :vm_name)
|
42
|
-
# TODO: filter out IP of given vm rather than printing status for all
|
43
|
-
sh "mccloud status"
|
44
|
-
end
|
45
|
-
|
46
|
-
|
47
|
-
#
|
48
|
-
# helper methods below
|
49
|
-
#
|
50
|
-
def get_required_args(args, *param_keys)
|
51
|
-
param_values = Array.new
|
52
|
-
param_keys.each do |param_key|
|
53
|
-
fail "parameter #{param_key.to_sym} is required" unless args[param_key.to_sym]
|
54
|
-
param_values << args[param_key.to_sym]
|
55
|
-
end
|
56
|
-
param_values.size == 1 ? param_values[0] : param_values
|
57
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# knife configuration that is honored by knife-solo, see
|
3
|
-
# https://github.com/matschaffer/knife-solo/wiki/Upgrading-to-0.3.0
|
4
|
-
#
|
5
|
-
log_level :info
|
6
|
-
log_location STDOUT
|
7
|
-
data_bag_path "data_bags"
|
8
|
-
encrypted_data_bag_secret "data_bag_key"
|
9
|
-
role_path "roles"
|
10
|
-
cookbook_path "cookbooks/#{ENV['CURRENT_APP_COOKBOOK']}"
|
data/test/esx-bootstrap/Rakefile
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'bundler/setup'
|
2
|
-
require 'fileutils'
|
3
|
-
require 'chef-workflow/tasks/tlc/deps'
|
4
|
-
require 'chef-tlc-workflow/helpers'
|
5
|
-
|
6
|
-
desc "resolve application cookbook with all its dependencies"
|
7
|
-
task :resolve_deps, [:app_cookbook] do |t, args|
|
8
|
-
Rake::Task["tlc:deps:resolve_app_cookbook"].invoke(args[:app_cookbook])
|
9
|
-
end
|
10
|
-
|
11
|
-
desc "bootstrap a server with Chef, does not provision (will ask for password if no key provided)"
|
12
|
-
task :bootstrap, [:host, :user, :ssh_key] do |t, args|
|
13
|
-
host, user = get_required_args(args, :host, :user)
|
14
|
-
sh "knife solo prepare #{user}@#{host} #{ssh_key_cmdline(args)} --bootstrap-version 10.18.2-1 --no-librarian -V"
|
15
|
-
end
|
16
|
-
|
17
|
-
desc "provision a server with data from `nodes/<host>.json` (will ask for password if no key provided)"
|
18
|
-
task :provision, [:app_cookbook, :host, :user, :ssh_key] do |t, args|
|
19
|
-
app_cookbook, host, user = get_required_args(args, :app_cookbook, :host, :user)
|
20
|
-
name, version = ChefTLCWorkflow::Helpers::parse_name_and_version(args[:app_cookbook])
|
21
|
-
with_app "#{name}-#{version}" do
|
22
|
-
sh "knife solo cook #{user}@#{host} #{ssh_key_cmdline(args)} --no-chef-check --no-librarian -V"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
desc "remove Chef-solo cookbook traces from the server (will ask for password if no key provided)"
|
27
|
-
task :cleanup, [:host, :user, :ssh_key] do |t, args|
|
28
|
-
host, user = get_required_args(args, :host, :user)
|
29
|
-
sh "knife solo clean #{user}@#{host} #{ssh_key_cmdline(args)} -V"
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
#
|
34
|
-
# helper methods below
|
35
|
-
#
|
36
|
-
def get_required_args(args, *param_keys)
|
37
|
-
param_values = Array.new
|
38
|
-
param_keys.each do |param_key|
|
39
|
-
fail "parameter #{param_key.to_sym} is required" unless args[param_key.to_sym]
|
40
|
-
param_values << args[param_key.to_sym]
|
41
|
-
end
|
42
|
-
param_values
|
43
|
-
end
|
44
|
-
|
45
|
-
def ssh_key_cmdline(args)
|
46
|
-
args[:ssh_key] ? "-i #{args[:ssh_key]}" : ""
|
47
|
-
end
|
48
|
-
|
49
|
-
#
|
50
|
-
# sets the 'CURRENT_APP_COOKBOOK' env var while the block executes, which is used in
|
51
|
-
# `.chef/knife.rb` for correctly setting the `cookbook_path` for the given app cookbook
|
52
|
-
#
|
53
|
-
def with_app(app_cookbook)
|
54
|
-
ENV['CURRENT_APP_COOKBOOK'] = app_cookbook
|
55
|
-
yield
|
56
|
-
ensure
|
57
|
-
ENV['CURRENT_APP_COOKBOOK'] = ""
|
58
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
|
2
|
-
- name: "sample-app"
|
3
|
-
version: "0.1.0"
|
4
|
-
path: "../sample-app"
|
5
|
-
# git: "https://github.com/tknerr/sample-app-tlc.git"
|
6
|
-
# ref: "v0.1.0"
|
7
|
-
|
8
|
-
- name: "sample-app"
|
9
|
-
version: "0.2.0"
|
10
|
-
path: "../sample-app"
|
11
|
-
# git: "https://github.com/tknerr/sample-app-tlc.git"
|
12
|
-
# ref: "v0.2.0"
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'bundler/setup'
|
2
|
-
require 'fileutils'
|
3
|
-
require 'chef-workflow/tasks/tlc/deps'
|
4
|
-
|
5
|
-
desc "resolve application cookbook with all its dependencies"
|
6
|
-
task :resolve_deps, [:app_cookbook] do |t, args|
|
7
|
-
Rake::Task["tlc:deps:resolve_app_cookbook"].invoke(args[:app_cookbook])
|
8
|
-
end
|
9
|
-
|
10
|
-
desc "bring up the vagrant \"VM\" as configured in the Vagrantfile"
|
11
|
-
task :up, [:vm_name] do |t, args|
|
12
|
-
vm_name = get_required_args(args, :vm_name)
|
13
|
-
sh "vagrant up #{vm_name}"
|
14
|
-
end
|
15
|
-
|
16
|
-
desc "provision the vagrant \"VM\" with the provisioners as defined in the Vagrantfile"
|
17
|
-
task :provision, [:vm_name] do |t, args|
|
18
|
-
vm_name = get_required_args(args, :vm_name)
|
19
|
-
sh "vagrant provision #{vm_name}"
|
20
|
-
end
|
21
|
-
|
22
|
-
desc "destroy the vagrant \"VM\" with the given name"
|
23
|
-
task :destroy, [:vm_name] do |t, args|
|
24
|
-
vm_name = get_required_args(args, :vm_name)
|
25
|
-
sh "vagrant destroy #{vm_name} -f"
|
26
|
-
end
|
27
|
-
|
28
|
-
desc "ssh into the vagrant \"VM\" with the given name"
|
29
|
-
task :ssh, [:vm_name] do |t, args|
|
30
|
-
vm_name = get_required_args(args, :vm_name)
|
31
|
-
sh "vagrant ssh #{vm_name}"
|
32
|
-
end
|
33
|
-
|
34
|
-
desc "show status of all vagrant \"VMs\" defined in the Vagrantfile"
|
35
|
-
task :status do
|
36
|
-
sh "vagrant status"
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
#
|
41
|
-
# helper methods below
|
42
|
-
#
|
43
|
-
def get_required_args(args, *param_keys)
|
44
|
-
param_values = Array.new
|
45
|
-
param_keys.each do |param_key|
|
46
|
-
fail "parameter #{param_key.to_sym} is required" unless args[param_key.to_sym]
|
47
|
-
param_values << args[param_key.to_sym]
|
48
|
-
end
|
49
|
-
param_values.size == 1 ? param_values[0] : param_values
|
50
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Vagrantfile for testing
|
3
|
-
#
|
4
|
-
Vagrant::Config.run do |config|
|
5
|
-
|
6
|
-
# default base box for all VMs
|
7
|
-
config.vm.box = "opscode-ubuntu-12.04"
|
8
|
-
config.vm.box_url = "https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_chef-10.18.2.box"
|
9
|
-
|
10
|
-
# sample-app
|
11
|
-
config.vm.define :'sample-app' do | sample_app_config |
|
12
|
-
sample_app_config.vm.customize ["modifyvm", :id,
|
13
|
-
"--memory", "384",
|
14
|
-
"--name", "sample-app.local"
|
15
|
-
]
|
16
|
-
sample_app_config.vm.host_name = "sample-app.local"
|
17
|
-
sample_app_config.vm.network :hostonly, "33.33.40.10"
|
18
|
-
|
19
|
-
sample_app_config.vm.provision :chef_solo do |chef|
|
20
|
-
chef.cookbooks_path = [ './cookbooks/sample-app-0.1.0' ]
|
21
|
-
chef.add_recipe "sample-app"
|
22
|
-
chef.json = {
|
23
|
-
:sample_app => {
|
24
|
-
:words_of_wisdom => 'AWESOMENESS - When i feel sad, i stop being sad and be awesome instead.'
|
25
|
-
}
|
26
|
-
}
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
@@ -1,12 +0,0 @@
|
|
1
|
-
|
2
|
-
- name: "sample-app"
|
3
|
-
version: "0.1.0"
|
4
|
-
path: "../sample-app"
|
5
|
-
# git: "https://github.com/tknerr/sample-app-tlc.git"
|
6
|
-
# ref: "v0.1.0"
|
7
|
-
|
8
|
-
- name: "sample-app"
|
9
|
-
version: "0.2.0"
|
10
|
-
path: "../sample-app"
|
11
|
-
# git: "https://github.com/tknerr/sample-app-tlc.git"
|
12
|
-
# ref: "v0.2.0"
|