cuoco 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +12 -0
- data/README.md +24 -5
- data/cuoco.gemspec +2 -1
- data/lib/cuoco/bootstrapper.rb +13 -2
- data/lib/cuoco/capistrano.rb +10 -0
- data/lib/cuoco/uploader.rb +4 -1
- data/lib/cuoco/version.rb +1 -1
- metadata +20 -3
data/CHANGELOG.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 0.0.2 - 2012-09-03
|
4
|
+
|
5
|
+
* added option to pass data from Capistrano to Chef;
|
6
|
+
* added option to use an arbitrary custom bootstrap script instead of Omnibus;
|
7
|
+
* reset Capistrano sessions after a Chef run to refresh configuration;
|
8
|
+
* fix issue with Omnibus not working on a bare Ubuntu box without `curl`;
|
9
|
+
|
10
|
+
## 0.0.1 - 2012-09-03
|
11
|
+
|
12
|
+
Initial release
|
data/README.md
CHANGED
@@ -10,11 +10,11 @@
|
|
10
10
|
|
11
11
|
*Capistrano and Chef Solo, sitting in a tree...*
|
12
12
|
|
13
|
-
[Capistrano](https://github.com/capistrano/capistrano#capistrano) is a framework that allows you to run commands in parallel on multiple remote machines.
|
13
|
+
[Capistrano](https://github.com/capistrano/capistrano#capistrano) is a framework that allows you to run commands in parallel on multiple remote machines. Its primary use is application deployment, but Capistrano can automate any task you can do over SSH. A big advantage of Capistrano is that it is wildly popular among web developers, and thus well supported and rich with plugins.
|
14
14
|
|
15
15
|
Another common task you have to do on the remote machines is server provisioning/management, and Capistrano has no facilities for that. It's definitely possible to manage machines using Capistrano, but you have to bring your own scripts.
|
16
16
|
|
17
|
-
[Chef Solo](http://wiki.opscode.com/display/chef/Chef+Solo) is a tool that uses well-structured, data-driven Ruby scripts to describe and run configuration management routines. It
|
17
|
+
[Chef Solo](http://wiki.opscode.com/display/chef/Chef+Solo) is a tool that uses well-structured, data-driven Ruby scripts to describe and run configuration management routines. It manages the machine it's running from. So before running Chef Solo on a remote machine, you have to install it there and upload your scripts to that machine. You can do that by hand, you can use one of the many Chef Solo bootstrap scripts, or you can use some tool like littlechef, which needs to be configured to know about your servers.
|
18
18
|
|
19
19
|
But wait - not only Capistrano knows where your servers are, it can already run commands on them, and in parallel. It's exactly what Chef Solo is lacking.
|
20
20
|
|
@@ -34,7 +34,7 @@ To make Cuoco tasks available in Capistrano, require this file in your `Capfile`
|
|
34
34
|
|
35
35
|
### Fully automatic mode
|
36
36
|
|
37
|
-
Cuoco can turn a completely bare machine into a live server with a single command. You buy servers, you declare them in Capistrano, you run `cap deploy:setup
|
37
|
+
Cuoco can turn a completely bare machine into a live server with a single command. You buy servers, you declare them in Capistrano, you run `cap deploy:setup deploy`. Done! [*]
|
38
38
|
|
39
39
|
To do so, require this file in your `Capfile` or `config/deploy.rb`.
|
40
40
|
|
@@ -65,11 +65,20 @@ If application deployment doesn't apply in your scenario, you can just run
|
|
65
65
|
|
66
66
|
directly.
|
67
67
|
|
68
|
+
### Custom bootstrap scripts
|
69
|
+
|
70
|
+
**As of September 2, 2012 the [pg gem fails to compile on Chef installed with the default bootstrap script](http://tickets.opscode.com/browse/COOK-1406).**
|
71
|
+
|
72
|
+
You can replace the Omnibus installation script with any other, like [this one](https://gist.github.com/3601146) I wrote for Ubuntu 12.04, by setting the `:chef_install_command` variable:
|
73
|
+
|
74
|
+
set :chef_install_command, 'wget -q -O - https://raw.github.com/gist/3601146/install_chef_ubuntu_precise.sh | sudo bash'
|
75
|
+
|
68
76
|
## Minimal requirements for remote machines
|
69
77
|
|
70
78
|
Here are the minimal requirements for running Cuoco:
|
71
79
|
|
72
80
|
* the server is running [one of the operating systems supported by Omnibus](http://wiki.opscode.com/display/chef/Installing+Omnibus+Chef+Client+on+Linux+and+Mac#InstallingOmnibusChefClientonLinuxandMac-TestedOperatingSystems) (most flavors of Linux will do);
|
81
|
+
* the server has `sudo`, `bash` and either `curl` or `wget` installed (most Linux servers do);
|
73
82
|
* Capistrano can connect to the server;
|
74
83
|
* the Capistrano user has sudo rights on the server. See [my article on setting up user accounts](http://leonid.shevtsov.me/en/how-to-set-up-user-accounts-on-your-web-server) for the suggested approach.
|
75
84
|
|
@@ -92,7 +101,17 @@ The chef roles directory *must* contain a role file for every Capistrano role yo
|
|
92
101
|
|
93
102
|
### Variables
|
94
103
|
|
95
|
-
|
104
|
+
You can pass data into chef by declaring a `:chef_data` variable
|
105
|
+
|
106
|
+
set :chef_data, {
|
107
|
+
:myapp => {
|
108
|
+
:path => deploy_to
|
109
|
+
}
|
110
|
+
}
|
111
|
+
|
112
|
+
The hash gets passed to Chef as if it was specified on the command line with `chef-solo -j chef_data.json`.
|
113
|
+
|
114
|
+
This approach is very simplistic and not very DRY, so I'm planning to expand on variables in further releases.
|
96
115
|
|
97
116
|
### Environments
|
98
117
|
|
@@ -102,7 +121,7 @@ TODO Environments are not supported by Chef Solo. It would be nice to provide th
|
|
102
121
|
|
103
122
|
"Cuoco" means "cook" in Italian. The original [Capistrano is a city in Italy](https://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=Capistrano,+Vibo+Valentia,+Italy&aq=0&oq=capistrano,+italy&sll=37.0625,-95.677068&sspn=60.376022,135.263672&vpsrc=0&t=h&ie=UTF8&hq=&hnear=Capistrano,+Province+of+Vibo+Valentia,+Calabria,+Italy&z=16). So a chef working solo in Capistrano would be called *un cuoco*... get it now?
|
104
123
|
|
105
|
-
(If you've been expecting to see Kaley Cuoco here, I'll save you a trip to
|
124
|
+
(If you've been expecting to see Kaley Cuoco here, I'll save you a trip to Google:)
|
106
125
|
|
107
126
|
![Another Cuoco](http://i.imgur.com/u5OIil.jpg)
|
108
127
|
|
data/cuoco.gemspec
CHANGED
data/lib/cuoco/bootstrapper.rb
CHANGED
@@ -3,7 +3,7 @@ module Cuoco
|
|
3
3
|
BOOTSTRAP_COMMAND = "\
|
4
4
|
if ! command -v chef-solo &>/dev/null;\
|
5
5
|
then\
|
6
|
-
|
6
|
+
INSTALL_COMMAND;
|
7
7
|
if ! command -v chef-solo &>/dev/null;\
|
8
8
|
then\
|
9
9
|
false;\
|
@@ -15,12 +15,23 @@ module Cuoco
|
|
15
15
|
fi\
|
16
16
|
".gsub(/ +/,' ')
|
17
17
|
|
18
|
+
DEFAULT_INSTALL_COMMAND = "
|
19
|
+
if command -v curl &>/dev/null;
|
20
|
+
then
|
21
|
+
curl -L http://opscode.com/chef/install.sh | sudo -p \"sudo password: \" bash;\
|
22
|
+
else
|
23
|
+
wget -q -O - http://opscode.com/chef/install.sh | sudo -p \"sudo password: \" bash;\
|
24
|
+
fi\
|
25
|
+
"
|
26
|
+
|
18
27
|
def initialize(capistrano)
|
19
28
|
@cap = capistrano
|
29
|
+
|
30
|
+
@install_command = @cap.fetch(:chef_install_command, DEFAULT_INSTALL_COMMAND)
|
20
31
|
end
|
21
32
|
|
22
33
|
def bootstrap
|
23
|
-
@cap.run(BOOTSTRAP_COMMAND, :shell => '/bin/bash')
|
34
|
+
@cap.run(BOOTSTRAP_COMMAND.gsub('INSTALL_COMMAND', @install_command), :shell => '/bin/bash')
|
24
35
|
end
|
25
36
|
end
|
26
37
|
end
|
data/lib/cuoco/capistrano.rb
CHANGED
@@ -6,6 +6,7 @@ require 'cuoco'
|
|
6
6
|
task :update_configuration do
|
7
7
|
bootstrap
|
8
8
|
run_roles
|
9
|
+
restart_sessions
|
9
10
|
end
|
10
11
|
|
11
12
|
desc "Sets up Chef on remote server"
|
@@ -40,5 +41,14 @@ require 'cuoco'
|
|
40
41
|
runner = Cuoco::Runner.new(self)
|
41
42
|
runner.run_list( list )
|
42
43
|
end
|
44
|
+
|
45
|
+
task :restart_sessions do
|
46
|
+
logger.info "Cuoco: restarting sessions"
|
47
|
+
sessions.each do |key, session|
|
48
|
+
logger.info "Closing: #{key}"
|
49
|
+
session.close
|
50
|
+
end
|
51
|
+
sessions.clear
|
52
|
+
end
|
43
53
|
end
|
44
54
|
end
|
data/lib/cuoco/uploader.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'json'
|
1
2
|
require 'cuoco/config_generator'
|
2
3
|
|
3
4
|
module Cuoco
|
@@ -7,6 +8,7 @@ module Cuoco
|
|
7
8
|
@cap = capistrano
|
8
9
|
|
9
10
|
@chef_path = File.expand_path(@cap.fetch(:chef_path, 'config/chef'))
|
11
|
+
@node_data = @cap.fetch(:chef_data, {})
|
10
12
|
|
11
13
|
@cuoco_remote_path = '/tmp/cuoco'
|
12
14
|
end
|
@@ -20,6 +22,7 @@ module Cuoco
|
|
20
22
|
|
21
23
|
def prepare_directory_structure
|
22
24
|
@cap.run("mkdir -p #{@cuoco_remote_path}", :shell => '/bin/bash')
|
25
|
+
@cap.sudo("mkdir -p /etc/chef", :shell => '/bin/bash')
|
23
26
|
end
|
24
27
|
|
25
28
|
def upload_chef_config
|
@@ -35,7 +38,7 @@ module Cuoco
|
|
35
38
|
end
|
36
39
|
|
37
40
|
def upload_node_json
|
38
|
-
@cap.put(
|
41
|
+
@cap.put(@node_data.to_json, @cuoco_remote_path+'/node.json')
|
39
42
|
end
|
40
43
|
end
|
41
44
|
end
|
data/lib/cuoco/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuoco
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '2'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: json
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: rake
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -51,6 +67,7 @@ extensions: []
|
|
51
67
|
extra_rdoc_files: []
|
52
68
|
files:
|
53
69
|
- .gitignore
|
70
|
+
- CHANGELOG.md
|
54
71
|
- Gemfile
|
55
72
|
- LICENSE
|
56
73
|
- README.md
|
@@ -79,7 +96,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
79
96
|
version: '0'
|
80
97
|
segments:
|
81
98
|
- 0
|
82
|
-
hash: -
|
99
|
+
hash: -893324196147809541
|
83
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
101
|
none: false
|
85
102
|
requirements:
|
@@ -88,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
105
|
version: '0'
|
89
106
|
segments:
|
90
107
|
- 0
|
91
|
-
hash: -
|
108
|
+
hash: -893324196147809541
|
92
109
|
requirements: []
|
93
110
|
rubyforge_project:
|
94
111
|
rubygems_version: 1.8.24
|