lisausa-knife-plugins 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 lisausa-knife-sshconfig.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Ryan Taylor Long
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,32 @@
1
+ # Lisausa Knife Plugins
2
+
3
+ These are plugins for the Chef utility `knife`, for use by LISAUSA employees
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'lisausa-knife-plugins', github: 'lisausa/lisausa-knife-plugins'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ ## Usage
16
+
17
+ ### .ssh/config
18
+
19
+ knife setup ssh
20
+
21
+ This is a plugin for Knife that helps grab all nodes within the LISA cloud and presents you with
22
+ a chunk of .ssh/config that provides host name mapping. This has the bonus of allowing for tab
23
+ completion, as well.
24
+
25
+ Take the given chunk of `.ssh/config` and copy-and-paste it into your `~/.ssh/config` file.
26
+
27
+ It's also useful to add something like this, so you wont need to specify your SSH login each time:
28
+
29
+ Host *.lisausa.net
30
+ IdentityFile ~/.ssh/id_rsa
31
+ User rlong
32
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,30 @@
1
+ require_relative '../../core_ext'
2
+ require 'chef/knife'
3
+
4
+ class LisausaKnifePlugins::SetupSsh < ::Chef::Knife
5
+ banner 'knife setup ssh'
6
+
7
+ deps do
8
+ require 'chef/shef/ext'
9
+ end
10
+
11
+ # This method will be executed when you run this knife command.
12
+ def run
13
+ Shef::Extensions.extend_context_object(self)
14
+ config = []
15
+ nodes.all do |n|
16
+ next if /vagrant/.match(n.name)
17
+ name = n.name
18
+ name << '.lisausa.net' unless /\.lisausa.net\Z/.match(n.name)
19
+
20
+ config << <<-END.strip_heredoc
21
+ Host #{name}
22
+ HostName #{n[:cloud][:public_hostname]}
23
+ END
24
+ end
25
+
26
+ ui.msg "Copy and paste the following into your ~/.ssh/config file:"
27
+ puts "## This is generated by `knife setup ssh`:\n\n#{config.join("\n")}"
28
+ end
29
+
30
+ end
data/lib/core_ext.rb ADDED
@@ -0,0 +1,8 @@
1
+ class String
2
+
3
+ def strip_heredoc
4
+ indent = scan(%r/^[ \t]*(?=\S)/).min.size rescue 0
5
+ gsub(%r/^[ \t]{#{indent}}/, '')
6
+ end
7
+
8
+ end
@@ -0,0 +1,3 @@
1
+ module LisausaKnifePlugins
2
+ VERSION = "0.0.3"
3
+ end
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/lisausa_knife_plugins', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'lisausa-knife-plugins'
6
+ maintainers = {
7
+ 'Ryan Taylor Long' => 'ryan.long@lisausa.net'
8
+ }
9
+ gem.authors = maintainers.keys
10
+ gem.email = maintainers.values
11
+
12
+ gem.description = <<-DESC.gsub(/\s+/, ' ')
13
+ These are plugins for the Chef utility `knife`, for use by LISAUSA employees
14
+ DESC
15
+ gem.summary = gem.description
16
+ gem.homepage = 'https://github.com/lisausa/knife-plugins'
17
+
18
+ gem.executables = [] # `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ gem.files = `git ls-files`.split("\n")
20
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ gem.require_paths = ['lib']
22
+
23
+ gem.version = LisausaKnifePlugins::VERSION
24
+
25
+ gem.add_dependency 'chef'
26
+
27
+ gem.add_development_dependency 'rake'
28
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lisausa-knife-plugins
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ryan Taylor Long
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-28 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: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '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'
46
+ description: ! ' These are plugins for the Chef utility `knife`, for use by LISAUSA
47
+ employees '
48
+ email:
49
+ - ryan.long@lisausa.net
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - LICENSE
57
+ - README.md
58
+ - Rakefile
59
+ - lib/chef/knife/setup_ssh.rb
60
+ - lib/core_ext.rb
61
+ - lib/lisausa_knife_plugins.rb
62
+ - lisausa-knife-plugins.gemspec
63
+ homepage: https://github.com/lisausa/knife-plugins
64
+ licenses: []
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ segments:
76
+ - 0
77
+ hash: -1886834353129127857
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ segments:
85
+ - 0
86
+ hash: -1886834353129127857
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 1.8.23
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: These are plugins for the Chef utility `knife`, for use by LISAUSA employees
93
+ test_files: []