head_chef 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDc2NGY2YjQxODc1ZjgwNWUzNGI5NWI5Y2YzY2ZlZDNlYzRlYWYwYQ==
4
+ MmM3MWRhZmNhMmE4ZTRkZDYyNDE0MGM0YzlhOTE5YjA1MmVmZDZiMw==
5
5
  data.tar.gz: !binary |-
6
- NzA5MTRhODJiNDMwZmZlYmFjODM4NTAwMmRiNWZhZTE4N2YzZjNhYg==
6
+ MTQ2NDMyYzU2NGMxNTc3MTk5NDk5ZWE1OWU4OWZmMGVmY2Y1NDQ1Mg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTYzMDNhYTNiOTQyMDczNWQyODNlODBjNGU4MWFjNGNlMjhhYzdhYzk2OWEz
10
- YTM5YTkzZDM4YTlmNWYxN2NlMWU5YjAyMjE2MzU2YTdlODg5NGMxMDUyMTEx
11
- NDk5NmI1MGRjMzZkZDFiZDExY2FlZDg4NmI3OWE3OGU1NzEyY2Q=
9
+ Y2I4ZmFmZmIzNWE5OTcyOTlhMWQ0MDkwYzlhNDE2NTVkM2ZjMjlmODBlMDBl
10
+ MTM2MjI0YzNiOWU4ZTIxMzFjNDIxNDI4MmE0NWMzZTY0NmU0NjA1YWIyZTM0
11
+ MjUxNjE0ODRlOWM1OWNkMGI1YTYwYTVlNmY4YzA2MWIxZWM4MTM=
12
12
  data.tar.gz: !binary |-
13
- NjIyMjNjODBhNmQ0OWRlNjhjMzg0ZDBkNjA1MmE5MjRhNDQ2YmRlNjViMWEx
14
- YzJmMjg3MWQ0ODhiZDcwZWQ5NWFlZDBiMDEwNWJhNDZkM2U4NWJmZWE3NzBj
15
- MmQ1ZmExMTZkYWNiZTcxMThmMDQ1NjU2YTU1N2QzNzZjYjg1NDQ=
13
+ NzdlNzM0NzliZjk4Y2IxYmMyZjUxOTAyY2JkYzgxMTQzYzUyNTQyZWY5ZWMw
14
+ N2JiYTUzOTA4ODliMTY1MzJhMjBiODBhZDhhMTY5ZGU3NDM1OTg3OTIzMDZi
15
+ NmE2ZTlmYTUzOTA0ODEyODBlMjgzMjU3MDY4MmY1ZDYxZTJhNTk=
data/README.md CHANGED
@@ -1,38 +1,184 @@
1
- Head Chef
2
- ========
1
+ #Head Chef
2
+ Manage Chef Environments with Berkshelf, Ridley, and Git
3
3
 
4
- The head-chef gem can be used to create environments based on the
5
- branches in a git repository containing a master cookbook that uses
6
- Berkshelf for dependency management.
4
+ #Installation
5
+ Add Head Chef to your repository's Gemfile:
7
6
 
8
- Different Chef environments (eg. production and non-production) may
9
- be located in different Chef organizations; this is configurable.
7
+ ```
8
+ gem 'head_chef'
9
+ ```
10
+ Or run in as a standalone
11
+
12
+ ```
13
+ gem install head_chef
14
+ ```
10
15
 
11
16
  #Usage
17
+ Head Chef manages Chef Enviroments using [Berkshelf](https://github.com/berkshelf/berkshelf). Chef Server connections are made via [Ridley](https://github.com/RiotGames/ridley), and are controlled by a [`knife.rb`](http://docs.opscode.com/config_rb_knife.html) file, which should be located in a `.chef` directory. Head Chef will use the closest `.chef/knife.rb` found in its or its parents directories, identical to the Chef CLI tool [`Knife`](http://docs.opscode.com/knife.html).
18
+
19
+ **Head Chef must be run in the root of a `git` repository.**
12
20
 
13
- To create or update the environment for the current branch:
21
+ _Note: It is up to the user to manage the Berksfile and Berksfile.lock_
22
+ ##Environment
23
+ The following commands are under `head-chef env` and perform actions on Chef Environments.
24
+
25
+ **By default, the Chef Environment used will match the current git branch.**
26
+
27
+ For example if the current git branch is `test`, these commands will be run against the Chef Environment named `test`, if it exists.
28
+
29
+ These commands can be passed the following arguments:
14
30
 
15
- ```bash
16
- head-chef env sync
31
+ ```
32
+ -e <environment>, Applies to the specified Chef Environment
17
33
  ```
18
34
 
19
- The sync command accepts these options:
35
+ ###diff
36
+ View cookbook version constraint diff between local Berksfile and Chef Environment.
37
+
38
+ ```
39
+ $ head-chef env diff
40
+ ```
41
+
42
+ Sample output:
43
+
44
+ ```
45
+ Loading environment test from chef server...
46
+ Loading cookbooks from berkshelf...
47
+ Calculating diff...
48
+ ADD:
49
+ nginx: 2.0.4
50
+ apt: 2.3.0
51
+ bluepill: 2.3.0
52
+ rsyslog: 1.9.0
53
+ build-essential: 1.4.2
54
+ ohai: 1.1.12
55
+ runit: 1.4.0
56
+ yum: 2.4.2
57
+ REMOVE:
58
+ java: 1.15.4
59
+ windows: 1.11.0
60
+ chef_handler: 1.1.4
61
+ aws: 1.0.0
62
+ ```
63
+
64
+ ###list
65
+ View Chef Environment cookbooks version contraints
66
+
67
+ ```
68
+ $ head-chef env list
69
+ ```
70
+
71
+ Sample output:
72
+
73
+ ```
74
+ COOKBOOKS:
75
+ aws: 1.0.0
76
+ chef_handler: 1.1.4
77
+ java: 1.15.4
78
+ windows: 1.11.0
79
+ ```
80
+
81
+ ###sync
82
+ `sync` local Berksfile's cookbook version constraints with Chef Environment.
83
+
84
+ **The Chef Environment will be created if it does not exist.**
85
+
86
+ `sync` will also ensure all cookbooks in the environment are present on Chef Server, and that the cookbooks contain the correct content for their version.
87
+
88
+ ```
89
+ $ head-chef env sync
90
+ ```
91
+
92
+ A conflict will arise when a cookbook to be uploaded matches a cookbook on Chef Server in version number, but the cookbooks do not have the same content. In general, conflicts will arise when a cookbook has been updated, but the version number was not changed. More often than not, this should be resolved by simply updating the cookbook version number, however, the force option can be used to overwrite the remote cookbook on Chef Server with the local version of the cookbook. This should only be used in exceptional circumstances.
20
93
 
21
- ```bash
22
- --force, Overwrites cookbooks on chef server
23
94
  ```
95
+ $ head-chef env sync --force
96
+ ```
24
97
 
25
- To compare the differences between the current branch and the
26
- environment in use on the Chef server:
98
+ Sample output:
27
99
 
28
- ```bash
29
- head-chef env diff
100
+ ```
101
+ Determing side effects of sync with chef environment test...
102
+ Uploading cookbooks to chef server...
103
+ Using nginx (2.0.4)
104
+ Using apt (2.3.0)
105
+ Using bluepill (2.3.0)
106
+ Using rsyslog (1.9.0)
107
+ Using build-essential (1.4.2)
108
+ Using ohai (1.1.12)
109
+ Using runit (1.4.0)
110
+ Using yum (2.4.2)
111
+ Uploading nginx (2.0.4) to: 'https://api.opscode.com:443/organizations/my-org'
112
+ Uploading apt (2.3.0) to: 'https://api.opscode.com:443/organizations/my-org'
113
+ Uploading bluepill (2.3.0) to: 'https://api.opscode.com:443/organizations/my-org'
114
+ Uploading rsyslog (1.9.0) to: 'https://api.opscode.com:443/organizations/my-org'
115
+ Uploading build-essential (1.4.2) to: 'https://api.opscode.com:443/organizations/my-org'
116
+ Uploading ohai (1.1.12) to: 'https://api.opscode.com:443/organizations/my-org'
117
+ Uploading runit (1.4.0) to: 'https://api.opscode.com:443/organizations/my-org'
118
+ Uploading yum (2.4.2) to: 'https://api.opscode.com:443/organizations/my-org'
119
+ Applying Berksfile.lock cookbook version to environment test...
120
+ Using nginx (2.0.4)
121
+ Using apt (2.3.0)
122
+ Using bluepill (2.3.0)
123
+ Using rsyslog (1.9.0)
124
+ Using build-essential (1.4.2)
125
+ Using ohai (1.1.12)
126
+ Using runit (1.4.0)
127
+ Using yum (2.4.2)
30
128
  ```
31
129
 
32
- The above commands accept a number of options:
130
+ Sample conflict:
33
131
 
34
- ```bash
35
- -e <environment>, Applies to the specified Chef environment
36
132
  ```
133
+ Determing side effects of sync with chef environment readme-example...
134
+ The following cookbooks are in conflict:
135
+ test_cookbook: 0.1.0
136
+ Use --force to sync environment
137
+ ```
138
+
139
+ #Workflow
140
+ Head Chef is meant to be run inside a **master cookbook**. A **master cookbook** is simply a git repository which has branches associated with Chef environment. Each branch has a Berksfile representing that environment's cookbook version constraints.
141
+
142
+ ##Testing/Development
143
+ Chef Environments can easily be created with Head Chef to be used for testing/development purposes:
144
+
145
+ - Checkout **master cookbook**
146
+ - Create a new branch
147
+ - Edit Berksfile
148
+ - Update Berksfile.lock
149
+ - head-chef env sync
150
+
151
+ These environments can be versioned by committing the branch back to the **master cookbook**, via pull request.
152
+
153
+ ##Cookbook Promotion
154
+ The following outlines a typical cookbook workflow in order to demonstate where Head Chef fits in the process:
155
+
156
+ - Update Chef cookbook until it is deemed ready for promotion (e.g. new version)
157
+ - Checkout `MasterCookbook`
158
+ - Checkout/create branch matching Chef Environment
159
+ - Edit Berksfile to include updated cookbook
160
+ - Update Berksfile.lock to include updated cookbook as well as resolve any new dependencies
161
+ - `head-chef env sync`
162
+
163
+ Similarly, all changes to environments can be versioned by committing back to the **master cookbook** repository.
164
+
165
+ ##Production
166
+ Updates to production occur in a similar fashion, but will most likely have more systems in place. Therefore, let's outline a full Chef Cookbook update workflow in production.
167
+
168
+ - Update Chef cookbook until it is deemed ready for promotion (e.g. new version)
169
+ - Checkout **master cookbook**
170
+ - Checkout/create branch matching Chef Environment
171
+ - Edit Berksfile to include updated cookbook
172
+ - Update Berksfile.lock to include updated cookbook as well as resolve any new dependencies
173
+ - Make pull request to **master cookbook**
174
+ - Pull request queues CI server build where required role cookbooks are tested in new/updated environment
175
+ - Once environment build passes, pull request is ready for merge
176
+ - After merge, environment and cookbooks can be updated via `head-chef env sync`
177
+
178
+ _Environment changes follow the same path, but exclude the cookbook update_
37
179
 
180
+ #Authors
181
+ - Mark Corwin (<mcorwin@mdsol.com>)
182
+ - Harry Wilkinson (<hwilkinson@mdsol.com>)
183
+ - Alex Trull (<atrull@mdsol.com>)
38
184
 
@@ -81,7 +81,7 @@ module HeadChef
81
81
 
82
82
  def remove_ignored_files(path)
83
83
  file_list = Dir.chdir(path) do
84
- Dir['**/*'].select { |f| File.file?(f) }
84
+ Dir['**/{*,.*}'].select { |f| File.file?(f) }
85
85
  end
86
86
 
87
87
  ignore_file = File.join(path, 'chefignore')
@@ -1,3 +1,3 @@
1
1
  module HeadChef
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: head_chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Corwin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-02 00:00:00.000000000 Z
11
+ date: 2014-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler