klarna_chef 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in klarna_chef.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Daniel Salmeron Amselem
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # Klarna Chef
2
+
3
+ This is a tool that will help you automate the process of provisioning machines using Chef-Solo.
4
+
5
+ ## Installation
6
+
7
+ gem install klarna_chef
8
+
9
+ ## Usage
10
+
11
+ The following command will initialize a Chef directory structure like `rails new` does for Rails projects.
12
+
13
+ klarna-chef new <name>
14
+
15
+ ## Contributing
16
+
17
+ 1. Fork it
18
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
19
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
20
+ 4. Push to the branch (`git push origin my-new-feature`)
21
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/klarna-chef ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'klarna_chef/cli'
4
+
5
+ KlarnaChef::CLI.start
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'klarna_chef/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "klarna_chef"
8
+ gem.version = KlarnaChef::VERSION
9
+ gem.authors = ["Daniel Salmeron Amselem"]
10
+ gem.email = ["daniel.amselem@klarna.com"]
11
+ gem.description = %q{Command Line utility to manage chef cookbooks.}
12
+ gem.summary = %q{Command Line utility to manage chef cookbooks.}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_development_dependency 'rspec', '~> 2.12.0'
21
+ gem.add_development_dependency 'aruba', '~> 0.5.0'
22
+
23
+ gem.add_dependency 'thor', '~> 0.16.0'
24
+ end
@@ -0,0 +1,13 @@
1
+ require 'thor'
2
+
3
+ require 'klarna_chef/generators/chef'
4
+
5
+ module KlarnaChef
6
+ class CLI < Thor
7
+
8
+ desc 'new NAME', 'Initializes a Chef project for your team'
9
+ def new(name)
10
+ KlarnaChef::Generators::Chef.start([name])
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,6 @@
1
+ # vi:ft=ruby:
2
+
3
+ site 'http://community.opscode.com/api/v1'
4
+
5
+ cookbook 'rvm', :github => 'fnichol/chef-rvm'
6
+ cookbook 'web', :git => 'gitosis@git.internal.machines:cookbook-web.git'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'librarian'
4
+ gem 'gusteau'
5
+ gem 'vagrant', '~> 1.0.5'
@@ -0,0 +1,67 @@
1
+ # TLV Chef
2
+
3
+ This project will allow you to provision a machine with a default TLV web stack.
4
+
5
+ ## Dependencies
6
+
7
+ - [gusteau](http://gusteau.gs/) - A fine Chef Solo wrapper.
8
+ - [vagrant](http://www.vagrantup.com/) - Vagrant is a tool for building and distributing working environments.
9
+ - [librarian-chef](https://github.com/applicationsonline/librarian) - Bundler for your Chef Cookbooks.
10
+
11
+ ## Setup
12
+
13
+ First of all you have to install all the dependencies of this project:
14
+
15
+ bundle install
16
+
17
+ Fetch all the cookbooks:
18
+
19
+ librarian-chef install
20
+
21
+ ## Usage
22
+
23
+ #### Vagrant
24
+
25
+ If you take a look at the `/nodes` directory, you will see there is already a `vagrant.yml` file. This node will allow you to instantly provision the Vagrant VM with your cookbooks and check that they are working, in a safe and reproducible environment.
26
+
27
+ Create the Vagrant VM:
28
+
29
+ vagrant up
30
+
31
+ To provision a node you will have to define a new node under `/nodes` or use an existing one, for example the `vagrant` node:
32
+
33
+ gusteau vagrant provision -b
34
+
35
+ Note that the previous command uses a `-b` option. For more information, take a look at the [gusteau documentation](https://github.com/locomote/gusteau).
36
+
37
+ **Congratulations!** You should now have a VM provisioned with all the components of TLV's web stack.
38
+
39
+ #### Production/Staging (or any other node)
40
+
41
+ Take a look at the `nodes/vagrant.yml` example and use it to create your own node for your production/staging machines. Then:
42
+
43
+ gusteau <node-name> provision -b
44
+
45
+ Where `<node-name>` is the name of the node file (without the `.yml` extension).
46
+
47
+ ## Roles
48
+
49
+ The only role available in this project is `web_app` and it simply defines a [`run_list`](http://wiki.opscode.com/display/chef/Roles#Roles-run_list) with the default recipe of the `web` cookbook.
50
+
51
+ ## Attributes
52
+
53
+ For the list of attributes available, check the [cookbook-web](http://git.hq.kred/gitweb/?p=cookbook-web.git;a=summary) repository.
54
+
55
+ ## Vagrant
56
+
57
+ The most common commands that you will need for Vagrant are:
58
+
59
+ - `vagrant up`: Boot up the VM.
60
+ - `vagrant halt` Stop the VM.
61
+ - `vagrant reload`: Restart the VM.
62
+ - `vagrant ssh`: SSH to the VM.
63
+ - `vagrant destroy`: Destroy the VM.
64
+
65
+ ## TODO
66
+
67
+ - Move the `chef-rvm` cookbook from the `Cheffile` to `cookbook-web` `metadata.rb`.
@@ -0,0 +1,11 @@
1
+ # vi:ft=ruby:
2
+
3
+ Vagrant::Config.run do |config|
4
+ config.vm.box_url = "https://s3.amazonaws.com/itmat-public/centos-6.3-chef-10.14.2.box"
5
+ config.vm.box = "centos63"
6
+
7
+ config.vm.network :hostonly, "33.33.33.10"
8
+
9
+ config.vm.forward_port 80, 8080
10
+ config.vm.forward_port 3000, 4000
11
+ end
@@ -0,0 +1,4 @@
1
+ {
2
+ "id": "license",
3
+ "key": "Place here the NewRelic key"
4
+ }
@@ -0,0 +1,11 @@
1
+ json:
2
+
3
+ roles:
4
+ - web_app
5
+
6
+ server:
7
+ host: <host of the machine to provision>
8
+ user: <user to ssh to the machine>
9
+ password: <password to ssh to the machine>
10
+ platform: centos
11
+
@@ -0,0 +1,4 @@
1
+ {
2
+ "id": "example",
3
+ "key": "some ssh public key"
4
+ }
@@ -0,0 +1,3 @@
1
+ /cookbooks
2
+ /tmp
3
+ .vagrant
@@ -0,0 +1,17 @@
1
+ json:
2
+ net:
3
+ IP: 33.33.33.10
4
+ web:
5
+ sudo:
6
+ users:
7
+ - deploy
8
+ - vagrant
9
+
10
+ roles:
11
+ - web_app
12
+
13
+ server:
14
+ host: 33.33.33.10
15
+ user: vagrant
16
+ password: vagrant
17
+ platform: centos
@@ -0,0 +1,6 @@
1
+ name "web_app"
2
+ description "A web application common stack"
3
+
4
+ run_list(%w(
5
+ recipe[web]
6
+ ))
@@ -0,0 +1,54 @@
1
+ require 'thor/group'
2
+
3
+ module KlarnaChef
4
+ module Generators
5
+ class Chef < Thor::Group
6
+ include Thor::Actions
7
+
8
+ argument :name, :type => :string
9
+
10
+ source_root File.dirname(__FILE__) + '/chef'
11
+
12
+ def create_gitignore
13
+ template('gitignore', "#{name}/.gitignore")
14
+ end
15
+
16
+ def create_web_app_role
17
+ template('web_app_role.rb', "#{name}/roles/web_app.rb")
18
+ end
19
+
20
+ def create_example_user_data_bag
21
+ template('example_user_data_bag.json', "#{name}/data_bags/users/example.json")
22
+ end
23
+
24
+ def create_example_newrelic_data_bag
25
+ template('example_newrelic_data_bag.json', "#{name}/data_bags/newrelic/license.json")
26
+ end
27
+
28
+ def create_vagrant_node
29
+ template('vagrant.yml', "#{name}/nodes/vagrant.yml")
30
+ end
31
+
32
+ def create_example_node
33
+ template('example_node.yml', "#{name}/nodes/example.yml")
34
+ end
35
+
36
+ def create_cheffile
37
+ template('Cheffile', "#{name}/Cheffile")
38
+ end
39
+
40
+ def create_readme
41
+ template('README.md', "#{name}/README.md")
42
+ end
43
+
44
+ def create_gemfile
45
+ template('Gemfile', "#{name}/Gemfile")
46
+ end
47
+
48
+ def create_vagrantfile
49
+ template('Vagrantfile', "#{name}/Vagrantfile")
50
+ end
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,3 @@
1
+ module KlarnaChef
2
+ VERSION = "1.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ require "klarna_chef/version"
2
+
3
+ module KlarnaChef
4
+ end
File without changes
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: klarna_chef
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Daniel Salmeron Amselem
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.12.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 2.12.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: aruba
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.5.0
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.5.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: thor
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.16.0
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.16.0
62
+ description: Command Line utility to manage chef cookbooks.
63
+ email:
64
+ - daniel.amselem@klarna.com
65
+ executables:
66
+ - klarna-chef
67
+ extensions: []
68
+ extra_rdoc_files: []
69
+ files:
70
+ - .gitignore
71
+ - Gemfile
72
+ - LICENSE.txt
73
+ - README.md
74
+ - Rakefile
75
+ - bin/klarna-chef
76
+ - klarna_chef.gemspec
77
+ - lib/klarna_chef.rb
78
+ - lib/klarna_chef/cli.rb
79
+ - lib/klarna_chef/generators/chef.rb
80
+ - lib/klarna_chef/generators/chef/Cheffile
81
+ - lib/klarna_chef/generators/chef/Gemfile
82
+ - lib/klarna_chef/generators/chef/README.md
83
+ - lib/klarna_chef/generators/chef/Vagrantfile
84
+ - lib/klarna_chef/generators/chef/example_newrelic_data_bag.json
85
+ - lib/klarna_chef/generators/chef/example_node.yml
86
+ - lib/klarna_chef/generators/chef/example_user_data_bag.json
87
+ - lib/klarna_chef/generators/chef/gitignore
88
+ - lib/klarna_chef/generators/chef/vagrant.yml
89
+ - lib/klarna_chef/generators/chef/web_app_role.rb
90
+ - lib/klarna_chef/version.rb
91
+ - spec/klarna_chef_spec.rb
92
+ homepage: ''
93
+ licenses: []
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 1.8.24
113
+ signing_key:
114
+ specification_version: 3
115
+ summary: Command Line utility to manage chef cookbooks.
116
+ test_files:
117
+ - spec/klarna_chef_spec.rb