knife-bootstrapsync 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +13 -0
- data/README.md +18 -0
- data/knife-bootstrapsync.gemspec +15 -0
- data/lib/chef/knife/bootstrapsync.rb +75 -0
- data/lib/knife-bootstrapsync/version.rb +8 -0
- metadata +82 -0
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright 2013 Heavy Water Operations LLC
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Knife Bootstrap Sync
|
2
|
+
|
3
|
+
Sync local directories to remote nodes, prior to bootstrap.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Use the `--sync-directory` option with the local directory
|
8
|
+
and remote directory separated by a `:`. The general use
|
9
|
+
case is to upload cookbooks for use by chef-solo:
|
10
|
+
|
11
|
+
```
|
12
|
+
$ knife bootstrap 127.0.0.2 --sync-directory './cookbooks:/var/chef/cache/cookbooks' ...
|
13
|
+
```
|
14
|
+
|
15
|
+
# Info
|
16
|
+
|
17
|
+
* Repository: https://github.com/heavywater/knife-bootstrapsync
|
18
|
+
* IRC: Freenode @ #heavywater
|
@@ -0,0 +1,15 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__)) + '/lib/'
|
2
|
+
require 'knife-bootstrapsync/version'
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'knife-bootstrapsync'
|
5
|
+
s.version = Knife::Bootstrapsync::VERSION.version
|
6
|
+
s.summary = 'Bootstrap directory sync'
|
7
|
+
s.author = 'Chris Roberts'
|
8
|
+
s.email = 'chrisroberts.code@gmail.com'
|
9
|
+
s.homepage = 'http://github.com/chrisroberts/knife-bootstrapsync'
|
10
|
+
s.description = 'Bootstrap directory sync'
|
11
|
+
s.require_path = 'lib'
|
12
|
+
s.add_dependency 'chef'
|
13
|
+
s.add_dependency 'net-sftp'
|
14
|
+
s.files = Dir['**/*']
|
15
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'chef/knife/bootstrap'
|
2
|
+
|
3
|
+
module Bootstrapsync
|
4
|
+
def sync_bootstrap_run
|
5
|
+
sync_directory
|
6
|
+
non_sync_bootstrap_run
|
7
|
+
end
|
8
|
+
|
9
|
+
def sync_directory
|
10
|
+
require 'net/sftp'
|
11
|
+
host = name_args.first
|
12
|
+
user = config[:ssh_user]
|
13
|
+
args = {}
|
14
|
+
args[:password] = config[:ssh_password] if config[:ssh_password]
|
15
|
+
args[:keys] = [config[:identity_file]] if config[:identity_file]
|
16
|
+
begin
|
17
|
+
Net::SFTP.start(host, user, args) do |sftp|
|
18
|
+
begin
|
19
|
+
sftp.mkdir!(File.dirname(Chef::Config[:knife][:directory_sync][:remote]))
|
20
|
+
rescue
|
21
|
+
puts 'Cookbook dir already exists'
|
22
|
+
end
|
23
|
+
sftp.upload!(
|
24
|
+
Chef::Config[:knife][:directory_sync][:local],
|
25
|
+
Chef::Config[:knife][:directory_sync][:remote],
|
26
|
+
:mkdir => true
|
27
|
+
)
|
28
|
+
end
|
29
|
+
rescue
|
30
|
+
puts 'Upload Failed'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class << self
|
35
|
+
def included(klass)
|
36
|
+
klass.class_eval do
|
37
|
+
alias_method :non_sync_bootstrap_run, :run
|
38
|
+
alias_method :run, :sync_bootstrap_run
|
39
|
+
|
40
|
+
option(:sync_directory,
|
41
|
+
:long => '--sync-directory LOCAL_PATH:REMOTE_PATH',
|
42
|
+
:description => 'Sync local directory to remote server',
|
43
|
+
:proc => Proc.new{ |k|
|
44
|
+
dirs = k.split(':')
|
45
|
+
Chef::Config[:knife][:directory_sync] = {:local => dirs.first, :remote => dirs.last}
|
46
|
+
}
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
Chef::Knife::Bootstrap.send(:include, Bootstrapsync)
|
54
|
+
|
55
|
+
|
56
|
+
begin
|
57
|
+
require 'chef/knife/rackspace_server_create'
|
58
|
+
|
59
|
+
class Chef
|
60
|
+
class Knife
|
61
|
+
class RackspaceServerCreate
|
62
|
+
option(:sync_directory,
|
63
|
+
:long => '--sync-directory LOCAL_PATH:REMOTE_PATH',
|
64
|
+
:description => 'Sync local directory to remote server',
|
65
|
+
:proc => Proc.new{ |k|
|
66
|
+
dirs = k.split(':')
|
67
|
+
Chef::Config[:knife][:directory_sync] = {:local => dirs.first, :remote => dirs.last}
|
68
|
+
}
|
69
|
+
)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
rescue
|
75
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: knife-bootstrapsync
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Chris Roberts
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-06-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: chef
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: net-sftp
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Bootstrap directory sync
|
47
|
+
email: chrisroberts.code@gmail.com
|
48
|
+
executables: []
|
49
|
+
extensions: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
files:
|
52
|
+
- lib/knife-bootstrapsync/version.rb
|
53
|
+
- lib/chef/knife/bootstrapsync.rb
|
54
|
+
- README.md
|
55
|
+
- LICENSE
|
56
|
+
- knife-bootstrapsync.gemspec
|
57
|
+
homepage: http://github.com/chrisroberts/knife-bootstrapsync
|
58
|
+
licenses: []
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 1.8.24
|
78
|
+
signing_key:
|
79
|
+
specification_version: 3
|
80
|
+
summary: Bootstrap directory sync
|
81
|
+
test_files: []
|
82
|
+
has_rdoc:
|