Merge lp:~pavel-pachkovskij/charms/precise/rack/trunk into lp:~mark-mims/charms/precise/rack/trunk

Proposed by Mark Mims
Status: Merged
Approved by: Mark Mims
Approved revision: 14
Merged at revision: 10
Proposed branch: lp:~pavel-pachkovskij/charms/precise/rack/trunk
Merge into: lp:~mark-mims/charms/precise/rack/trunk
Diff against target: 3362 lines (+2250/-513)
84 files modified
README.md (+277/-102)
config.yaml (+29/-33)
cookbooks/juju/definitions/juju_port.rb (+11/-0)
cookbooks/juju/definitions/relation_set.rb (+7/-0)
cookbooks/juju/libraries/juju.rb (+32/-0)
cookbooks/juju/libraries/juju/juju_helpers.rb (+45/-0)
cookbooks/juju/libraries/juju/ruby_helpers.rb (+38/-0)
cookbooks/juju/metadata.rb (+8/-0)
cookbooks/juju/recipes/bootstrap.rb (+2/-0)
cookbooks/memcached-relation/metadata.rb (+9/-0)
cookbooks/memcached-relation/recipes/broken.rb (+14/-0)
cookbooks/memcached-relation/recipes/changed.rb (+30/-0)
cookbooks/mongodb-relation/metadata.rb (+9/-0)
cookbooks/mongodb-relation/recipes/broken.rb (+14/-0)
cookbooks/mongodb-relation/recipes/changed.rb (+31/-0)
cookbooks/mysql-relation/metadata.rb (+9/-0)
cookbooks/mysql-relation/recipes/broken.rb (+14/-0)
cookbooks/mysql-relation/recipes/changed.rb (+31/-0)
cookbooks/mysql-relation/recipes/joined.rb (+3/-0)
cookbooks/nagios-relation/metadata.rb (+7/-0)
cookbooks/nagios-relation/recipes/joined.rb (+22/-0)
cookbooks/nginx/definitions/nginx_site.rb (+18/-0)
cookbooks/nginx/metadata.rb (+7/-0)
cookbooks/nginx/recipes/default.rb (+9/-0)
cookbooks/nginx/templates/default/site.conf.erb (+39/-0)
cookbooks/nodejs/metadata.rb (+7/-0)
cookbooks/nodejs/recipes/default.rb (+17/-0)
cookbooks/nrpe-relation/recipes/joined.rb (+1/-0)
cookbooks/postgresql-relation/metadata.rb (+9/-0)
cookbooks/postgresql-relation/recipes/broken.rb (+14/-0)
cookbooks/postgresql-relation/recipes/changed.rb (+31/-0)
cookbooks/postgresql-relation/recipes/joined.rb (+3/-0)
cookbooks/proxy-relation/metadata.rb (+8/-0)
cookbooks/proxy-relation/recipes/joined.rb (+15/-0)
cookbooks/rack/attributes/default.rb (+8/-0)
cookbooks/rack/definitions/bundle.rb (+50/-0)
cookbooks/rack/definitions/executables.rb (+29/-0)
cookbooks/rack/definitions/extra_packages.rb (+11/-0)
cookbooks/rack/definitions/rake_task.rb (+11/-0)
cookbooks/rack/definitions/scm_provider.rb (+38/-0)
cookbooks/rack/files/default/database.yml (+53/-0)
cookbooks/rack/files/default/wrap-ssh.sh (+2/-0)
cookbooks/rack/metadata.rb (+10/-0)
cookbooks/rack/providers/envfile.rb (+83/-0)
cookbooks/rack/providers/procfile.rb (+39/-0)
cookbooks/rack/recipes/config-changed.rb (+17/-0)
cookbooks/rack/recipes/deploy.rb (+84/-0)
cookbooks/rack/recipes/install.rb (+45/-0)
cookbooks/rack/recipes/start.rb (+5/-0)
cookbooks/rack/recipes/stop.rb (+5/-0)
cookbooks/rack/resources/envfile.rb (+8/-0)
cookbooks/rack/resources/procfile.rb (+11/-0)
cookbooks/rack/templates/default/bin/restart.erb (+3/-0)
cookbooks/rack/templates/default/bin/run.erb (+4/-0)
cookbooks/redis-relation/metadata.rb (+8/-0)
cookbooks/redis-relation/recipes/broken.rb (+14/-0)
cookbooks/redis-relation/recipes/changed.rb (+28/-0)
files/resque_example.yml (+0/-1)
hooks/Gemfile (+5/-0)
hooks/Gemfile.lock (+72/-0)
hooks/bootstrap (+28/-0)
hooks/common.sh (+0/-109)
hooks/god-relation-joined (+0/-12)
hooks/install (+5/-57)
hooks/mongoid-relation-changed (+0/-35)
hooks/mongoid-relation-joined (+0/-7)
hooks/mysql-relation-broken (+0/-9)
hooks/mysql-relation-changed (+0/-25)
hooks/mysql-relation-joined (+0/-7)
hooks/postgresql-relation-broken (+0/-9)
hooks/postgresql-relation-changed (+0/-25)
hooks/postgresql-relation-joined (+0/-10)
hooks/rack-server-relation-joined (+0/-7)
hooks/resque-relation-changed (+0/-18)
hooks/resque-relation-joined (+0/-14)
hooks/rvm-installer.sh (+620/-0)
hooks/start (+0/-8)
hooks/stop (+0/-7)
hooks/stub (+18/-0)
metadata.yaml (+19/-17)
revision (+1/-1)
tests/100_deploy.test (+49/-0)
tests/get-unit-info (+45/-0)
tests/html2haml.yml (+2/-0)
To merge this branch: bzr merge lp:~pavel-pachkovskij/charms/precise/rack/trunk
Reviewer Review Type Date Requested Status
Mark Mims Approve
Review via email: mp+179721@code.launchpad.net

Description of the change

moving this from the bug https://bugs.launchpad.net/charms/+bug/1205002 into a real MP

To post a comment you must log in.
Revision history for this message
Mark Mims (mark-mims) wrote :

Hey Pavel,

I have a couple of changes I'd like to see, but I'll file these as bug reports against the charm once we get these changes merged.

Before merging this one, could you please embed wayne's script into the bootstrap process rather than just `curl -L https://get.rvm.io | bash -s stable --ruby` please? I know this introduces some versioning issues, but it keeps the complete installation process under revision control.

I might do this myself later this week if you're still on vacation... I don't remember when you're back.

Thanks!
Mark

review: Needs Fixing
11. By Pavel Pachkovskij

fix config default value bug

12. By Pavel Pachkovskij

fix code formatting in README.md

13. By Pavel Pachkovskij

fix code formatting in README.md

14. By Pavel Pachkovskij

add rvm-installer, move cookbooks to CHARM_DIR

Revision history for this message
Mark Mims (mark-mims) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README.md'
2--- README.md 2013-03-01 11:10:06 +0000
3+++ README.md 2013-08-21 10:46:51 +0000
4@@ -1,108 +1,283 @@
5-## Overview
6-
7-Rack applications subordinate [Juju Charm](http://jujucharms.com/). Works only when related to appropriate web-server.
8-
9-## Usage
10-
11-You can use any of available web servers, which provides rack container. Currently available:
12-
13-- [apache2-passenger](http://jujucharms.com/charms/precise/apache2-passenger)
14-- [nginx-passenger](http://jujucharms.com/charms/precise/nginx-passenger)
15-
16-All examples will use **apache2-passenger**, but you can choose any.
17-
18-### Rails 3 example
19-
20-1. Deploy web-server
21-
22- juju deploy apache2-passenger
23-
24-2. Deploy Rack application (see configuration section below)
25-
26- juju deploy rack --config myapp.yml
27-
28-3. Relate them
29-
30- juju add-relation rack apache2-passenger
31-
32-4. Deploy and relate database
33-
34- juju deploy mysql
35- juju add-relation mysql rack
36-
37-5. Open the stack up to the outside world.
38-
39- juju expose apache2-passenger
40-
41-6. Find the apache2-passenger instance's public URL from
42-
43- juju status
44-
45-#### PostgreSQL setup
46-
47-On a step 4 run
48+# Overview
49+
50+Rack provides a minimal, modular and adaptable interface for developing web applications in Ruby. This Charm will deploy Ruby on Rails, Sinatra or any other Rack application and connect it to supported services.
51+
52+# Usage
53+
54+To deploy this charm you will need at a minimum: a cloud environment, working Juju installation and a successful bootstrap. Once bootstrapped, deploy Rack charm and all required services.
55+
56+## Ruby on Rails example
57+
58+Configure your application, for example:
59+
60+**sample-rails.yml**
61+
62+ sample-rails:
63+ repo: https://github.com/pavelpachkovskij/sample-rails
64+
65+Deploy Rack application:
66+
67+ juju deploy rack sample-rails --config sample-rails.yml
68+
69+Deploy and relate database
70
71 juju deploy postgresql
72- juju add-relation postgresql:db rack
73-
74-#### Mongodb setup
75-
76-If you use Mongodb with Mongoid then on a step 4 you should run
77+ juju add-relation postgresql:db sample-rails
78+
79+Now you can run migrations:
80+
81+ juju ssh sample-rails/0 run rake db:migrate
82+
83+Seed database
84+
85+ juju ssh sample-rails/0 run rake db:seed
86+
87+And finally expose the Rack service:
88+
89+ juju expose rack
90+
91+Find the Rack instance's public URL from
92+
93+ juju status
94+
95+### MySQL setup
96+
97+ juju deploy mysql
98+ juju add-relation mysql rack
99+
100+## Sinatra example
101+
102+Configure your application, for example html2haml
103+
104+**html2haml.yml**
105+
106+ html2haml:
107+ repo: https://github.com/twilson63/html2haml.git
108+
109+Deploy your Rack service
110+
111+ juju deploy rack html2haml --config html2haml.yml
112+
113+Expose Rack service:
114+
115+ juju expose html2haml
116+
117+## Source code updates
118+
119+ juju set <service_name> revision=<revision>
120+
121+## Executing commands
122+
123+ juju ssh <unit_name> run <command>
124+
125+## Restart application
126+
127+ juju ssh <unit_name> sudo restart rack
128+
129+## Foreman integration
130+
131+You can add Procfile to your application and Rack to start additional processes or replace default application server:
132+
133+Example Procfile:
134+
135+ web: bundle exec unicorn -p $PORT
136+ watcher: bundle exec rake watch
137+
138+## Specifying a Ruby Version
139+
140+You can use the ruby keyword of your app's Gemfile to specify a particular version of Ruby.
141+
142+ source "https://rubygems.org"
143+ ruby "1.9.3"
144+
145+# Horizontal scaling
146+
147+Juju makes it easy to scale your Rack application. You can simply deploy any supported load balancer, add relation and launch any number of application instances.
148+
149+## HAProxy
150+
151+ juju deploy rack rack --config rack.yml
152+ juju deploy haproxy
153+ juju add-relation haproxy rack
154+ juju expose haproxy
155+ juju add-unit rack -n 2
156+
157+## Apache2
158+
159+Apache2 is harder to start with, but it provides more flexibility with configuration options.
160+Here is a quick example of using Apache2 as a load balancer with your rack application:
161+
162+Deploy Rack application
163+
164+ juju deploy rack --config rack.yml
165+
166+You have to enable mod_proxy_balancer and mod_proxy_http modules in your Apache2 config:
167+
168+**apache2.yml** example
169+
170+ apache2:
171+ enable_modules: proxy_balancer proxy_http
172+
173+Deploy Apache2
174+
175+ juju deploy apache2 --config apache2.yml
176+
177+Create balancer relation between Apache2 and Rack application
178+
179+ juju add-relation apache2:balancer rack
180+
181+Apache2 charm expects a template to be passed in. Example of vhost that will balance all traffic over your application instances:
182+
183+**vhost.tmpl**
184+
185+ <VirtualHost *:80>
186+ ServerName rack
187+ ProxyPass / balancer://rack/ lbmethod=byrequests stickysession=BALANCEID
188+ ProxyPassReverse / balancer://rack/
189+ </VirtualHost>
190+
191+Update Apache2 service config with this template
192+
193+juju set apache2 "vhost_http_template=$(base64 < vhost.tmpl)"
194+
195+Expose Apache2 service
196+
197+ juju expose apache2
198+
199+# Logging with Logstash
200+
201+You can add logstash service to collect information from application's logs and Kibana application to visualize this data.
202+
203+ juju deploy kibana
204+ juju deploy logstash-indexer
205+ juju add-relation kibana logstash-indexer:rest
206+
207+ juju deploy logstash-agent
208+ juju add-relation logstash-agent logstash-indexer
209+ juju add-relation logstash-agent rack
210+ juju set logstash-agent CustomLogFile="['/var/www/rack/current/log/*.log']" CustomLogType="rack"
211+ juju expose kibana
212+
213+# Monitoring with Nagios and NRPE
214+
215+You can can perform HTTP checks with Nagios. To do this deploy Nagios and relate it to your Rack application:
216+
217+ juju deploy nagios
218+ juju add-relation rack nagios
219+
220+Additionally you can perform disk, mem, and swap checks with NRPE extension:
221+
222+ juju deploy nrpe
223+ juju add-relation rack nrpe
224+ juju add-relation nrpe nagios
225+
226+# MongoDB relation
227+
228+Deploy MonogDB service and relate it to Rack application:
229
230 juju deploy mongodb
231 juju add-relation mongodb rack
232
233-#### Resque setup
234-
235-Coming soon...
236-
237-### Sinatra example
238-
239-1. Deploy web-server
240-
241- juju deploy apache2-passenger
242-
243-2. Configure your application, for example html2haml
244-
245- **html2haml.yml**
246-
247- html2haml:
248- repo_url: https://github.com/twilson63/html2haml.git
249- app_name: html2haml
250-
251-3. Deploy your application with Rack Charm
252-
253- juju deploy rack html2haml --config html2haml.yml
254-
255-4. Relate it to web-server
256-
257- juju add-relation html2haml apache2-passenger
258-
259-5. Open the stack up to the outside world.
260-
261- juju expose apache2-passenger
262-
263-## Configuration
264-
265-Here is an example configuration for Rails 3 installation from svn trunk. Additionally it will install imagemagick package.
266-
267- rails:
268- repo_type: svn
269- repo_url: https://github.com/pavelpachkovskij/sample-rails
270- repo_branch: trunk
271- app_name: sample-rails
272- install_root: /var/www
273- extra_packages: imagemagick
274- port: 80
275- migrate_database: true
276- seed_database: true
277- compile_assets: true
278-
279-If you don't have or don't need to migrate database, seed database or compile assets, disable them in your config. They are enabled by default.
280-
281-## Under the hood
282-
283-- installs all dependencies and extra packages
284-- install node.js from ppa:chris-lea/node.js
285-- fetch an application from configured repository
286-- runs bundler
287+Rack charm will set environment variables which you can use to configure your Mongodb adapter.
288+
289+ MONGODB_URL => mongodb://host:port/database
290+
291+## Mongoid 2.x
292+
293+Your mongoid.yml should look like:
294+
295+ production:
296+ uri: <%= ENV['MONGODB_URL'] %>
297+
298+## Mongoid 3.x
299+
300+Your mongoid.yml should look like:
301+
302+ production:
303+ sessions:
304+ default:
305+ uri: <%= ENV['MONGODB_URL'] %>
306+
307+In both cases you can set additional options specified by Mongoid.
308+
309+# Memcached relation
310+
311+Deploy Memcached service and relate it to Rack application:
312+
313+ juju deploy memcached
314+ juju add-relation memcached rack
315+
316+Rack charm will set environment variables which you can use to configure your Memcache adapter. [Dalli](https://github.com/mperham/dalli) use those variables by default.
317+
318+ MEMCACHE_PASSWORD => xxxxxxxxxxxx
319+ MEMCACHE_SERVERS => instance.hostname.net
320+ MEMCACHE_USERNAME => xxxxxxxxxxxx
321+
322+# Redis relation
323+
324+Deploy Redis service and relate it to Rack application:
325+
326+ juju deploy redis-master
327+ juju add-relation redis-master:redis-master rack
328+
329+Rack charm will set environment variables which you can use to configure your Redis adapter.
330+
331+ REDIS_URL => redis://username:password@my.host:6389
332+
333+For example you can configure Redis adapter in config/initializers/redis.rb
334+
335+ uri = URI.parse(ENV["REDIS_URL"])
336+ REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
337+
338+# Known issues
339+
340+## Rack application didn't start because assets were not compiled
341+
342+To be able to compile assets before you've joined database relation you have to disable initialize_on_precompile option in application.rb:
343+
344+ config.assets.initialize_on_precompile = false
345+
346+If you can't do this you still can join database and compile assets manually:
347+
348+ juju ssh rack/0 run rake assets:precompile
349+
350+Then restart Rack service (while you have to replace 'rack/0' with your application name, e.g. 'sample-rails/0', 'sudo restart rack' is a valid command to restart any deployed application):
351+
352+ juju ssh rack/0 sudo restart rack
353+
354+# Configuration
355+
356+## Deploy from Git
357+
358+Sample Git config:
359+
360+ rack:
361+ repo: <repository_url>
362+ revision: <revision_number>
363+
364+To deploy from private repo via SSH add 'deploy_key' option:
365+
366+ deploy_key: <private_key>
367+
368+## Deploy from SVN
369+
370+Sample SVN config:
371+
372+ rack:
373+ scm_provider: svn
374+ repo: <repository_url>
375+ revision: <revision_number>
376+ svn_username: <username>
377+ svn_password: <password>
378+
379+## Install extra packages
380+
381+Specify list of packages separated by spaces:
382+
383+ extra_packages: 'libsqlite3++-dev libmagick++-dev'
384+
385+## Set ENV variables
386+
387+You can set ENV variables, which will be available within all processes defined in a Procfile:
388+
389+ env: 'AWS_ACCESS_KEY_ID=aws_access_key_id AWS_SECRET_ACCESS_KEY=aws_secret_access_key'
390\ No newline at end of file
391
392=== modified file 'config.yaml'
393--- config.yaml 2013-03-01 11:10:06 +0000
394+++ config.yaml 2013-08-21 10:46:51 +0000
395@@ -1,41 +1,37 @@
396 options:
397- app_name:
398- type: string
399- default: sample-rails
400- description: Application Name
401- repo_url:
402- type: string
403- default: "https://github.com/pavelpachkovskij/sample-rails.git"
404+ repo:
405+ type: string
406+ default: ''
407 description: Application repository URL
408- repo_branch:
409+ revision:
410 type: string
411- default: master
412- description: Application branch name (git only, for bzr the branch is in the url)
413- repo_type:
414+ default: HEAD
415+ description: "The revision to be checked out. This can be symbolic, like HEAD or it can be a source control management-specific revision identifier."
416+ scm_provider:
417 type: string
418 default: git
419- description: Repository type {git|bzr|svn} for now
420- install_root:
421- type: string
422- default: /var/www
423- description: Install the application in app_name under this directory
424+ description: The name of the source control management provider to be used (git or svn).
425+ deploy_key:
426+ type: string
427+ default: ''
428+ description: A deploy key is an SSH key that is stored on the server and grants access to a repository (git only).
429+ svn_username:
430+ type: string
431+ default: ''
432+ description: The password for the user that has access to the Subversion repository (svn only).
433+ svn_password:
434+ type: string
435+ default: ''
436+ description: The user name for a user that has access to the Subversion repository (svn only).
437+ rack_env:
438+ type: string
439+ default: production
440+ description: Both RACK_ENV and RAILS_ENV environment variables.
441 extra_packages:
442 type: string
443- default: ""
444+ default: ''
445 description: Extra packages to install before bundle install
446- port:
447- type: int
448- default: 80
449- description: Port to run application
450- migrate_database:
451- type: boolean
452- default: true
453- description: Migrate database
454- seed_database:
455- type: boolean
456- default: true
457- description: Seed database
458- compile_assets:
459- type: boolean
460- default: true
461- description: Compile assets
462\ No newline at end of file
463+ env:
464+ type: string
465+ default: ''
466+ description: "List of environment variables (e.g. SECRET_TOKEN=secret_token). These variables will override those which were set by Rack charm (like DATABASE_URL, REDIS_URL)"
467\ No newline at end of file
468
469=== added directory 'cookbooks'
470=== added directory 'cookbooks/juju'
471=== added directory 'cookbooks/juju/definitions'
472=== added file 'cookbooks/juju/definitions/juju_port.rb'
473--- cookbooks/juju/definitions/juju_port.rb 1970-01-01 00:00:00 +0000
474+++ cookbooks/juju/definitions/juju_port.rb 2013-08-21 10:46:51 +0000
475@@ -0,0 +1,11 @@
476+define :juju_port, action: :open do
477+ if params[:action] == :open
478+ execute "open-port #{params[:name]}" do
479+ action :run
480+ end
481+ elsif params[:action] == :close
482+ execute "close-port #{params[:name]}" do
483+ action :run
484+ end
485+ end
486+end
487\ No newline at end of file
488
489=== added file 'cookbooks/juju/definitions/relation_set.rb'
490--- cookbooks/juju/definitions/relation_set.rb 1970-01-01 00:00:00 +0000
491+++ cookbooks/juju/definitions/relation_set.rb 2013-08-21 10:46:51 +0000
492@@ -0,0 +1,7 @@
493+define :relation_set do
494+ args_string = params[:variables].map { |key, value| "#{key}=\"#{value}\"" }.join(' ')
495+
496+ execute "relation-set #{args_string}" do
497+ action :run
498+ end
499+end
500\ No newline at end of file
501
502=== added directory 'cookbooks/juju/libraries'
503=== added directory 'cookbooks/juju/libraries/juju'
504=== added file 'cookbooks/juju/libraries/juju.rb'
505--- cookbooks/juju/libraries/juju.rb 1970-01-01 00:00:00 +0000
506+++ cookbooks/juju/libraries/juju.rb 2013-08-21 10:46:51 +0000
507@@ -0,0 +1,32 @@
508+$: << File.expand_path('..', __FILE__)
509+require 'yaml'
510+require 'securerandom'
511+require 'active_support/all'
512+require 'juju/juju_helpers'
513+require 'juju/ruby_helpers'
514+
515+class Chef
516+ class Resource
517+ include JujuHelpers
518+ include RubyHelpers
519+ if ENV['JUJU_ENV'] == 'development'
520+ include JujuHelpersDev
521+ end
522+ end
523+
524+ class Recipe
525+ include RubyHelpers
526+ include JujuHelpers
527+ if ENV['JUJU_ENV'] == 'development'
528+ include JujuHelpersDev
529+ end
530+ end
531+
532+ class Provider
533+ include RubyHelpers
534+ include JujuHelpers
535+ if ENV['JUJU_ENV'] == 'development'
536+ include JujuHelpersDev
537+ end
538+ end
539+end
540\ No newline at end of file
541
542=== added file 'cookbooks/juju/libraries/juju/juju_helpers.rb'
543--- cookbooks/juju/libraries/juju/juju_helpers.rb 1970-01-01 00:00:00 +0000
544+++ cookbooks/juju/libraries/juju/juju_helpers.rb 2013-08-21 10:46:51 +0000
545@@ -0,0 +1,45 @@
546+module JujuHelpers
547+ def juju_config
548+ @juju_config ||= JSON.load(config_get('--format=json')).symbolize_keys.tap do |config|
549+ File.open(juju_config_cache_path, "w+") do |file|
550+ file.write(config.to_yaml)
551+ end
552+ end
553+ end
554+
555+ def juju_relation
556+ @juju_relation ||= JSON.load(relation_get('--format=json'))
557+ end
558+
559+ def unit_get(key)
560+ run("unit-get #{shell_quote(key)}")
561+ end
562+
563+ def juju_config_cache
564+ File.exists?(juju_config_cache_path) ? YAML.load(File.read(juju_config_cache_path)) : {}
565+ end
566+
567+private
568+ def config_get(key)
569+ run("config-get #{shell_quote(key)}")
570+ end
571+
572+ def relation_get(key)
573+ run("relation-get #{shell_quote(key)}")
574+ end
575+
576+ def juju_config_cache_path
577+ "/root/.juju_config_cache.yml"
578+ end
579+end
580+
581+module JujuHelpersDev
582+ def juju_config
583+ {
584+ repo: 'https://github.com/pavelpachkovskij/octopress',
585+ scm_provider: 'git',
586+ revision: 'public',
587+ rack_env: 'development',
588+ }
589+ end
590+end
591\ No newline at end of file
592
593=== added file 'cookbooks/juju/libraries/juju/ruby_helpers.rb'
594--- cookbooks/juju/libraries/juju/ruby_helpers.rb 1970-01-01 00:00:00 +0000
595+++ cookbooks/juju/libraries/juju/ruby_helpers.rb 2013-08-21 10:46:51 +0000
596@@ -0,0 +1,38 @@
597+require 'shellwords'
598+require 'dotenv'
599+require 'foreman/procfile'
600+
601+module RubyHelpers
602+ def run(command)
603+ value = %x{ #{command} 2>&1 }.strip
604+ value.empty? ? nil : value
605+ end
606+
607+ def run_with_wrap_bundle(commands)
608+ run(wrap_bundle(commands))
609+ end
610+
611+ def wrap_bundle(commands)
612+ [
613+ 'unset BUNDLE_GEMFILE RUBYOPT GEM_HOME',
614+ hash_to_shell_args(dotenv_args).map{ |args| "export #{args}" },
615+ commands
616+ ].flatten.join(';')
617+ end
618+
619+ def shell_quote(value)
620+ Shellwords.escape(value)
621+ end
622+
623+ def hash_to_shell_args(hash)
624+ hash.map { |key, value| "#{key}=#{value}" }
625+ end
626+
627+ def dotenv_args
628+ ::File.exists?(dotenv_path) ? Dotenv::Environment.new(dotenv_path) : {}
629+ end
630+private
631+ def dotenv_path
632+ "#{node[:rack][:root]}/shared/.env"
633+ end
634+end
635\ No newline at end of file
636
637=== added file 'cookbooks/juju/metadata.rb'
638--- cookbooks/juju/metadata.rb 1970-01-01 00:00:00 +0000
639+++ cookbooks/juju/metadata.rb 2013-08-21 10:46:51 +0000
640@@ -0,0 +1,8 @@
641+maintainer "Altoros Systems, Inc."
642+maintainer_email "pavel.pachkovskij@altoros.com"
643+license "GPL-3"
644+description "JuJu Helpers"
645+
646+version "0.1"
647+name "juju"
648+depends "rack"
649\ No newline at end of file
650
651=== added directory 'cookbooks/juju/recipes'
652=== added file 'cookbooks/juju/recipes/bootstrap.rb'
653--- cookbooks/juju/recipes/bootstrap.rb 1970-01-01 00:00:00 +0000
654+++ cookbooks/juju/recipes/bootstrap.rb 2013-08-21 10:46:51 +0000
655@@ -0,0 +1,2 @@
656+node.default[:juju] = juju_config_cache
657+node.override[:juju] = juju_config
658\ No newline at end of file
659
660=== added directory 'cookbooks/memcached-relation'
661=== added file 'cookbooks/memcached-relation/metadata.rb'
662--- cookbooks/memcached-relation/metadata.rb 1970-01-01 00:00:00 +0000
663+++ cookbooks/memcached-relation/metadata.rb 2013-08-21 10:46:51 +0000
664@@ -0,0 +1,9 @@
665+maintainer "Altoros Systems, Inc."
666+maintainer_email "pavel.pachkovskij@altoros.com"
667+license "GPL-3"
668+description "Memcached relation"
669+
670+version "0.1"
671+name "memcached-relation"
672+depends "rack"
673+depends "juju"
674\ No newline at end of file
675
676=== added directory 'cookbooks/memcached-relation/recipes'
677=== added file 'cookbooks/memcached-relation/recipes/broken.rb'
678--- cookbooks/memcached-relation/recipes/broken.rb 1970-01-01 00:00:00 +0000
679+++ cookbooks/memcached-relation/recipes/broken.rb 2013-08-21 10:46:51 +0000
680@@ -0,0 +1,14 @@
681+rack_envfile "#{node[:rack][:root]}/shared/.env" do
682+ delete_variables(%w(memcache_servers memcache_password memcache_username))
683+ action :delete_variables
684+end
685+
686+executables do
687+ action :export
688+end
689+
690+service 'rack' do
691+ ignore_failure true
692+ provider Chef::Provider::Service::Upstart
693+ action :restart
694+end
695\ No newline at end of file
696
697=== added file 'cookbooks/memcached-relation/recipes/changed.rb'
698--- cookbooks/memcached-relation/recipes/changed.rb 1970-01-01 00:00:00 +0000
699+++ cookbooks/memcached-relation/recipes/changed.rb 2013-08-21 10:46:51 +0000
700@@ -0,0 +1,30 @@
701+memcached = {
702+ host: juju_relation['host'],
703+ port: juju_relation['port'],
704+}
705+
706+if %i(host port).any? { |attr| memcached[attr].nil? || memcached[attr].empty? }
707+ puts "Waiting for all attributes being set."
708+else
709+ rack_envfile "#{node[:rack][:root]}/shared/.env" do
710+ variables({
711+ memcache_servers: "#{memcached[:host]}:#{memcached[:port]}",
712+ memcache_password: nil,
713+ memcache_username: nil
714+ })
715+ user 'deploy'
716+ group 'deploy'
717+ mode '0644'
718+ action :merge
719+ end
720+
721+ executables do
722+ action :export
723+ end
724+
725+ service 'rack' do
726+ ignore_failure true
727+ provider Chef::Provider::Service::Upstart
728+ action :restart
729+ end
730+end
731\ No newline at end of file
732
733=== added directory 'cookbooks/mongodb-relation'
734=== added file 'cookbooks/mongodb-relation/metadata.rb'
735--- cookbooks/mongodb-relation/metadata.rb 1970-01-01 00:00:00 +0000
736+++ cookbooks/mongodb-relation/metadata.rb 2013-08-21 10:46:51 +0000
737@@ -0,0 +1,9 @@
738+maintainer "Altoros Systems, Inc."
739+maintainer_email "pavel.pachkovskij@altoros.com"
740+license "GPL-3"
741+description "MongoDB relation"
742+
743+version "0.1"
744+name "mongodb-relation"
745+depends "rack"
746+depends "juju"
747\ No newline at end of file
748
749=== added directory 'cookbooks/mongodb-relation/recipes'
750=== added file 'cookbooks/mongodb-relation/recipes/broken.rb'
751--- cookbooks/mongodb-relation/recipes/broken.rb 1970-01-01 00:00:00 +0000
752+++ cookbooks/mongodb-relation/recipes/broken.rb 2013-08-21 10:46:51 +0000
753@@ -0,0 +1,14 @@
754+rack_envfile "#{node[:rack][:root]}/shared/.env" do
755+ delete_variables(%w(mongodb_url))
756+ action :delete_variables
757+end
758+
759+executables do
760+ action :export
761+end
762+
763+service 'rack' do
764+ ignore_failure true
765+ provider Chef::Provider::Service::Upstart
766+ action :restart
767+end
768\ No newline at end of file
769
770=== added file 'cookbooks/mongodb-relation/recipes/changed.rb'
771--- cookbooks/mongodb-relation/recipes/changed.rb 1970-01-01 00:00:00 +0000
772+++ cookbooks/mongodb-relation/recipes/changed.rb 2013-08-21 10:46:51 +0000
773@@ -0,0 +1,31 @@
774+require 'securerandom'
775+
776+mongodb = {
777+ host: juju_relation['hostname'],
778+ port: juju_relation['port'],
779+ database: "rack_#{node[:juju][:rack_env]}"
780+}
781+
782+if %i(host port).any? { |attr| mongodb[attr].nil? || mongodb[attr].empty? }
783+ puts "Waiting for all attributes being set."
784+else
785+ rack_envfile "#{node[:rack][:root]}/shared/.env" do
786+ variables({
787+ mongodb_url: "mongodb://#{mongodb[:host]}:#{mongodb[:port]}/#{mongodb[:database]}",
788+ })
789+ user 'deploy'
790+ group 'deploy'
791+ mode '0644'
792+ action :merge
793+ end
794+
795+ executables do
796+ action :export
797+ end
798+
799+ service 'rack' do
800+ ignore_failure true
801+ provider Chef::Provider::Service::Upstart
802+ action :restart
803+ end
804+end
805\ No newline at end of file
806
807=== added directory 'cookbooks/mysql-relation'
808=== added file 'cookbooks/mysql-relation/metadata.rb'
809--- cookbooks/mysql-relation/metadata.rb 1970-01-01 00:00:00 +0000
810+++ cookbooks/mysql-relation/metadata.rb 2013-08-21 10:46:51 +0000
811@@ -0,0 +1,9 @@
812+maintainer "Altoros Systems, Inc."
813+maintainer_email "pavel.pachkovskij@altoros.com"
814+license "GPL-3"
815+description "MySQL relation"
816+
817+version "0.1"
818+name "mysql-relation"
819+depends "rack"
820+depends "juju"
821\ No newline at end of file
822
823=== added directory 'cookbooks/mysql-relation/recipes'
824=== added file 'cookbooks/mysql-relation/recipes/broken.rb'
825--- cookbooks/mysql-relation/recipes/broken.rb 1970-01-01 00:00:00 +0000
826+++ cookbooks/mysql-relation/recipes/broken.rb 2013-08-21 10:46:51 +0000
827@@ -0,0 +1,14 @@
828+rack_envfile "#{node[:rack][:root]}/shared/.env" do
829+ delete_variables(%w(database_url))
830+ action :delete_variables
831+end
832+
833+executables do
834+ action :export
835+end
836+
837+service 'rack' do
838+ ignore_failure true
839+ provider Chef::Provider::Service::Upstart
840+ action :restart
841+end
842\ No newline at end of file
843
844=== added file 'cookbooks/mysql-relation/recipes/changed.rb'
845--- cookbooks/mysql-relation/recipes/changed.rb 1970-01-01 00:00:00 +0000
846+++ cookbooks/mysql-relation/recipes/changed.rb 2013-08-21 10:46:51 +0000
847@@ -0,0 +1,31 @@
848+mysql = {
849+ host: juju_relation['host'],
850+ database: juju_relation['database'],
851+ username: juju_relation['user'],
852+ password: juju_relation['password'],
853+ port: juju_relation['port']
854+}
855+
856+if %i(host database username password).any? { |attr| mysql[attr].nil? || mysql[attr].empty? }
857+ puts "Waiting for all attributes being set."
858+else
859+ rack_envfile "#{node[:rack][:root]}/shared/.env" do
860+ variables({
861+ database_url: "mysql2://#{mysql[:username]}:#{mysql[:password]}@#{mysql[:host]}:#{mysql[:port]}/#{mysql[:database]}",
862+ })
863+ user 'deploy'
864+ group 'deploy'
865+ mode '0644'
866+ action :merge
867+ end
868+
869+ executables do
870+ action :export
871+ end
872+
873+ service 'rack' do
874+ ignore_failure true
875+ provider Chef::Provider::Service::Upstart
876+ action :restart
877+ end
878+end
879\ No newline at end of file
880
881=== added file 'cookbooks/mysql-relation/recipes/joined.rb'
882--- cookbooks/mysql-relation/recipes/joined.rb 1970-01-01 00:00:00 +0000
883+++ cookbooks/mysql-relation/recipes/joined.rb 2013-08-21 10:46:51 +0000
884@@ -0,0 +1,3 @@
885+relation_set do
886+ variables(database: "rack_#{SecureRandom.hex}")
887+end
888\ No newline at end of file
889
890=== added directory 'cookbooks/nagios-relation'
891=== added file 'cookbooks/nagios-relation/metadata.rb'
892--- cookbooks/nagios-relation/metadata.rb 1970-01-01 00:00:00 +0000
893+++ cookbooks/nagios-relation/metadata.rb 2013-08-21 10:46:51 +0000
894@@ -0,0 +1,7 @@
895+maintainer "Altoros Systems, Inc."
896+maintainer_email "pavel.pachkovskij@altoros.com"
897+license "GPL-3"
898+description "Nagios relation"
899+
900+version "0.1"
901+name "juju"
902\ No newline at end of file
903
904=== added directory 'cookbooks/nagios-relation/recipes'
905=== added file 'cookbooks/nagios-relation/recipes/joined.rb'
906--- cookbooks/nagios-relation/recipes/joined.rb 1970-01-01 00:00:00 +0000
907+++ cookbooks/nagios-relation/recipes/joined.rb 2013-08-21 10:46:51 +0000
908@@ -0,0 +1,22 @@
909+private_address = unit_get('private-address')
910+
911+relation_set do
912+ variables(
913+ "monitors" => {
914+ "version" => "0.3",
915+ 'monitors' => {
916+ 'local' => {},
917+ 'remote' => {
918+ 'http' => {
919+ 'http' => {
920+ 'port' => 80,
921+ 'host' => private_address
922+ }
923+ }
924+ }
925+ }
926+ }.to_yaml,
927+ "target-id" => ENV["JUJU_UNIT_NAME"].gsub('/', '-'),
928+ "target-address" => private_address
929+ )
930+end
931\ No newline at end of file
932
933=== added directory 'cookbooks/nginx'
934=== added directory 'cookbooks/nginx/definitions'
935=== added file 'cookbooks/nginx/definitions/nginx_site.rb'
936--- cookbooks/nginx/definitions/nginx_site.rb 1970-01-01 00:00:00 +0000
937+++ cookbooks/nginx/definitions/nginx_site.rb 2013-08-21 10:46:51 +0000
938@@ -0,0 +1,18 @@
939+define :nginx_site, :action => :enable do
940+ site_available_path = "/etc/nginx/sites-available/#{params[:name]}"
941+ site_enabled_path = "/etc/nginx/sites-enabled/#{params[:name]}"
942+
943+ if params[:action] == :enable
944+ link site_enabled_path do
945+ to site_available_path
946+ not_if { File.exists?(site_enabled_path) }
947+ only_if { File.exists?(site_available_path) }
948+ action :create
949+ end
950+ elsif params[:action] == :disable
951+ file site_enabled_path do
952+ only_if { File.exists?(site_enabled_path) }
953+ action :delete
954+ end
955+ end
956+end
957\ No newline at end of file
958
959=== added file 'cookbooks/nginx/metadata.rb'
960--- cookbooks/nginx/metadata.rb 1970-01-01 00:00:00 +0000
961+++ cookbooks/nginx/metadata.rb 2013-08-21 10:46:51 +0000
962@@ -0,0 +1,7 @@
963+maintainer "Altoros Systems, Inc."
964+maintainer_email "pavel.pachkovskij@altoros.com"
965+license "GPL-3"
966+description "Installs/Configures nginx"
967+
968+version "0.1"
969+name "nginx"
970
971=== added directory 'cookbooks/nginx/recipes'
972=== added file 'cookbooks/nginx/recipes/default.rb'
973--- cookbooks/nginx/recipes/default.rb 1970-01-01 00:00:00 +0000
974+++ cookbooks/nginx/recipes/default.rb 2013-08-21 10:46:51 +0000
975@@ -0,0 +1,9 @@
976+package 'nginx' do
977+ action :install
978+end
979+
980+template '/etc/nginx/sites-available/rack' do
981+ source 'site.conf.erb'
982+ owner 'root'
983+ group 'root'
984+end
985\ No newline at end of file
986
987=== added directory 'cookbooks/nginx/templates'
988=== added directory 'cookbooks/nginx/templates/default'
989=== added file 'cookbooks/nginx/templates/default/site.conf.erb'
990--- cookbooks/nginx/templates/default/site.conf.erb 1970-01-01 00:00:00 +0000
991+++ cookbooks/nginx/templates/default/site.conf.erb 2013-08-21 10:46:51 +0000
992@@ -0,0 +1,39 @@
993+upstream rack {
994+ server localhost:8080;
995+}
996+
997+server {
998+ listen 80 default_server;
999+ # server_name "";
1000+
1001+ keepalive_timeout 5;
1002+
1003+ root <%= node[:rack][:root] %>/current/public;
1004+
1005+ access_log <%= node[:rack][:root] %>/current/log/nginx.access.log;
1006+ error_log <%= node[:rack][:root] %>/current/log/nginx.error.log;
1007+
1008+ # this rewrites all the requests to the maintenance.html
1009+ # page if it exists in the doc root. This is for capistrano's
1010+ # disable web task
1011+ if (-f $document_root/maintenance.html) {
1012+ rewrite ^(.*)$ /maintenance.html last;
1013+ break;
1014+ }
1015+
1016+ location / {
1017+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
1018+ proxy_set_header Host $http_host;
1019+
1020+ # If the file exists as a static file serve it directly without
1021+ # running all the other rewite tests on it
1022+ if (-f $request_filename) {
1023+ break;
1024+ }
1025+
1026+ if (!-f $request_filename) {
1027+ proxy_pass http://rack;
1028+ break;
1029+ }
1030+ }
1031+}
1032\ No newline at end of file
1033
1034=== added directory 'cookbooks/nodejs'
1035=== added file 'cookbooks/nodejs/metadata.rb'
1036--- cookbooks/nodejs/metadata.rb 1970-01-01 00:00:00 +0000
1037+++ cookbooks/nodejs/metadata.rb 2013-08-21 10:46:51 +0000
1038@@ -0,0 +1,7 @@
1039+maintainer "Altoros Systems, Inc."
1040+maintainer_email "pavel.pachkovskij@altoros.com"
1041+license "GPL-3"
1042+description "Installs/Configures nodejs"
1043+
1044+version "0.1"
1045+name "nodejs"
1046
1047=== added directory 'cookbooks/nodejs/recipes'
1048=== added file 'cookbooks/nodejs/recipes/default.rb'
1049--- cookbooks/nodejs/recipes/default.rb 1970-01-01 00:00:00 +0000
1050+++ cookbooks/nodejs/recipes/default.rb 2013-08-21 10:46:51 +0000
1051@@ -0,0 +1,17 @@
1052+%w(python-software-properties python g++ make).each do |pckg|
1053+ package pckg do
1054+ action :install
1055+ end
1056+end
1057+
1058+execute 'add nodejs ppa' do
1059+ command 'add-apt-repository -y ppa:chris-lea/node.js'
1060+end
1061+
1062+execute 'apt-get update' do
1063+ command 'apt-get update'
1064+end
1065+
1066+package 'nodejs' do
1067+ action :install
1068+end
1069\ No newline at end of file
1070
1071=== added directory 'cookbooks/nrpe-relation'
1072=== added directory 'cookbooks/nrpe-relation/recipes'
1073=== added file 'cookbooks/nrpe-relation/recipes/joined.rb'
1074--- cookbooks/nrpe-relation/recipes/joined.rb 1970-01-01 00:00:00 +0000
1075+++ cookbooks/nrpe-relation/recipes/joined.rb 2013-08-21 10:46:51 +0000
1076@@ -0,0 +1,1 @@
1077+include_recipe 'nagios-relation::joined'
1078\ No newline at end of file
1079
1080=== added directory 'cookbooks/postgresql-relation'
1081=== added file 'cookbooks/postgresql-relation/metadata.rb'
1082--- cookbooks/postgresql-relation/metadata.rb 1970-01-01 00:00:00 +0000
1083+++ cookbooks/postgresql-relation/metadata.rb 2013-08-21 10:46:51 +0000
1084@@ -0,0 +1,9 @@
1085+maintainer "Altoros Systems, Inc."
1086+maintainer_email "pavel.pachkovskij@altoros.com"
1087+license "GPL-3"
1088+description "PosgreSQL relation"
1089+
1090+version "0.1"
1091+name "postgresql-relation"
1092+depends "rack"
1093+depends "juju"
1094\ No newline at end of file
1095
1096=== added directory 'cookbooks/postgresql-relation/recipes'
1097=== added file 'cookbooks/postgresql-relation/recipes/broken.rb'
1098--- cookbooks/postgresql-relation/recipes/broken.rb 1970-01-01 00:00:00 +0000
1099+++ cookbooks/postgresql-relation/recipes/broken.rb 2013-08-21 10:46:51 +0000
1100@@ -0,0 +1,14 @@
1101+rack_envfile "#{node[:rack][:root]}/shared/.env" do
1102+ delete_variables(%w(database_url))
1103+ action :delete_variables
1104+end
1105+
1106+executables do
1107+ action :export
1108+end
1109+
1110+service 'rack' do
1111+ ignore_failure true
1112+ provider Chef::Provider::Service::Upstart
1113+ action :restart
1114+end
1115\ No newline at end of file
1116
1117=== added file 'cookbooks/postgresql-relation/recipes/changed.rb'
1118--- cookbooks/postgresql-relation/recipes/changed.rb 1970-01-01 00:00:00 +0000
1119+++ cookbooks/postgresql-relation/recipes/changed.rb 2013-08-21 10:46:51 +0000
1120@@ -0,0 +1,31 @@
1121+postgresql = {
1122+ host: juju_relation['host'],
1123+ database: juju_relation['database'],
1124+ username: juju_relation['user'],
1125+ password: juju_relation['password'],
1126+ port: juju_relation['port']
1127+}
1128+
1129+if %i(host database username password).any? { |attr| postgresql[attr].nil? || postgresql[attr].empty? }
1130+ puts "Waiting for all attributes being set."
1131+else
1132+ rack_envfile "#{node[:rack][:root]}/shared/.env" do
1133+ variables({
1134+ database_url: "postgres://#{postgresql[:username]}:#{postgresql[:password]}@#{postgresql[:host]}:#{postgresql[:port]}/#{postgresql[:database]}",
1135+ })
1136+ user 'deploy'
1137+ group 'deploy'
1138+ mode '0644'
1139+ action :merge
1140+ end
1141+
1142+ executables do
1143+ action :export
1144+ end
1145+
1146+ service 'rack' do
1147+ ignore_failure true
1148+ provider Chef::Provider::Service::Upstart
1149+ action :restart
1150+ end
1151+end
1152\ No newline at end of file
1153
1154=== added file 'cookbooks/postgresql-relation/recipes/joined.rb'
1155--- cookbooks/postgresql-relation/recipes/joined.rb 1970-01-01 00:00:00 +0000
1156+++ cookbooks/postgresql-relation/recipes/joined.rb 2013-08-21 10:46:51 +0000
1157@@ -0,0 +1,3 @@
1158+relation_set do
1159+ variables(database: "rack_#{SecureRandom.hex}")
1160+end
1161
1162=== added directory 'cookbooks/proxy-relation'
1163=== added file 'cookbooks/proxy-relation/metadata.rb'
1164--- cookbooks/proxy-relation/metadata.rb 1970-01-01 00:00:00 +0000
1165+++ cookbooks/proxy-relation/metadata.rb 2013-08-21 10:46:51 +0000
1166@@ -0,0 +1,8 @@
1167+maintainer "Altoros Systems, Inc."
1168+maintainer_email "pavel.pachkovskij@altoros.com"
1169+license "GPL-3"
1170+description "MongoDB relation"
1171+
1172+version "0.1"
1173+name "website-relation"
1174+depends "juju"
1175\ No newline at end of file
1176
1177=== added directory 'cookbooks/proxy-relation/recipes'
1178=== added file 'cookbooks/proxy-relation/recipes/joined.rb'
1179--- cookbooks/proxy-relation/recipes/joined.rb 1970-01-01 00:00:00 +0000
1180+++ cookbooks/proxy-relation/recipes/joined.rb 2013-08-21 10:46:51 +0000
1181@@ -0,0 +1,15 @@
1182+private_address = unit_get('private-address')
1183+
1184+relation_set do
1185+ variables(
1186+ port: 80,
1187+ hostname: private_address,
1188+ private_address: private_address,
1189+ all_services: [
1190+ {
1191+ 'service_name' => 'rack',
1192+ 'service_port' => 80
1193+ }
1194+ ].to_yaml
1195+ )
1196+end
1197\ No newline at end of file
1198
1199=== added directory 'cookbooks/rack'
1200=== added directory 'cookbooks/rack/attributes'
1201=== added file 'cookbooks/rack/attributes/default.rb'
1202--- cookbooks/rack/attributes/default.rb 1970-01-01 00:00:00 +0000
1203+++ cookbooks/rack/attributes/default.rb 2013-08-21 10:46:51 +0000
1204@@ -0,0 +1,8 @@
1205+default[:rack][:root] = '/var/www/rack'
1206+default[:rack][:gems_dependencies] = {
1207+ 'pg' => %w(libpq++-dev),
1208+ 'mysql2' => %w(libmysql++-dev),
1209+ 'sqlite3' => %w(libsqlite3-dev),
1210+ 'rmagick' => %w(libmagick++-dev),
1211+ 'nokogiri' => %w(libxslt-dev libxml2-dev)
1212+}
1213\ No newline at end of file
1214
1215=== added directory 'cookbooks/rack/definitions'
1216=== added file 'cookbooks/rack/definitions/bundle.rb'
1217--- cookbooks/rack/definitions/bundle.rb 1970-01-01 00:00:00 +0000
1218+++ cookbooks/rack/definitions/bundle.rb 2013-08-21 10:46:51 +0000
1219@@ -0,0 +1,50 @@
1220+define :bundle, action: :install do
1221+ %w(.rvmrc ruby-version .ruby-version .rbenv-version).each do |rvm_file|
1222+ file "#{params[:name]}/#{rvm_file}" do
1223+ action :delete
1224+ end
1225+ end
1226+
1227+ node[:rack][:gems_dependencies].each do |bundled_gem, packages|
1228+ if %x(grep -q #{bundled_gem} #{params[:name]}/Gemfile.lock) && $?.success?
1229+ packages.each do |pckg|
1230+ package pckg do
1231+ action :install
1232+ end
1233+ end
1234+ end
1235+ end
1236+
1237+ ruby_version_string = run_with_wrap_bundle(["cd #{params[:name]}", "bundle platform --ruby"]).chomp
1238+
1239+ if ruby_version_string == "No ruby version specified"
1240+ ruby_version_string = run('rvm current')
1241+ else
1242+ ruby_version_string = ruby_version_string.sub('(', '').sub(')', '').split.join('-')
1243+
1244+ execute "rvm install #{ruby_version_string}" do
1245+ action :run
1246+ end
1247+ end
1248+
1249+ execute "rvm wrapper #{ruby_version_string} rack bundle" do
1250+ action :run
1251+ end
1252+
1253+ file "#{params[:name]}/.ruby-version" do
1254+ action :create
1255+ content ruby_version_string
1256+ group params[:group]
1257+ user params[:user]
1258+ end
1259+
1260+ bundle_without = (%w(development production test).reject{ |env| env == node[:juju][:rack_env] }).join(' ')
1261+
1262+ execute 'bundle install' do
1263+ action :run
1264+ command wrap_bundle("rack_bundle install --without #{bundle_without} --path #{node[:rack][:root]}/shared/bundle")
1265+ cwd params[:name]
1266+ group params[:group]
1267+ user params[:user]
1268+ end
1269+end
1270\ No newline at end of file
1271
1272=== added file 'cookbooks/rack/definitions/executables.rb'
1273--- cookbooks/rack/definitions/executables.rb 1970-01-01 00:00:00 +0000
1274+++ cookbooks/rack/definitions/executables.rb 2013-08-21 10:46:51 +0000
1275@@ -0,0 +1,29 @@
1276+define :executables, action: :export do
1277+ if params[:action] == :export
1278+ rack_procfile 'rack Procfile' do
1279+ cwd "#{node[:rack][:root]}/current"
1280+ user 'deploy'
1281+ app 'rack'
1282+ action :export
1283+ end
1284+
1285+ template "/usr/bin/run" do
1286+ cookbook 'rack'
1287+ source 'bin/run.erb'
1288+ owner 'root'
1289+ group 'root'
1290+ mode '0755'
1291+ helpers(RubyHelpers)
1292+ action :create
1293+ end
1294+
1295+ template "/usr/bin/service_restart" do
1296+ cookbook 'rack'
1297+ source 'bin/restart.erb'
1298+ owner 'root'
1299+ group 'root'
1300+ mode '0755'
1301+ action :create
1302+ end
1303+ end
1304+end
1305\ No newline at end of file
1306
1307=== added file 'cookbooks/rack/definitions/extra_packages.rb'
1308--- cookbooks/rack/definitions/extra_packages.rb 1970-01-01 00:00:00 +0000
1309+++ cookbooks/rack/definitions/extra_packages.rb 2013-08-21 10:46:51 +0000
1310@@ -0,0 +1,11 @@
1311+define :extra_packages, action: :install do
1312+ if params[:action] == :install
1313+ if params[:extra_packages]
1314+ params[:extra_packages].split(',').map(&:strip).each do |pckg|
1315+ package pckg do
1316+ action :install
1317+ end
1318+ end
1319+ end
1320+ end
1321+end
1322\ No newline at end of file
1323
1324=== added file 'cookbooks/rack/definitions/rake_task.rb'
1325--- cookbooks/rack/definitions/rake_task.rb 1970-01-01 00:00:00 +0000
1326+++ cookbooks/rack/definitions/rake_task.rb 2013-08-21 10:46:51 +0000
1327@@ -0,0 +1,11 @@
1328+define :rake_task, action: :run, user: 'ubuntu', group: 'ubuntu', cwd: nil, ignore_failure: false do
1329+ execute "rake #{params[:name]}" do
1330+ action params[:action]
1331+ command wrap_bundle(["cd #{params[:cwd]}", "rack_bundle exec rake #{params[:name]}"])
1332+ cwd params[:cwd]
1333+ group params[:group]
1334+ ignore_failure params[:ignore_failure]
1335+ only_if { run_with_wrap_bundle(["cd #{params[:cwd]}", "rack_bundle exec rake #{params[:name]} --dry-run"]) && $?.success? }
1336+ user params[:user]
1337+ end
1338+end
1339\ No newline at end of file
1340
1341=== added file 'cookbooks/rack/definitions/scm_provider.rb'
1342--- cookbooks/rack/definitions/scm_provider.rb 1970-01-01 00:00:00 +0000
1343+++ cookbooks/rack/definitions/scm_provider.rb 2013-08-21 10:46:51 +0000
1344@@ -0,0 +1,38 @@
1345+define :scm_provider, action: :bootstrap do
1346+ if params[:action] == :bootstrap
1347+ case params[:name]
1348+ when 'git'
1349+ package 'git-core' do
1350+ action :install
1351+ end
1352+ when 'svn'
1353+ package 'subversion' do
1354+ action :install
1355+ end
1356+ else
1357+ raise ArgumentError
1358+ end
1359+
1360+ if params[:deploy_key]
1361+ directory "/tmp/private_code/.ssh" do
1362+ owner params[:owner]
1363+ group params[:group]
1364+ recursive true
1365+ end
1366+
1367+ cookbook_file "/tmp/private_code/wrap-ssh.sh" do
1368+ source "wrap-ssh.sh"
1369+ owner params[:owner]
1370+ group params[:group]
1371+ mode 00700
1372+ end
1373+
1374+ file '/tmp/private_code/.ssh/id_deploy' do
1375+ content params[:deploy_key]
1376+ owner params[:owner]
1377+ group params[:group]
1378+ mode 00400
1379+ end
1380+ end
1381+ end
1382+end
1383\ No newline at end of file
1384
1385=== added directory 'cookbooks/rack/files'
1386=== added directory 'cookbooks/rack/files/default'
1387=== added file 'cookbooks/rack/files/default/database.yml'
1388--- cookbooks/rack/files/default/database.yml 1970-01-01 00:00:00 +0000
1389+++ cookbooks/rack/files/default/database.yml 2013-08-21 10:46:51 +0000
1390@@ -0,0 +1,53 @@
1391+<%
1392+
1393+require 'cgi'
1394+require 'uri'
1395+
1396+begin
1397+ uri = URI.parse(ENV["DATABASE_URL"])
1398+rescue URI::InvalidURIError
1399+ raise "Invalid DATABASE_URL"
1400+end
1401+
1402+raise "No RACK_ENV or RAILS_ENV found" unless ENV["RAILS_ENV"] || ENV["RACK_ENV"]
1403+
1404+def attribute(name, value, force_string = false)
1405+ if value
1406+ value_string =
1407+ if force_string
1408+ '"' + value + '"'
1409+ else
1410+ value
1411+ end
1412+ "#{name}: #{value_string}"
1413+ else
1414+ ""
1415+ end
1416+end
1417+
1418+adapter = uri.scheme
1419+adapter = "postgresql" if adapter == "postgres"
1420+
1421+database = (uri.path || "").split("/")[1]
1422+
1423+username = uri.user
1424+password = uri.password
1425+
1426+host = uri.host
1427+port = uri.port
1428+
1429+params = CGI.parse(uri.query || "")
1430+
1431+%>
1432+
1433+<%= ENV["RAILS_ENV"] || ENV["RACK_ENV"] %>:
1434+ <%= attribute "adapter", adapter %>
1435+ <%= attribute "database", database %>
1436+ <%= attribute "username", username %>
1437+ <%= attribute "password", password, true %>
1438+ <%= attribute "host", host %>
1439+ <%= attribute "port", port %>
1440+
1441+<% params.each do |key, value| %>
1442+ <%= key %>: <%= value.first %>
1443+<% end %>
1444\ No newline at end of file
1445
1446=== added file 'cookbooks/rack/files/default/wrap-ssh.sh'
1447--- cookbooks/rack/files/default/wrap-ssh.sh 1970-01-01 00:00:00 +0000
1448+++ cookbooks/rack/files/default/wrap-ssh.sh 2013-08-21 10:46:51 +0000
1449@@ -0,0 +1,2 @@
1450+#!/usr/bin/env bash
1451+/usr/bin/env ssh -o "StrictHostKeyChecking=no" -i "/tmp/private_code/.ssh/id_deploy" $1 $2
1452\ No newline at end of file
1453
1454=== added file 'cookbooks/rack/metadata.rb'
1455--- cookbooks/rack/metadata.rb 1970-01-01 00:00:00 +0000
1456+++ cookbooks/rack/metadata.rb 2013-08-21 10:46:51 +0000
1457@@ -0,0 +1,10 @@
1458+maintainer "Altoros Systems, Inc."
1459+maintainer_email "pavel.pachkovskij@altoros.com"
1460+license "GPL-3"
1461+description "Installs/Configures Rack application"
1462+
1463+version "0.1"
1464+name "rack"
1465+depends "nginx"
1466+depends "juju"
1467+depends "nodejs"
1468
1469=== added directory 'cookbooks/rack/providers'
1470=== added file 'cookbooks/rack/providers/envfile.rb'
1471--- cookbooks/rack/providers/envfile.rb 1970-01-01 00:00:00 +0000
1472+++ cookbooks/rack/providers/envfile.rb 2013-08-21 10:46:51 +0000
1473@@ -0,0 +1,83 @@
1474+def whyrun_supported?
1475+ true
1476+end
1477+
1478+action :merge do
1479+ converge_by("Update #{ @new_resource }") do
1480+ env = dotenv_args
1481+
1482+ @new_resource.variables.each do |key, value|
1483+ env[key.to_s.upcase] = shell_quote(value)
1484+ end
1485+
1486+ user_env.each do |key, value|
1487+ env[key.to_s.upcase] = shell_quote(value)
1488+ end
1489+
1490+ file @new_resource.name do
1491+ content hash_to_shell_args(env).join("\n")
1492+ user new_resource.user
1493+ group new_resource.group
1494+ mode new_resource.mode
1495+ action :create
1496+ end
1497+ end
1498+end
1499+
1500+action :delete_variables do
1501+ converge_by("Update #{ @new_resource }") do
1502+ env = dotenv_args
1503+
1504+ unless env.blank?
1505+ @new_resource.delete_variables.each do |key|
1506+ env.delete(key.to_s.upcase)
1507+ end
1508+
1509+ user_env.each do |key, value|
1510+ env[key.to_s.upcase] = shell_quote(value)
1511+ end
1512+
1513+ file @new_resource.name do
1514+ content hash_to_shell_args(env).join("\n")
1515+ user new_resource.user
1516+ group new_resource.group
1517+ mode new_resource.mode
1518+ action :create
1519+ end
1520+ end
1521+ end
1522+end
1523+
1524+private
1525+
1526+PAIR = /
1527+ \A
1528+ ([\w\.]+) # key
1529+ (?:\s*=\s*|:\s+?) # separator
1530+ ( # value begin
1531+ '(?:\'|[^'])*' # single quoted value
1532+ | # or
1533+ "(?:\"|[^"])*" # double quoted value
1534+ | # or
1535+ [^#\n]+ # unquoted value
1536+ ) # value end
1537+ \z
1538+ /x
1539+
1540+def user_env
1541+ if node[:juju][:env].present?
1542+ node[:juju][:env].split(' ').reduce({}) do |result, pair|
1543+ if match = pair.match(PAIR)
1544+ key, value = match.captures
1545+ value = value.strip.sub(/\A(['"])(.*)\1\z/, '\2')
1546+ value = value.gsub('\n', "\n").gsub(/\\(.)/, '\1') if $1 == '"'
1547+ result[key] = value
1548+ result
1549+ else
1550+ raise FormatError, "Pair #{pair.inspect} doesn't match format"
1551+ end
1552+ end
1553+ else
1554+ {}
1555+ end
1556+end
1557\ No newline at end of file
1558
1559=== added file 'cookbooks/rack/providers/procfile.rb'
1560--- cookbooks/rack/providers/procfile.rb 1970-01-01 00:00:00 +0000
1561+++ cookbooks/rack/providers/procfile.rb 2013-08-21 10:46:51 +0000
1562@@ -0,0 +1,39 @@
1563+require 'etc'
1564+
1565+def whyrun_supported?
1566+ true
1567+end
1568+
1569+action :reverse_merge do
1570+ converge_by("Update #{ @new_resource }") do
1571+ procfile = Foreman::Procfile.new(::File.exists?(@new_resource.procfile) ? @new_resource.procfile : nil)
1572+ @new_resource.entries.each do |key, command|
1573+ key = key.to_s
1574+ procfile[key] = command unless key_exists?(procfile, key)
1575+ end
1576+ file @new_resource.procfile do
1577+ content procfile.to_s
1578+ user new_resource.user
1579+ group new_resource.group
1580+ mode new_resource.mode
1581+ action :create
1582+ end
1583+ end
1584+end
1585+
1586+action :export do
1587+ converge_by("Export #{ @new_resource }") do
1588+ execute "foreman export --procfile #{ @new_resource.procfile || 'Procfile' } upstart /etc/init \
1589+ --user #{ @new_resource.user || 'deploy' } --app #{ @new_resource.app || 'rack'} \
1590+ --log #{node[:rack][:root]}/shared/log" do
1591+ cwd new_resource.cwd
1592+ action :run
1593+ end
1594+ end
1595+end
1596+
1597+private
1598+
1599+def key_exists?(procfile, key)
1600+ procfile.entries { |k, v| return true if k == key } && false
1601+end
1602\ No newline at end of file
1603
1604=== added directory 'cookbooks/rack/recipes'
1605=== added file 'cookbooks/rack/recipes/config-changed.rb'
1606--- cookbooks/rack/recipes/config-changed.rb 1970-01-01 00:00:00 +0000
1607+++ cookbooks/rack/recipes/config-changed.rb 2013-08-21 10:46:51 +0000
1608@@ -0,0 +1,17 @@
1609+if (node.default[:juju][:revision] != node.override[:juju][:revision]) ||
1610+ (node.default[:juju][:env] != node.override[:juju][:env])
1611+
1612+ service 'rack' do
1613+ ignore_failure true
1614+ provider Chef::Provider::Service::Upstart
1615+ action :stop
1616+ end
1617+
1618+ include_recipe 'rack::deploy'
1619+
1620+ service 'rack' do
1621+ ignore_failure true
1622+ provider Chef::Provider::Service::Upstart
1623+ action :start
1624+ end
1625+end
1626\ No newline at end of file
1627
1628=== added file 'cookbooks/rack/recipes/deploy.rb'
1629--- cookbooks/rack/recipes/deploy.rb 1970-01-01 00:00:00 +0000
1630+++ cookbooks/rack/recipes/deploy.rb 2013-08-21 10:46:51 +0000
1631@@ -0,0 +1,84 @@
1632+extra_packages node[:juju][:extra_packages] do
1633+ action :install
1634+end
1635+
1636+scm_provider node[:juju][:scm_provider] do
1637+ deploy_key node[:juju][:deploy_key]
1638+ owner 'deploy'
1639+ group 'deploy'
1640+ action :bootstrap
1641+end
1642+
1643+rack_envfile "#{node[:rack][:root]}/shared/.env" do
1644+ variables({
1645+ rack_env: node[:juju][:rack_env],
1646+ rails_env: node[:juju][:rack_env],
1647+ port: 8080
1648+ })
1649+ user 'deploy'
1650+ group 'deploy'
1651+ mode '0644'
1652+ action :merge
1653+end
1654+
1655+deploy_revision node[:rack][:root] do
1656+ repo node[:juju][:repo]
1657+ action :deploy
1658+
1659+ user 'deploy'
1660+ group 'deploy'
1661+
1662+ symlink_before_migrate({'config/database.yml' => 'config/database.yml',
1663+ '.env' => '.env'})
1664+
1665+ case node[:juju][:scm_provider]
1666+ when 'git'
1667+ revision node[:juju][:revision]
1668+ ssh_wrapper "/tmp/private_code/wrap-ssh.sh"
1669+ when 'svn'
1670+ revision node[:juju][:revision]
1671+ scm_provider Chef::Provider::Subversion
1672+ svn_username node[:juju][:svn_username]
1673+ svn_password node[:juju][:svn_password]
1674+ else
1675+ raise ArgumentError
1676+ end
1677+
1678+ before_migrate do
1679+ # workaround for symlink_before_migrate() http://tickets.opscode.com/browse/CHEF-4374
1680+ directory "#{release_path}/config" do
1681+ user 'deploy'
1682+ group 'deploy'
1683+ action :create
1684+ end
1685+
1686+ bundle release_path do
1687+ user 'deploy'
1688+ group 'deploy'
1689+ action :install
1690+ end
1691+ end
1692+
1693+ before_restart do
1694+ rake_task 'assets:precompile' do
1695+ cwd "#{node[:rack][:root]}/current"
1696+ user 'deploy'
1697+ group 'deploy'
1698+ ignore_failure true
1699+ action :run
1700+ end
1701+ end
1702+end
1703+
1704+rack_procfile 'reverse_merge entries in Procfile' do
1705+ procfile "#{node[:rack][:root]}/current/Procfile"
1706+ entries({web: 'bundle exec rackup config.ru -p $PORT'})
1707+ user 'deploy'
1708+ group 'deploy'
1709+ mode '0644'
1710+ action :reverse_merge
1711+end
1712+
1713+executables do
1714+ action :export
1715+end
1716\ No newline at end of file
1717
1718=== added file 'cookbooks/rack/recipes/install.rb'
1719--- cookbooks/rack/recipes/install.rb 1970-01-01 00:00:00 +0000
1720+++ cookbooks/rack/recipes/install.rb 2013-08-21 10:46:51 +0000
1721@@ -0,0 +1,45 @@
1722+include_recipe 'nginx::default'
1723+include_recipe 'nodejs::default'
1724+
1725+user 'deploy' do
1726+ home '/home/deploy'
1727+ shell '/bin/bash'
1728+ supports manage_home: true
1729+ action :create
1730+end
1731+
1732+%w{config log pids cached-copy bundle system db}.each do |dir|
1733+ directory "#{node[:rack][:root]}/shared/#{dir}" do
1734+ owner 'deploy'
1735+ group 'deploy'
1736+ mode '0755'
1737+ recursive true
1738+ action :create
1739+ end
1740+end
1741+
1742+cookbook_file "#{node[:rack][:root]}/shared/config/database.yml" do
1743+ source 'database.yml'
1744+ cookbook 'rack'
1745+ owner 'deploy'
1746+ group 'deploy'
1747+ action :create
1748+end
1749+
1750+include_recipe 'rack::deploy'
1751+
1752+nginx_site 'rack' do
1753+ action :enable
1754+end
1755+
1756+nginx_site 'default' do
1757+ action :disable
1758+end
1759+
1760+service 'nginx' do
1761+ action :start
1762+end
1763+
1764+juju_port 80 do
1765+ action :open
1766+end
1767\ No newline at end of file
1768
1769=== added file 'cookbooks/rack/recipes/start.rb'
1770--- cookbooks/rack/recipes/start.rb 1970-01-01 00:00:00 +0000
1771+++ cookbooks/rack/recipes/start.rb 2013-08-21 10:46:51 +0000
1772@@ -0,0 +1,5 @@
1773+service 'rack' do
1774+ ignore_failure true
1775+ provider Chef::Provider::Service::Upstart
1776+ action :start
1777+end
1778\ No newline at end of file
1779
1780=== added file 'cookbooks/rack/recipes/stop.rb'
1781--- cookbooks/rack/recipes/stop.rb 1970-01-01 00:00:00 +0000
1782+++ cookbooks/rack/recipes/stop.rb 2013-08-21 10:46:51 +0000
1783@@ -0,0 +1,5 @@
1784+service 'rack' do
1785+ ignore_failure true
1786+ provider Chef::Provider::Service::Upstart
1787+ action :stop
1788+end
1789\ No newline at end of file
1790
1791=== added directory 'cookbooks/rack/resources'
1792=== added file 'cookbooks/rack/resources/envfile.rb'
1793--- cookbooks/rack/resources/envfile.rb 1970-01-01 00:00:00 +0000
1794+++ cookbooks/rack/resources/envfile.rb 2013-08-21 10:46:51 +0000
1795@@ -0,0 +1,8 @@
1796+actions :merge, :delete_variables
1797+
1798+attribute :name, kind_of: String, required: true, name_attribute: true
1799+attribute :variables, required: true, kind_of: Hash
1800+attribute :delete_variables, required: true, kind_of: Array
1801+attribute :user, kind_of: String
1802+attribute :group, kind_of: String
1803+attribute :mode, kind_of: String
1804\ No newline at end of file
1805
1806=== added file 'cookbooks/rack/resources/procfile.rb'
1807--- cookbooks/rack/resources/procfile.rb 1970-01-01 00:00:00 +0000
1808+++ cookbooks/rack/resources/procfile.rb 2013-08-21 10:46:51 +0000
1809@@ -0,0 +1,11 @@
1810+actions :reverse_merge, :export
1811+
1812+attribute :procfile, kind_of: String
1813+attribute :entries, required: true, kind_of: Hash
1814+attribute :user, kind_of: String
1815+attribute :group, kind_of: String
1816+attribute :mode, kind_of: String
1817+attribute :app, kind_of: String
1818+attribute :cwd, kind_of: String
1819+
1820+attr_accessor :current_procfile
1821\ No newline at end of file
1822
1823=== added directory 'cookbooks/rack/templates'
1824=== added directory 'cookbooks/rack/templates/default'
1825=== added directory 'cookbooks/rack/templates/default/bin'
1826=== added file 'cookbooks/rack/templates/default/bin/restart.erb'
1827--- cookbooks/rack/templates/default/bin/restart.erb 1970-01-01 00:00:00 +0000
1828+++ cookbooks/rack/templates/default/bin/restart.erb 2013-08-21 10:46:51 +0000
1829@@ -0,0 +1,3 @@
1830+#!/bin/bash
1831+
1832+sudo restart rack
1833\ No newline at end of file
1834
1835=== added file 'cookbooks/rack/templates/default/bin/run.erb'
1836--- cookbooks/rack/templates/default/bin/run.erb 1970-01-01 00:00:00 +0000
1837+++ cookbooks/rack/templates/default/bin/run.erb 2013-08-21 10:46:51 +0000
1838@@ -0,0 +1,4 @@
1839+#!/bin/bash
1840+
1841+COMMAND="$@"
1842+sudo su - deploy -c "<%= wrap_bundle(["cd #{node[:rack][:root]}/current", 'rack_bundle exec $COMMAND']) %>"
1843\ No newline at end of file
1844
1845=== added directory 'cookbooks/redis-relation'
1846=== added file 'cookbooks/redis-relation/metadata.rb'
1847--- cookbooks/redis-relation/metadata.rb 1970-01-01 00:00:00 +0000
1848+++ cookbooks/redis-relation/metadata.rb 2013-08-21 10:46:51 +0000
1849@@ -0,0 +1,8 @@
1850+maintainer "Altoros Systems, Inc."
1851+maintainer_email "pavel.pachkovskij@altoros.com"
1852+license "GPL-3"
1853+description "MongoDB relation"
1854+
1855+version "0.1"
1856+name "website-relation"
1857+depends "juju"
1858\ No newline at end of file
1859
1860=== added directory 'cookbooks/redis-relation/recipes'
1861=== added file 'cookbooks/redis-relation/recipes/broken.rb'
1862--- cookbooks/redis-relation/recipes/broken.rb 1970-01-01 00:00:00 +0000
1863+++ cookbooks/redis-relation/recipes/broken.rb 2013-08-21 10:46:51 +0000
1864@@ -0,0 +1,14 @@
1865+rack_envfile "#{node[:rack][:root]}/shared/.env" do
1866+ delete_variables(%w(redis_url))
1867+ action :delete_variables
1868+end
1869+
1870+executables do
1871+ action :export
1872+end
1873+
1874+service 'rack' do
1875+ ignore_failure true
1876+ provider Chef::Provider::Service::Upstart
1877+ action :restart
1878+end
1879\ No newline at end of file
1880
1881=== added file 'cookbooks/redis-relation/recipes/changed.rb'
1882--- cookbooks/redis-relation/recipes/changed.rb 1970-01-01 00:00:00 +0000
1883+++ cookbooks/redis-relation/recipes/changed.rb 2013-08-21 10:46:51 +0000
1884@@ -0,0 +1,28 @@
1885+redis = {
1886+ host: juju_relation['hostname'],
1887+ port: juju_relation['port'],
1888+}
1889+
1890+if %i(host port).any? { |attr| redis[attr].nil? || redis[attr].empty? }
1891+ puts "Waiting for all attributes being set."
1892+else
1893+ rack_envfile "#{node[:rack][:root]}/shared/.env" do
1894+ variables({
1895+ redis_url: "redis://#{redis[:host]}:#{redis[:port]}",
1896+ })
1897+ user 'deploy'
1898+ group 'deploy'
1899+ mode '0644'
1900+ action :merge
1901+ end
1902+
1903+ executables do
1904+ action :export
1905+ end
1906+
1907+ service 'rack' do
1908+ ignore_failure true
1909+ provider Chef::Provider::Service::Upstart
1910+ action :restart
1911+ end
1912+end
1913\ No newline at end of file
1914
1915=== removed directory 'files'
1916=== removed file 'files/mongoid_example.yml'
1917=== removed file 'files/resque_example.yml'
1918--- files/resque_example.yml 2013-03-01 11:10:06 +0000
1919+++ files/resque_example.yml 1970-01-01 00:00:00 +0000
1920@@ -1,1 +0,0 @@
1921-development: localhost:6379
1922\ No newline at end of file
1923
1924=== added file 'hooks/Gemfile'
1925--- hooks/Gemfile 1970-01-01 00:00:00 +0000
1926+++ hooks/Gemfile 2013-08-21 10:46:51 +0000
1927@@ -0,0 +1,5 @@
1928+source "https://rubygems.org"
1929+
1930+gem 'chef', '~> 11.6.0'
1931+gem 'foreman', '~> 0.63'
1932+gem 'activesupport', '~> 4.0.0'
1933\ No newline at end of file
1934
1935=== added file 'hooks/Gemfile.lock'
1936--- hooks/Gemfile.lock 1970-01-01 00:00:00 +0000
1937+++ hooks/Gemfile.lock 2013-08-21 10:46:51 +0000
1938@@ -0,0 +1,72 @@
1939+GEM
1940+ remote: https://rubygems.org/
1941+ specs:
1942+ activesupport (4.0.0)
1943+ i18n (~> 0.6, >= 0.6.4)
1944+ minitest (~> 4.2)
1945+ multi_json (~> 1.3)
1946+ thread_safe (~> 0.1)
1947+ tzinfo (~> 0.3.37)
1948+ atomic (1.1.10)
1949+ chef (11.6.0)
1950+ erubis
1951+ highline (>= 1.6.9)
1952+ json (>= 1.4.4, <= 1.7.7)
1953+ mixlib-authentication (>= 1.3.0)
1954+ mixlib-cli (~> 1.3.0)
1955+ mixlib-config (>= 1.1.2)
1956+ mixlib-log (>= 1.3.0)
1957+ mixlib-shellout
1958+ net-ssh (~> 2.6)
1959+ net-ssh-multi (~> 1.1.0)
1960+ ohai (>= 0.6.0)
1961+ rest-client (>= 1.0.4, < 1.7.0)
1962+ yajl-ruby (~> 1.1)
1963+ dotenv (0.8.0)
1964+ erubis (2.7.0)
1965+ foreman (0.63.0)
1966+ dotenv (>= 0.7)
1967+ thor (>= 0.13.6)
1968+ highline (1.6.19)
1969+ i18n (0.6.4)
1970+ ipaddress (0.8.0)
1971+ json (1.7.7)
1972+ mime-types (1.23)
1973+ minitest (4.7.5)
1974+ mixlib-authentication (1.3.0)
1975+ mixlib-log
1976+ mixlib-cli (1.3.0)
1977+ mixlib-config (1.1.2)
1978+ mixlib-log (1.6.0)
1979+ mixlib-shellout (1.2.0)
1980+ multi_json (1.7.7)
1981+ net-ssh (2.6.8)
1982+ net-ssh-gateway (1.2.0)
1983+ net-ssh (>= 2.6.5)
1984+ net-ssh-multi (1.1)
1985+ net-ssh (>= 2.1.4)
1986+ net-ssh-gateway (>= 0.99.0)
1987+ ohai (6.18.0)
1988+ ipaddress
1989+ mixlib-cli
1990+ mixlib-config
1991+ mixlib-log
1992+ mixlib-shellout
1993+ systemu
1994+ yajl-ruby
1995+ rest-client (1.6.7)
1996+ mime-types (>= 1.16)
1997+ systemu (2.5.2)
1998+ thor (0.18.1)
1999+ thread_safe (0.1.0)
2000+ atomic
2001+ tzinfo (0.3.37)
2002+ yajl-ruby (1.1.0)
2003+
2004+PLATFORMS
2005+ ruby
2006+
2007+DEPENDENCIES
2008+ activesupport (~> 4.0.0)
2009+ chef (~> 11.6.0)
2010+ foreman (~> 0.63)
2011
2012=== added file 'hooks/bootstrap'
2013--- hooks/bootstrap 1970-01-01 00:00:00 +0000
2014+++ hooks/bootstrap 2013-08-21 10:46:51 +0000
2015@@ -0,0 +1,28 @@
2016+#!/bin/bash
2017+set -e
2018+
2019+export HOME=/root
2020+
2021+apt-get update
2022+apt-get install -y curl build-essential
2023+
2024+$CHARM_DIR/hooks/rvm-installer.sh stable
2025+
2026+export PATH=$PATH:/usr/local/rvm/bin
2027+source /usr/local/rvm/scripts/rvm
2028+
2029+rvm install ruby --default
2030+rvm use ruby
2031+
2032+cd $CHARM_DIR/hooks && bundle install
2033+
2034+rvm wrapper ruby juju chef-solo bundle
2035+
2036+configure_chef_solo() {
2037+ cat > /etc/chef/solo.rb <<EOF
2038+cookbook_path '$CHARM_DIR/cookbooks'
2039+EOF
2040+}
2041+
2042+mkdir -p /etc/chef
2043+[[ -a /etc/chef/solo.rb ]] || configure_chef_solo
2044\ No newline at end of file
2045
2046=== removed file 'hooks/common.sh'
2047--- hooks/common.sh 2013-02-22 14:15:28 +0000
2048+++ hooks/common.sh 1970-01-01 00:00:00 +0000
2049@@ -1,109 +0,0 @@
2050-install_root=`config-get install_root`
2051-app_name=`config-get app_name`
2052-repo_url=`config-get repo_url`
2053-repo_branch=`config-get repo_branch`
2054-repo_type=`config-get repo_type`
2055-extra_packages=`config-get extra_packages`
2056-port=`config-get port`
2057-migrate_database=`config-get migrate_database`
2058-seed_database=`config-get seed_database`
2059-compile_assets=`config-get compile_assets`
2060-
2061-root="$install_root/$app_name"
2062-
2063-export RAILS_ENV=production
2064-export RAILS_ROOT=$root
2065-
2066-has_gem() {
2067- grep -q $1 $root/Gemfile
2068-}
2069-add_gem() {
2070- echo -e "\ngem '$1'\n" >> $root/Gemfile
2071- bundle_install
2072-}
2073-ensure_gem() {
2074- has_gem $1 || add_gem $1
2075-}
2076-bundle_install() {
2077- cd $root && bundle install
2078-}
2079-
2080-#db methods
2081-
2082-database_version() {
2083- `cd $root && bundle exec rake db:version | awk '/Current version:/ { print $3 }'`
2084-}
2085-
2086-configure_database() {
2087- juju-log "Configure database"
2088-
2089- cat > "$root/config/database.yml" <<EOS
2090- $RAILS_ENV:
2091- adapter: $1
2092- database: $2
2093- host: $3
2094- pool: 5
2095- timeout: 5000
2096- username: $4
2097- password: $5
2098-EOS
2099-}
2100-
2101-migrate_database() {
2102- if [[ $migrate_database == 'True' ]]; then
2103- juju-log "Migrate database"
2104- wrap_rake db:migrate
2105- fi
2106-}
2107-
2108-seed_database() {
2109- if [[ $seed_database == 'True' ]]; then
2110- juju-log "Seed database"
2111- wrap_rake db:seed
2112- fi
2113-}
2114-
2115-compile_assets() {
2116- if [[ $compile_assets == 'True' ]]; then
2117- juju-log 'Compile assets'
2118- wrap_rake assets:precompile
2119- fi
2120-}
2121-
2122-create_mongoid_indexes() {
2123- juju-log 'Create mongoid indexes'
2124- wrap_rake db:mongoid:create_indexes
2125-}
2126-
2127-run_rake() {
2128- cd $root && bundle exec rake $1
2129-}
2130-
2131-wrap_rake() {
2132- run_rake $1 || juju-log "Your either do not have Rake installed or trying to run task that doesn't exist."
2133-}
2134-
2135-# global methods
2136-
2137-requires_restart() {
2138- for relation_id in $(relation-ids website); do
2139- relation-set -r $relation_id updated_at=`date +%s`
2140- done
2141-}
2142-
2143-exit_if_blank() {
2144- if [ -z "$1" ] ; then
2145- juju-log "$2 not set yet."
2146- exit 0
2147- fi
2148-}
2149-
2150-# rescue methods
2151-
2152-configure_resque() {
2153- juju-log "Configuring Resque..."
2154-
2155- cat > "$root/config/resque.yml" <<EOS
2156-$RAILS_ENV: $1:$2
2157-EOS
2158-}
2159\ No newline at end of file
2160
2161=== added symlink 'hooks/config-changed'
2162=== target is u'stub'
2163=== removed file 'hooks/god-relation-joined'
2164--- hooks/god-relation-joined 2013-02-15 14:57:55 +0000
2165+++ hooks/god-relation-joined 1970-01-01 00:00:00 +0000
2166@@ -1,12 +0,0 @@
2167-#!/bin/bash
2168-
2169-set -eu
2170-
2171-source "$(dirname $0)/common.sh"
2172-
2173-cat >> '/etc/god/environment_variables.god' <<EOS
2174-ENV['RAILS_ROOT'] = '$RAILS_ROOT'
2175-ENV['RAILS_ENV'] = '$RAILS_ENV'
2176-EOS
2177-
2178-relation-set path="$root/config/*.god"
2179\ No newline at end of file
2180
2181=== modified file 'hooks/install'
2182--- hooks/install 2013-02-15 14:57:55 +0000
2183+++ hooks/install 2013-08-21 10:46:51 +0000
2184@@ -1,58 +1,6 @@
2185 #!/bin/bash
2186-
2187-set -eu
2188-source "$(dirname $0)/common.sh"
2189-
2190-juju-log 'Add chris-lea node.js ppa'
2191-add-apt-repository -y ppa:chris-lea/node.js
2192-apt-get update -qq
2193-
2194-juju-log "Install dependencies"
2195-apt-get install -y -qq build-essential libsqlite3-dev libmysql++-dev libpq-dev nodejs
2196-
2197-juju-log "Install extra packages"
2198-[[ -z $extra_packages ]] || apt-get -y install -qq $extra_packages
2199-
2200-juju-log "install bundler"
2201-gem install bundler --no-rdoc --no-ri
2202-
2203-fetch_from_git() {
2204- apt-get -y install -qq git-core
2205- umask 022
2206- git clone $repo_url -b $repo_branch $root
2207-}
2208-fetch_from_bzr() {
2209- apt-get -y install -qq bzr
2210- umask 022
2211- bzr branch $repo_url $root
2212-}
2213-fetch_from_svn() {
2214- apt-get install -y -qq subversion
2215- umask 022
2216- if [[ ($repo_branch == 'trunk') || (-z $repo_branch) ]]; then
2217- svn co "$repo_url/trunk" $root
2218- else
2219- svn co "$repo_url/branches/$repo_branch" $root
2220- fi
2221-}
2222-install_app() {
2223- juju-log "Install rails app into $root"
2224- case $repo_type in
2225- git )
2226- fetch_from_git ;;
2227- bzr )
2228- fetch_from_bzr ;;
2229- svn )
2230- fetch_from_svn ;;
2231- esac
2232-
2233- mkdir -p $root/config
2234- mkdir -p $root/public
2235- mkdir -p $root/tmp
2236- #touch $root/log/production.log
2237- #chmod 0666 $root/log/production.log
2238-
2239- bundle_install
2240-}
2241-
2242-[ -d $root ] || install_app
2243\ No newline at end of file
2244+set -e
2245+
2246+source "$(dirname $0)/bootstrap"
2247+
2248+juju_chef-solo -o "recipe[juju::bootstrap],recipe[rack::install]"
2249
2250=== added symlink 'hooks/memcached-relation-broken'
2251=== target is u'stub'
2252=== added symlink 'hooks/memcached-relation-changed'
2253=== target is u'stub'
2254=== added symlink 'hooks/mongodb-relation-broken'
2255=== target is u'stub'
2256=== added symlink 'hooks/mongodb-relation-changed'
2257=== target is u'stub'
2258=== removed file 'hooks/mongoid-relation-changed'
2259--- hooks/mongoid-relation-changed 2013-02-22 14:15:28 +0000
2260+++ hooks/mongoid-relation-changed 1970-01-01 00:00:00 +0000
2261@@ -1,35 +0,0 @@
2262-#!/bin/bash
2263-
2264-set -eu
2265-
2266-source "$(dirname $0)/common.sh"
2267-
2268-host=`relation-get hostname`
2269-port=`relation-get port`
2270-
2271-exit_if_blank "$host" 'mongodb host'
2272-exit_if_blank "$port" 'mongodb port'
2273-
2274-configure_mongoid() {
2275- juju-log "Configure Mongoid"
2276- cat > "$root/config/mongoid.yml" <<EOS
2277-$RAILS_ENV:
2278- sessions:
2279- default:
2280- database: "rails_${RAILS_ENV}"
2281- hosts:
2282- - ${host}:${port}
2283- options:
2284- consistency: :strong
2285-EOS
2286-}
2287-
2288-configure_mongoid
2289-
2290-create_mongoid_indexes
2291-
2292-seed_database
2293-
2294-compile_assets
2295-
2296-requires_restart
2297\ No newline at end of file
2298
2299=== removed file 'hooks/mongoid-relation-joined'
2300--- hooks/mongoid-relation-joined 2013-02-14 14:06:50 +0000
2301+++ hooks/mongoid-relation-joined 1970-01-01 00:00:00 +0000
2302@@ -1,7 +0,0 @@
2303-#!/bin/bash
2304-
2305-set -eu
2306-
2307-source "$(dirname $0)/common.sh"
2308-
2309-ensure_gem 'mongoid'
2310\ No newline at end of file
2311
2312=== modified file 'hooks/mysql-relation-broken'
2313--- hooks/mysql-relation-broken 2013-02-14 14:06:50 +0000
2314+++ hooks/mysql-relation-broken 1970-01-01 00:00:00 +0000
2315@@ -1,9 +0,0 @@
2316-#!/bin/bash
2317-
2318-set -eu
2319-
2320-source "$(dirname $0)/common.sh"
2321-
2322-configure_database 'mysql2' "" "" "" ""
2323-
2324-requires_restart
2325\ No newline at end of file
2326
2327=== target is u'stub'
2328=== modified file 'hooks/mysql-relation-changed'
2329--- hooks/mysql-relation-changed 2013-02-15 14:57:55 +0000
2330+++ hooks/mysql-relation-changed 1970-01-01 00:00:00 +0000
2331@@ -1,25 +0,0 @@
2332-#!/bin/bash
2333-
2334-set -eu
2335-
2336-source "$(dirname $0)/common.sh"
2337-
2338-host=`relation-get host`
2339-database=`relation-get database`
2340-user=`relation-get user`
2341-password=`relation-get password`
2342-
2343-exit_if_blank "$host" 'mysql host'
2344-exit_if_blank "$database" 'mysql database'
2345-exit_if_blank "$user" 'mysql user'
2346-exit_if_blank "$password" 'mysql password'
2347-
2348-configure_database 'mysql2' "$database" "$host" "$user" "$password"
2349-
2350-migrate_database
2351-
2352-seed_database
2353-
2354-compile_assets
2355-
2356-requires_restart
2357\ No newline at end of file
2358
2359=== target is u'stub'
2360=== modified file 'hooks/mysql-relation-joined'
2361--- hooks/mysql-relation-joined 2013-02-14 14:06:50 +0000
2362+++ hooks/mysql-relation-joined 1970-01-01 00:00:00 +0000
2363@@ -1,7 +0,0 @@
2364-#!/bin/bash
2365-
2366-set -eu
2367-
2368-source "$(dirname $0)/common.sh"
2369-
2370-ensure_gem 'mysql2'
2371\ No newline at end of file
2372
2373=== target is u'stub'
2374=== added symlink 'hooks/nagios-relation-joined'
2375=== target is u'stub'
2376=== added symlink 'hooks/nrpe-relation-joined'
2377=== target is u'stub'
2378=== modified file 'hooks/postgresql-relation-broken'
2379--- hooks/postgresql-relation-broken 2013-02-14 14:06:50 +0000
2380+++ hooks/postgresql-relation-broken 1970-01-01 00:00:00 +0000
2381@@ -1,9 +0,0 @@
2382-#!/bin/bash
2383-
2384-set -eu
2385-
2386-source "$(dirname $0)/common.sh"
2387-
2388-configure_database 'postgresql' "" "" "" ""
2389-
2390-requires_restart
2391\ No newline at end of file
2392
2393=== target is u'stub'
2394=== modified file 'hooks/postgresql-relation-changed'
2395--- hooks/postgresql-relation-changed 2013-02-15 14:57:55 +0000
2396+++ hooks/postgresql-relation-changed 1970-01-01 00:00:00 +0000
2397@@ -1,25 +0,0 @@
2398-#!/bin/bash
2399-
2400-set -eu
2401-
2402-source "$(dirname $0)/common.sh"
2403-
2404-host=`relation-get host`
2405-database=`relation-get database`
2406-user=`relation-get user`
2407-password=`relation-get password`
2408-
2409-exit_if_blank "$host" 'mysql host'
2410-exit_if_blank "$database" 'mysql database'
2411-exit_if_blank "$user" 'mysql user'
2412-exit_if_blank "$password" 'mysql password'
2413-
2414-configure_database 'postgresql' "$database" "$host" "$user" "$password"
2415-
2416-migrate_database
2417-
2418-seed_database
2419-
2420-compile_assets
2421-
2422-requires_restart
2423\ No newline at end of file
2424
2425=== target is u'stub'
2426=== modified file 'hooks/postgresql-relation-joined'
2427--- hooks/postgresql-relation-joined 2013-02-15 14:57:55 +0000
2428+++ hooks/postgresql-relation-joined 1970-01-01 00:00:00 +0000
2429@@ -1,10 +0,0 @@
2430-#!/bin/bash
2431-
2432-set -eu
2433-
2434-source "$(dirname $0)/common.sh"
2435-
2436-ensure_gem 'pg'
2437-
2438-# TODO: we need uniq within unit scope but valid postgresql database identifier here
2439-relation-set database="rails_${RAILS_ENV}"
2440\ No newline at end of file
2441
2442=== target is u'stub'
2443=== added symlink 'hooks/proxy-relation-joined'
2444=== target is u'stub'
2445=== removed file 'hooks/rack-server-relation-joined'
2446--- hooks/rack-server-relation-joined 2013-03-01 07:41:56 +0000
2447+++ hooks/rack-server-relation-joined 1970-01-01 00:00:00 +0000
2448@@ -1,7 +0,0 @@
2449-#!/bin/bash
2450-
2451-set -eu
2452-
2453-source "$(dirname $0)/common.sh"
2454-
2455-relation-set rack_root=$root rack_port=$port
2456\ No newline at end of file
2457
2458=== added symlink 'hooks/redis-relation-broken'
2459=== target is u'stub'
2460=== added symlink 'hooks/redis-relation-changed'
2461=== target is u'stub'
2462=== removed file 'hooks/resque-relation-changed'
2463--- hooks/resque-relation-changed 2013-02-15 14:57:55 +0000
2464+++ hooks/resque-relation-changed 1970-01-01 00:00:00 +0000
2465@@ -1,18 +0,0 @@
2466-#!/bin/bash
2467-
2468-set -eux
2469-
2470-source "$(dirname $0)/common.sh"
2471-
2472-resque_host=`relation-get hostname`
2473-resque_port=`relation-get port`
2474-resque_web_port=5678
2475-
2476-exit_if_blank "$resque_host" 'resque host'
2477-exit_if_blank "$resque_port" 'resque port'
2478-
2479-configure_resque $resque_host $resque_port
2480-
2481-open-port $resque_web_port
2482-
2483-requires_restart
2484\ No newline at end of file
2485
2486=== removed file 'hooks/resque-relation-joined'
2487--- hooks/resque-relation-joined 2013-02-14 14:06:50 +0000
2488+++ hooks/resque-relation-joined 1970-01-01 00:00:00 +0000
2489@@ -1,14 +0,0 @@
2490-#!/bin/bash
2491-
2492-set -eux
2493-
2494-source "$(dirname $0)/common.sh"
2495-rakefile="$root/Rakefile"
2496-
2497-tasks_loaded() {
2498- grep -q 'resque/tasks' $rakefile
2499-}
2500-
2501-tasks_loaded || echo "require 'resque/tasks'" >> $rakefile
2502-
2503-mkdir -p ~/.vegas/resque-web
2504\ No newline at end of file
2505
2506=== added file 'hooks/rvm-installer.sh'
2507--- hooks/rvm-installer.sh 1970-01-01 00:00:00 +0000
2508+++ hooks/rvm-installer.sh 2013-08-21 10:46:51 +0000
2509@@ -0,0 +1,620 @@
2510+#!/usr/bin/env bash
2511+
2512+BASH_MIN_VERSION="3.2.25"
2513+if
2514+ [[ -n "${BASH_VERSION:-}" &&
2515+ "$(printf "%b" "${BASH_VERSION:-}\n${BASH_MIN_VERSION}\n" | LC_ALL=C sort -n -t"." | head -n1)" != "${BASH_MIN_VERSION}"
2516+ ]]
2517+then
2518+ echo "BASH ${BASH_MIN_VERSION} required (you have $BASH_VERSION)"
2519+ exit 1
2520+fi
2521+
2522+export HOME PS4
2523+export rvm_trace_flag rvm_debug_flag rvm_user_install_flag rvm_ignore_rvmrc rvm_prefix rvm_path
2524+
2525+shopt -s extglob
2526+PS4="+ \${BASH_SOURCE##\${rvm_path:-}} : \${FUNCNAME[0]:+\${FUNCNAME[0]}()} \${LINENO} > "
2527+set -o errtrace
2528+set -o errexit
2529+
2530+log() { printf "%b\n" "$*"; }
2531+fail() { log "\nERROR: $*\n" ; exit 1 ; }
2532+
2533+\which which >/dev/null 2>&1 || fail "Could not find 'which' command, make sure it's available first before continuing installation."
2534+if
2535+ [[ -z "${rvm_tar_command:-}" ]] && builtin command -v gtar >/dev/null
2536+then
2537+ rvm_tar_command=gtar
2538+elif
2539+ ${rvm_tar_command:-tar} --help 2>&1 | GREP_OPTIONS="" \grep -- --strip-components >/dev/null
2540+then
2541+ rvm_tar_command="${rvm_tar_command:-tar}"
2542+else
2543+ case "$(uname)" in
2544+ (OpenBSD)
2545+ log "Trying to install GNU version of tar, might require sudo password"
2546+ if (( UID ))
2547+ then sudo pkg_add -z gtar-1
2548+ else pkg_add -z gtar-1
2549+ fi
2550+ rvm_tar_command=gtar
2551+ ;;
2552+ (Darwin|FreeBSD|DragonFly) # it's not possible to autodetect on OSX, the help/man does not mention all flags
2553+ rvm_tar_command=tar
2554+ ;;
2555+ esac
2556+ builtin command -v ${rvm_tar_command:-gtar} >/dev/null ||
2557+ fail "Could not find GNU compatible version of 'tar' command, make sure it's available first before continuing installation."
2558+fi
2559+if
2560+ [[ ! " ${rvm_tar_options:-} " =~ " --no-same-owner " ]] &&
2561+ $rvm_tar_command --help 2>&1 | GREP_OPTIONS="" \grep -- --no-same-owner >/dev/null
2562+then
2563+ rvm_tar_options="${rvm_tar_options:-}${rvm_tar_options:+ }--no-same-owner"
2564+fi
2565+
2566+usage()
2567+{
2568+ printf "%b" "
2569+
2570+Usage
2571+
2572+ rvm-installer [options] [action]
2573+
2574+Options
2575+
2576+ [[--]version] <latest|latest-minor|latest-x|latest-x.y|x.y.z> - Install RVM version
2577+ [--]branch <name> - Install RVM head, from named branch
2578+ --trace - used to debug the installer script
2579+
2580+Actions
2581+
2582+ master - Install RVM master branch from wayneeseguin rvm repo (Default).
2583+ stable - Install RVM stable branch from wayneeseguin rvm repo.
2584+ help - Display CLI help (this output)
2585+
2586+Branches:
2587+
2588+ branch <branch>
2589+ branch /<branch>
2590+ branch <repo>/
2591+ branch <repo>/<branch>
2592+
2593+ Defaults:
2594+
2595+ branch: master
2596+ repo: wayneeseguin
2597+
2598+"
2599+}
2600+
2601+## duplication marker 32fosjfjsznkjneuera48jae
2602+__rvm_curl_output_control()
2603+{
2604+ if
2605+ (( ${rvm_quiet_curl_flag:-0} == 1 ))
2606+ then
2607+ __flags+=( "--silent" "--show-error" )
2608+ elif
2609+ [[ " $*" =~ " -s" || " $*" =~ " --silent" ]]
2610+ then
2611+ # make sure --show-error is used with --silent
2612+ [[ " $*" =~ " -S" || " $*" =~ " -sS" || " $*" =~ " --show-error" ]] ||
2613+ {
2614+ __flags+=( "--show-error" )
2615+ }
2616+ fi
2617+}
2618+
2619+## duplication marker 32fosjfjsznkjneuera48jae
2620+# -S is automatically added to -s
2621+__rvm_curl()
2622+(
2623+ __rvm_which curl >/dev/null ||
2624+ {
2625+ rvm_error "RVM requires 'curl'. Install 'curl' first and try again."
2626+ return 200
2627+ }
2628+
2629+ typeset -a __flags
2630+ __flags=( --fail --location --max-redirs 10 )
2631+
2632+ if [[ -n "${rvm_proxy:-}" ]]
2633+ then __flags+=( --proxy "${rvm_proxy:-}" )
2634+ fi
2635+
2636+ __rvm_curl_output_control
2637+
2638+ unset curl
2639+ __rvm_debug_command \curl "${__flags[@]}" "$@" || return $?
2640+)
2641+
2642+rvm_error() { printf "ERROR: %b\n" "$*"; }
2643+__rvm_which(){ which "$@" || return $?; true; }
2644+__rvm_debug_command(){ "$@" || return $?; true; }
2645+rvm_is_a_shell_function()
2646+{
2647+ [[ -t 0 && -t 1 ]] || return $?
2648+ return ${rvm_is_not_a_shell_function:-0}
2649+}
2650+
2651+#Searches for highest available version for the given pattern
2652+# fetch_version 1.10. -> 1.10.3
2653+# fetch_version 1. -> 1.11.0
2654+# fetch_version "" -> 2.0.1
2655+fetch_version()
2656+{
2657+ __rvm_curl -s https://api.github.com/repos/wayneeseguin/rvm/tags |
2658+ sed -n '/"name": / {s/^.*".*": "\(.*\)".*$/\1/; p;}' |
2659+ sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n |
2660+ GREP_OPTIONS="" \grep "^${1:-}" | tail -n 1
2661+}
2662+
2663+install_release()
2664+{
2665+ typeset _version
2666+ _version=$1
2667+ log "Downloading RVM version ${_version}"
2668+ get_and_unpack \
2669+ https://github.com/wayneeseguin/rvm/archive/${_version}.tar.gz \
2670+ rvm-${_version}.tgz ||
2671+ get_and_unpack \
2672+ https://bitbucket.org/mpapis/rvm/get/${_version}.tar.gz \
2673+ rvm-${_version}.tgz
2674+}
2675+
2676+install_head()
2677+{
2678+ typeset _repo _branch
2679+ case "$1" in
2680+ (/*)
2681+ _repo=wayneeseguin
2682+ _branch=${1#/}
2683+ ;;
2684+ (*/)
2685+ _repo=${1%/}
2686+ _branch=master
2687+ ;;
2688+ (*/*)
2689+ _repo=${1%%/*}
2690+ _branch=${1#*/}
2691+ ;;
2692+ (*)
2693+ _repo=wayneeseguin
2694+ _branch=$1
2695+ ;;
2696+ esac
2697+ case "${_repo}" in
2698+ (mpapis|wayneeseguin)
2699+ log "Downloading RVM from ${_repo} branch ${_branch}"
2700+ get_and_unpack \
2701+ https://github.com/${_repo}/rvm/archive/${_branch}.tar.gz \
2702+ ${_repo}-rvm-${_branch//\//_}.tgz ||
2703+ get_and_unpack \
2704+ https://bitbucket.org/mpapis/rvm/get/${_branch}.tar.gz \
2705+ ${_repo}-rvm-${_branch//\//_}.tgz
2706+ ;;
2707+ (*)
2708+ log "Downloading RVM from ${_repo} branch ${_branch}"
2709+ get_and_unpack \
2710+ https://github.com/${_repo}/rvm/archive/${_branch}.tar.gz \
2711+ ${_repo}-rvm-${_branch//\//_}.tgz
2712+ ;;
2713+ esac
2714+}
2715+
2716+# duplication marker dfkjdjngdfjngjcszncv
2717+# Drop in cd which _doesn't_ respect cdpath
2718+__rvm_cd()
2719+{
2720+ typeset old_cdpath ret
2721+ ret=0
2722+ old_cdpath="${CDPATH}"
2723+ CDPATH="."
2724+ chpwd_functions="" builtin cd "$@" || ret=$?
2725+ CDPATH="${old_cdpath}"
2726+ return $ret
2727+}
2728+
2729+get_and_unpack()
2730+{
2731+ typeset _url _file _patern _return
2732+ _url=$1
2733+ _file=$2
2734+
2735+ __rvm_curl ${_url} -o ${rvm_archives_path}/${_file} ||
2736+ {
2737+ _return=$?
2738+ case $_return in
2739+ # duplication marker lfdgzkngdkjvnfjknkjvcnbjkncvjxbn
2740+ (60)
2741+ log "
2742+Could not download '${_url}', you can read more about it here:
2743+https://rvm.io/support/fixing-broken-ssl-certificates/
2744+To continue in insecure mode run 'echo insecure >> ~/.curlrc'.
2745+"
2746+ ;;
2747+ # duplication marker lfdgzkngdkjvnfjknkjvcnbjkncvjxbn
2748+ (77)
2749+ log "
2750+It looks like you have old certificates, you can read more about it here:
2751+https://rvm.io/support/fixing-broken-ssl-certificates/
2752+"
2753+ ;;
2754+ # duplication marker lfdgzkngdkjvnfjknkjvcnbjkncvjxbn
2755+ (141)
2756+ log "
2757+Curl returned 141 - it is result of a segfault which means it's Curls fault.
2758+Try again and if it crashes more than a couple of times you either need to
2759+reinstall Curl or consult with your distribution manual and contact support.
2760+"
2761+ ;;
2762+ (*)
2763+ log "
2764+Could not download '${_url}'.
2765+ curl returned status '$_return'.
2766+"
2767+ ;;
2768+ esac
2769+ return $_return
2770+ }
2771+
2772+ [[ -d "${rvm_src_path}/rvm" ]] || \mkdir -p "${rvm_src_path}/rvm"
2773+ __rvm_cd "${rvm_src_path}/rvm" ||
2774+ {
2775+ _return=$?
2776+ log "Could not change directory '${rvm_src_path}/rvm'."
2777+ return $_return
2778+ }
2779+
2780+ rm -rf ${rvm_src_path}/rvm/*
2781+ $rvm_tar_command xzf ${rvm_archives_path}/${_file} ${rvm_tar_options:-} --strip-components 1 ||
2782+ {
2783+ _return=$?
2784+ log "Could not extract RVM sources."
2785+ return $_return
2786+ }
2787+}
2788+
2789+# Tracing, if asked for.
2790+if [[ "$*" =~ --trace ]] || (( ${rvm_trace_flag:-0} > 0 ))
2791+then
2792+ set -o xtrace
2793+ rvm_trace_flag=1
2794+fi
2795+
2796+# Variable initialization, remove trailing slashes if they exist on HOME
2797+true \
2798+ ${rvm_trace_flag:=0} ${rvm_debug_flag:=0}\
2799+ ${rvm_ignore_rvmrc:=0} HOME="${HOME%%+(\/)}"
2800+
2801+
2802+if (( rvm_ignore_rvmrc == 0 ))
2803+then
2804+ for rvmrc in /etc/rvmrc "$HOME/.rvmrc"
2805+ do
2806+ if [[ -s "$rvmrc" ]]
2807+ then
2808+ if GREP_OPTIONS="" \grep '^\s*rvm .*$' "$rvmrc" >/dev/null 2>&1
2809+ then
2810+ printf "%b" "
2811+Error: $rvmrc is for rvm settings only.
2812+rvm CLI may NOT be called from within $rvmrc.
2813+Skipping the loading of $rvmrc
2814+"
2815+ exit 1
2816+ else
2817+ source "$rvmrc"
2818+ fi
2819+ fi
2820+ done
2821+fi
2822+
2823+if [[ -z "${rvm_path:-}" ]]
2824+then
2825+ if (( UID == 0 ))
2826+ then
2827+ rvm_user_install_flag=0
2828+ rvm_prefix="/usr/local"
2829+ rvm_path="${rvm_prefix}/rvm"
2830+ else
2831+ rvm_user_install_flag=1
2832+ rvm_prefix="$HOME"
2833+ rvm_path="${rvm_prefix}/.rvm"
2834+ fi
2835+fi
2836+if [[ -z "${rvm_prefix}" ]]
2837+then
2838+ rvm_prefix=$( dirname $rvm_path )
2839+fi
2840+
2841+# duplication marker kkdfkgnjfndgjkndfjkgnkfjdgn
2842+case "$rvm_path" in
2843+ (/usr/local/rvm) rvm_user_install_flag=0 ;;
2844+ ($HOME/*|/${USER// /_}*) rvm_user_install_flag=1 ;;
2845+ (*) rvm_user_install_flag=0 ;;
2846+esac
2847+
2848+install_rubies=()
2849+install_gems=()
2850+flags=()
2851+forwarded_flags=()
2852+# Parse CLI arguments.
2853+while (( $# > 0 ))
2854+do
2855+ token="$1"
2856+ shift
2857+ case "$token" in
2858+
2859+ --trace)
2860+ set -o xtrace
2861+ rvm_trace_flag=1
2862+ flags+=( "$token" )
2863+ forwarded_flags+=( "$token" )
2864+ ;;
2865+
2866+ --debug|--quiet-curl)
2867+ flags+=( "$token" )
2868+ forwarded_flags+=( "$token" )
2869+ token=${token#--}
2870+ token=${token//-/_}
2871+ export "rvm_${token}_flag"=1
2872+ printf "%b" "Turning on ${token/_/ } mode.\n"
2873+ ;;
2874+
2875+ --path)
2876+ if [[ -n "${1:-}" ]]
2877+ then
2878+ rvm_path="$1"
2879+ shift
2880+ else
2881+ fail "--path must be followed by a path."
2882+ fi
2883+ ;;
2884+
2885+ --branch|branch) # Install RVM from a given branch
2886+ if [[ -n "${1:-}" ]]
2887+ then
2888+ version="head"
2889+ branch="$1"
2890+ shift
2891+ else
2892+ fail "--branch must be followed by a branchname."
2893+ fi
2894+ ;;
2895+
2896+ --user-install|--ignore-dotfiles)
2897+ token=${token#--}
2898+ token=${token//-/_}
2899+ export "rvm_${token}_flag"=1
2900+ printf "%b" "Turning on ${token/_/ } mode.\n"
2901+ ;;
2902+
2903+ --auto-dotfiles)
2904+ flags+=( "$token" )
2905+ export "rvm_auto_dotfiles_flag"=1
2906+ printf "%b" "Turning on auto dotfiles mode.\n"
2907+ ;;
2908+
2909+ --auto)
2910+ export "rvm_auto_dotfiles_flag"=1
2911+ printf "%b" "Warning, --auto is deprecated in favor of --auto-dotfiles.\n"
2912+ ;;
2913+
2914+ --verify-downloads)
2915+ if [[ -n "${1:-}" ]]
2916+ then
2917+ export rvm_verify_downloads_flag="$1"
2918+ forwarded_flags+=( "$token" "$1" )
2919+ shift
2920+ else
2921+ fail "--verify-downloads must be followed by level(0|1|2)."
2922+ fi
2923+ ;;
2924+
2925+ --autolibs=*)
2926+ flags+=( "$token" )
2927+ export rvm_autolibs_flag="${token#--autolibs=}"
2928+ forwarded_flags+=( "$token" )
2929+ ;;
2930+
2931+ --with-gems=*)
2932+ flags+=( "$token" )
2933+ export rvm_with_gems="${token#--with-gems=}"
2934+ printf "%b" "Installing RVM with gems: ${rvm_with_gems}.\n"
2935+ ;;
2936+
2937+ --without-gems=*)
2938+ flags+=( "$token" )
2939+ export rvm_without_gems="${token#--without-gems=}"
2940+ printf "%b" "Installing RVM without gems: ${rvm_without_gems}.\n"
2941+ ;;
2942+
2943+ --version|version)
2944+ version="$1"
2945+ shift
2946+ ;;
2947+
2948+ head)
2949+ version="head"
2950+ branch="master"
2951+ ;;
2952+
2953+ stable|master)
2954+ version="head"
2955+ branch="$token"
2956+ ;;
2957+
2958+ latest|latest-*|+([[:digit:]]).+([[:digit:]]).+([[:digit:]]))
2959+ version="$token"
2960+ ;;
2961+
2962+ --ruby)
2963+ install_rubies+=( ruby )
2964+ ;;
2965+
2966+ --ruby=*)
2967+ token=${token#--ruby=}
2968+ install_rubies+=( ${token//,/ } )
2969+ ;;
2970+
2971+ --rails)
2972+ install_gems+=( rails )
2973+ ;;
2974+
2975+ --gems=*)
2976+ token=${token#--gems=}
2977+ install_gems+=( ${token//,/ } )
2978+ ;;
2979+
2980+ (--add-to-rvm-group)
2981+ export rvm_add_users_to_rvm_group="$1"
2982+ shift
2983+ ;;
2984+
2985+ help|usage)
2986+ usage
2987+ exit 0
2988+ ;;
2989+ *)
2990+ usage
2991+ exit 1
2992+ ;;
2993+
2994+ esac
2995+done
2996+
2997+case "$rvm_path" in
2998+ *[[:space:]]*)
2999+ printf "%b" "
3000+It looks you are one of the happy *space* users(in home dir name),
3001+RVM is not yet fully ready for it, use this trick to fix it:
3002+
3003+ sudo mkdir -p /${USER// /_}.rvm
3004+ sudo chown -R \"$USER:\" /${USER// /_}.rvm
3005+ echo \"export rvm_path=/${USER// /_}.rvm\" >> \"$HOME/.rvmrc\"
3006+
3007+and start installing again.
3008+
3009+"
3010+ exit 2
3011+ ;;
3012+ /usr/share/ruby-rvm)
3013+ printf "%b" "
3014+It looks you are one of the happy Ubuntu users,
3015+RVM packaged by Ubuntu is old and broken,
3016+follow this link for details how to fix:
3017+
3018+ http://stackoverflow.com/a/9056395/497756
3019+
3020+"
3021+ [[ "${rvm_uses_broken_ubuntu_path:-no}" == "yes" ]] || exit 3
3022+ ;;
3023+esac
3024+
3025+if (( ${#install_gems[@]} > 0 && ${#install_rubies[@]} == 0 ))
3026+then
3027+ install_rubies=( ruby )
3028+fi
3029+
3030+if (( ${#install_rubies[@]} > 0 ))
3031+then
3032+ echo "Please read and follow further instructions."
3033+ echo "Press ENTER to continue."
3034+ builtin read -n 1 -s -r anykey
3035+fi
3036+
3037+true "${version:=head}"
3038+
3039+if [[ "$rvm_path" != /* ]]
3040+then
3041+ fail "The rvm install path must be fully qualified. Tried $rvm_path"
3042+fi
3043+
3044+rvm_src_path="$rvm_path/src"
3045+rvm_archives_path="$rvm_path/archives"
3046+rvm_releases_url="https://rvm.io/releases"
3047+
3048+for dir in "$rvm_src_path" "$rvm_archives_path"
3049+do
3050+ if [[ ! -d "$dir" ]]
3051+ then
3052+ mkdir -p "$dir"
3053+ fi
3054+done
3055+
3056+# Perform the actual installation, first we obtain the source using whichever
3057+# means was specified, if any. Defaults to head.
3058+case "${version}" in
3059+ (head)
3060+ echo "${branch}" > "$rvm_path/RELEASE"
3061+ install_head ${branch:-master} || exit $?
3062+ ;;
3063+
3064+ (latest)
3065+ echo "${version}" > "$rvm_path/RELEASE"
3066+ install_release $(fetch_version "") || exit $?
3067+ ;;
3068+
3069+ (latest-minor)
3070+ echo "${version}" > "$rvm_path/RELEASE"
3071+ version="$(\cat "$rvm_path/VERSION")"
3072+ install_release $(fetch_version "${version%.*}") || exit $?
3073+ ;;
3074+
3075+ (latest-*)
3076+ echo "${version}" > "$rvm_path/RELEASE"
3077+ install_release $(fetch_version "${version#latest-}") || exit $?
3078+ ;;
3079+
3080+ (+([[:digit:]]).+([[:digit:]]).+([[:digit:]])) # x.y.z
3081+ echo "version" > "$rvm_path/RELEASE"
3082+ install_release ${version} || exit $?
3083+ ;;
3084+
3085+ (*)
3086+ fail "Something went wrong, unrecognized version '$version'"
3087+ ;;
3088+esac
3089+
3090+# required flag - path to install
3091+flags+=( --path "$rvm_path" )
3092+
3093+chmod +x ./scripts/install
3094+./scripts/install "${flags[@]}"
3095+
3096+if (( ${#install_rubies[@]} > 0 ))
3097+then
3098+ (
3099+ source ${rvm_scripts_path:-${rvm_path}/scripts}/rvm
3100+ source ${rvm_scripts_path:-${rvm_path}/scripts}/version
3101+ __rvm_version
3102+
3103+ for _ruby in ${install_rubies[@]}
3104+ do command rvm "${forwarded_flags[@]}" install ${_ruby} -j 2
3105+ done
3106+ # set the first one as default, skip rest
3107+ for _ruby in ${install_rubies[@]}
3108+ do
3109+ rvm "${forwarded_flags[@]}" alias create default ${_ruby}
3110+ break
3111+ done
3112+
3113+ for _gem in ${install_gems[@]}
3114+ do rvm "${forwarded_flags[@]}" all do gem install ${_gem}
3115+ done
3116+
3117+ printf "%b" "
3118+ * To start using RVM you need to run \`source $rvm_path/scripts/rvm\`
3119+ in all your open shell windows, in rare cases you need to reopen all shell windows.
3120+"
3121+
3122+ if [[ "${install_gems[*]}" =~ "rails" ]]
3123+ then
3124+ printf "%b" "
3125+ * To start using rails you need to run \`rails new <project_dir>\`.
3126+"
3127+ fi
3128+ )
3129+fi
3130
3131=== modified file 'hooks/start'
3132--- hooks/start 2013-02-14 14:06:50 +0000
3133+++ hooks/start 1970-01-01 00:00:00 +0000
3134@@ -1,8 +0,0 @@
3135-#!/bin/bash
3136-
3137-source "$(dirname $0)/common.sh"
3138-
3139-# this is workaround to allow start application even if redis is not connected yet
3140-if has_gem 'resque' ; then
3141- configure_resque 'localhost' '6379'
3142-fi
3143\ No newline at end of file
3144
3145=== target is u'stub'
3146=== modified file 'hooks/stop'
3147--- hooks/stop 2013-02-14 14:06:50 +0000
3148+++ hooks/stop 1970-01-01 00:00:00 +0000
3149@@ -1,7 +0,0 @@
3150-#!/bin/bash
3151-# This will be run when the service is being torn down, allowing you to disable
3152-# it in various ways..
3153-# For example, if your web app uses a text file to signal to the load balancer
3154-# that it is live... you could remove it and sleep for a bit to allow the load
3155-# balancer to stop sending traffic.
3156-# rm /srv/webroot/server-live.txt && sleep 30
3157
3158=== target is u'stub'
3159=== added file 'hooks/stub'
3160--- hooks/stub 1970-01-01 00:00:00 +0000
3161+++ hooks/stub 2013-08-21 10:46:51 +0000
3162@@ -0,0 +1,18 @@
3163+#!/bin/bash
3164+set -e
3165+
3166+export HOME=/root
3167+export PATH=$PATH:/usr/local/rvm/bin
3168+source /usr/local/rvm/scripts/rvm
3169+
3170+hook_name=$(basename $0)
3171+
3172+if [[ "$hook_name" == *-relation-* ]]; then
3173+ cookbook_name="${hook_name%-relation*}-relation"
3174+ recipe_name=${hook_name#*relation-}
3175+ else
3176+ cookbook_name='rack'
3177+ recipe_name=$hook_name
3178+fi
3179+
3180+juju_chef-solo -o "recipe[juju::bootstrap],recipe[$cookbook_name::$recipe_name]"
3181\ No newline at end of file
3182
3183=== modified file 'metadata.yaml'
3184--- metadata.yaml 2013-07-11 19:25:36 +0000
3185+++ metadata.yaml 2013-08-21 10:46:51 +0000
3186@@ -1,7 +1,6 @@
3187 name: rack
3188-subordinate: true
3189 summary: A modular Ruby webserver interface
3190-maintainer: Altoros Systems, Inc. <pavel.pachkovskij@altoros.com>
3191+maintainer: "Altoros Systems, Inc. <pavel.pachkovskij@altoros.com>"
3192 description: |
3193 Rack provides a minimal, modular and adaptable interface
3194 for developing web applications in Ruby.
3195@@ -9,25 +8,28 @@
3196 it unifies and distills the API for web servers, web frameworks, and
3197 software in between (the so-called middleware) into a single method call.
3198 categories:
3199- - app-servers
3200+ - app-servers
3201 provides:
3202- god:
3203- interface: god
3204+ proxy:
3205+ interface: http
3206+ nagios:
3207+ interface: monitors
3208+ nrpe:
3209+ interface: local-monitors
3210 scope: container
3211- optional: true
3212 requires:
3213- rack-server:
3214- interface: rack
3215- scope: container
3216+ postgresql:
3217+ interface: pgsql
3218+ optional: true
3219 mysql:
3220 interface: mysql
3221 optional: true
3222- postgresql:
3223- interface: pgsql
3224- optional: true
3225- resque:
3226+ mongodb:
3227+ interface: mongodb
3228+ optional: true
3229+ memcached:
3230+ interface: memcache
3231+ optional: true
3232+ redis:
3233 interface: redis
3234- optional: true
3235- mongoid:
3236- interface: mongodb
3237- optional: true
3238+ optional: true
3239\ No newline at end of file
3240
3241=== modified file 'revision'
3242--- revision 2013-03-01 11:10:06 +0000
3243+++ revision 2013-08-21 10:46:51 +0000
3244@@ -1,1 +1,1 @@
3245-4
3246\ No newline at end of file
3247+10
3248
3249=== added directory 'tests'
3250=== added file 'tests/100_deploy.test'
3251--- tests/100_deploy.test 1970-01-01 00:00:00 +0000
3252+++ tests/100_deploy.test 2013-08-21 10:46:51 +0000
3253@@ -0,0 +1,49 @@
3254+#!/bin/sh
3255+
3256+teardown() {
3257+ juju destroy-service html2haml
3258+ if [ -n "$datadir" ] ; then
3259+ if [ -f $datadir/passed ]; then
3260+ rm -r $datadir
3261+ else
3262+ echo $datadir preserved
3263+ fi
3264+ fi
3265+}
3266+
3267+trap teardown EXIT
3268+
3269+juju deploy rack --config html2haml.yml html2haml
3270+juju expose html2haml
3271+
3272+for try in `seq 1 600` ; do
3273+ host=`juju status | get-unit-info html2haml public-address`
3274+ if [ -z "$host" ] ; then
3275+ sleep 1
3276+ else
3277+ break
3278+ fi
3279+done
3280+
3281+if [ -z "$host" ] ; then
3282+ echo FAIL: status timed out
3283+ exit 1
3284+fi
3285+
3286+datadir=`mktemp -d ${TMPDIR:-/tmp}/wget.test.XXXXXXX`
3287+echo INFO: datadir=$datadir
3288+
3289+wget --tries=100 --timeout=6 http://$host/ -O - -a $datadir/wget.log | grep -q '<title>' || continue
3290+
3291+if [ $try -eq 600 ] ; then
3292+ echo FAIL: Timed out waiting.
3293+ exit 1
3294+fi
3295+
3296+touch $datadir/passed
3297+
3298+trap - EXIT
3299+teardown
3300+
3301+echo PASS: deployed successfully
3302+exit 0
3303\ No newline at end of file
3304
3305=== added file 'tests/get-unit-info'
3306--- tests/get-unit-info 1970-01-01 00:00:00 +0000
3307+++ tests/get-unit-info 2013-08-21 10:46:51 +0000
3308@@ -0,0 +1,45 @@
3309+#!/usr/bin/python
3310+# machines:
3311+# 0: {dns-name: ec2-50-17-84-127.compute-1.amazonaws.com, instance-id: i-8c5c3fec}
3312+# 1: {dns-name: ec2-184-73-102-113.compute-1.amazonaws.com, instance-id: i-14a2c174}
3313+# 2: {dns-name: ec2-75-101-184-93.compute-1.amazonaws.com, instance-id: i-e0a2c180}
3314+# services:
3315+# mysql:
3316+# charm: local:mysql-11
3317+# relations: {db: wordpress}
3318+# units:
3319+# mysql/0:
3320+# machine: 2
3321+# relations:
3322+# db: {state: up}
3323+# state: started
3324+# wordpress:
3325+# charm: local:wordpress-31
3326+# exposed: true
3327+# relations: {db: mysql}
3328+# units:
3329+# wordpress/0:
3330+# machine: 1
3331+# open-ports: []
3332+# relations: {}
3333+# state: null
3334+
3335+import yaml
3336+import sys
3337+from subprocess import Popen, PIPE
3338+
3339+def main():
3340+ d = yaml.safe_load(Popen(['juju','status'],stdout=PIPE).stdout)
3341+ srv = d.get("services", {}).get(sys.argv[1])
3342+ if srv is None:
3343+ return
3344+ units = srv.get("units", {})
3345+ if units is None:
3346+ return
3347+ item = units.items()[0][1].get(sys.argv[2])
3348+ if item is None:
3349+ return
3350+ print item
3351+
3352+if __name__ == "__main__":
3353+ main()
3354\ No newline at end of file
3355
3356=== added file 'tests/html2haml.yml'
3357--- tests/html2haml.yml 1970-01-01 00:00:00 +0000
3358+++ tests/html2haml.yml 2013-08-21 10:46:51 +0000
3359@@ -0,0 +1,2 @@
3360+html2haml:
3361+ repo: https://github.com/twilson63/html2haml.git
3362\ No newline at end of file

Subscribers

People subscribed via source and target branches

to all changes: