knife-cleanup 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -6
- data/lib/chef/knife/cleanup_versions.rb +8 -1
- data/lib/knife-cleanup/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
Knife-Cleanup
|
2
2
|
===
|
3
3
|
|
4
|
-
This is a [Knife](http://wiki.opscode.com/display/chef/Knife) plugin to help cleanup unused cookbook versions from a chef server. If you have an automated system that creates new cookbook versions for each commit (maybe something like [chef-jenkins][chefjenkins] then your chef server might end up with thousands of cookbook versions and they most of them are unused. And this is perfectly fine... Still if this annoys you, this plugin will help you cleanup unused versions by looking into each environment and keeping the versions used there and also the latest version of each cookbook. Before deleting any cookbooks it will download and create a backup of them under `.cleanup/cookbook_name/`.
|
4
|
+
This is a [Knife](http://wiki.opscode.com/display/chef/Knife) plugin to help cleanup unused cookbook versions from a chef server. If you have an automated system that creates new cookbook versions for each commit (maybe something like [chef-jenkins][chefjenkins]) then your chef server might end up with thousands of cookbook versions and they most of them are unused. And this is perfectly fine... Still if this annoys you, this plugin will help you cleanup unused versions by looking into each environment and keeping the versions used there and also the latest version of each cookbook. Before deleting any cookbooks it will download and create a backup of them under `.cleanup/cookbook_name/`.
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
|
8
8
|
You will need chef installed and a working knife config; development has been done on chef 11, but it should work with any version higher than 0.10.10
|
9
9
|
|
10
10
|
```bash
|
11
|
-
|
11
|
+
gem install knife-cleanup
|
12
12
|
```
|
13
13
|
|
14
14
|
## Usage
|
@@ -16,21 +16,22 @@ You will need chef installed and a working knife config; development has been do
|
|
16
16
|
For a list of commands:
|
17
17
|
|
18
18
|
```bash
|
19
|
-
|
19
|
+
knife cleanup --help
|
20
20
|
```
|
21
21
|
|
22
22
|
Currently there is only one command available:
|
23
23
|
|
24
24
|
```bash
|
25
|
-
|
25
|
+
knife cleanup versions <-D>
|
26
26
|
```
|
27
27
|
|
28
|
-
If you run it without --delete (-D) it will show you the versions that would be deleted. In delete mode it will save first a backup of the version and then proceed to delete it. I've seen various strange situations where knife is not able to download the cookbook version from the server, and be aware that we will skip those cases and there will not be a backup for such corrupted versions. You've been warned.
|
28
|
+
If you run it without --delete (-D) it will show you the versions that would be deleted, but not delete anything. In delete mode it will save first a backup of the version and then proceed to delete it. I've seen various strange situations where knife is not able to download the cookbook version from the server, and be aware that we will skip those cases and there will not be a backup for such corrupted versions. You've been warned.
|
29
29
|
|
30
30
|
Note: this is by no means production ready; I'm using it with success for my needs and hopefully you will find it useful too. Be sure to do a backup your chef server ([knife-backup][knifebackup] before using it, etc.
|
31
31
|
|
32
32
|
## Todo/Ideas
|
33
|
-
|
33
|
+
|
34
|
+
* Make backup optional and location of them configurable
|
34
35
|
* Cleanup databags
|
35
36
|
* Cleanup unused cookbooks
|
36
37
|
|
@@ -33,6 +33,13 @@ module ServerCleanup
|
|
33
33
|
:description => "Delete the unused versions of the cookbooks",
|
34
34
|
:boolean => true
|
35
35
|
|
36
|
+
option :backup,
|
37
|
+
:short => "-B",
|
38
|
+
:long => "--backup",
|
39
|
+
:description => "Backup the cookbook versions that are being deleted",
|
40
|
+
:boolean => true
|
41
|
+
:default => false
|
42
|
+
|
36
43
|
def run
|
37
44
|
cookbooks
|
38
45
|
end
|
@@ -81,7 +88,7 @@ module ServerCleanup
|
|
81
88
|
print "#{cb_ver} "
|
82
89
|
if config[:delete]
|
83
90
|
dir = ".cleanup/#{cb}/"
|
84
|
-
backup_cookbook(cb,cb_ver,dir)
|
91
|
+
backup_cookbook(cb,cb_ver,dir) if config[:backup]
|
85
92
|
delete_cookbook(cb, cb_ver)
|
86
93
|
end
|
87
94
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-cleanup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef
|