chef-extensions 0.1.0
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 +4 -0
- data/Gemfile +4 -0
- data/Guardfile +5 -0
- data/LICENSE +20 -0
- data/README.md +42 -0
- data/Rakefile +46 -0
- data/chef-extensions.gemspec +24 -0
- data/docs/index.html +108 -0
- data/docs/lib/chef-extensions.html +108 -0
- data/docs/lib/chef-extensions/version.html +56 -0
- data/lib/chef-extensions.rb +35 -0
- data/lib/chef-extensions/version.rb +6 -0
- metadata +91 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Gerhard Lazu
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# chef-extensions
|
2
|
+
|
3
|
+
Commands useful for checking internet connectivity, VM presence etc.
|
4
|
+
|
5
|
+
## Install it
|
6
|
+
|
7
|
+
gem install chef-extensions
|
8
|
+
|
9
|
+
## How it works
|
10
|
+
|
11
|
+
I'm only using chef-solo, so after installing the gem, require it in
|
12
|
+
`config/solo.rb`.
|
13
|
+
|
14
|
+
Then, in your cookbooks or providers, use one of the existing methods, eg:
|
15
|
+
|
16
|
+
if Chef::Extensions.wan_up?
|
17
|
+
# do some work...
|
18
|
+
end
|
19
|
+
|
20
|
+
If you want to see use-cases for the gem, check out
|
21
|
+
[apt-cookbook](https://github.com/gchef/apt-cookbook/blob/master/providers/repository.rb).
|
22
|
+
|
23
|
+
[Full gem documentation](https://gchef.github.com/chef-extensions)
|
24
|
+
|
25
|
+
## Known issues / concerns
|
26
|
+
|
27
|
+
Google's DNS **very rarely** doesn't to pings. It's reliable 99.9% of the time,
|
28
|
+
which is good enough. Would defintely benefit from having 2 IPs and falling
|
29
|
+
back to the second one before returning false.
|
30
|
+
|
31
|
+
## Note on Patches/Pull Requests
|
32
|
+
|
33
|
+
* Fork the project.
|
34
|
+
* Make your feature addition or bug fix.
|
35
|
+
* Commit, do not mess with rakefile, version, or history.
|
36
|
+
(if you want to have your own version, that is fine but bump version in a
|
37
|
+
commit by itself I can ignore when I pull)
|
38
|
+
* Send me a pull request. Bonus points for topic branches.
|
39
|
+
|
40
|
+
## Copyright
|
41
|
+
|
42
|
+
Copyright (c) 2012 Gerhard Lazu. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'rdiscount'
|
4
|
+
require 'rocco/tasks'
|
5
|
+
Rocco::make 'docs/'
|
6
|
+
|
7
|
+
desc 'Build rocco docs'
|
8
|
+
task :docs => :rocco
|
9
|
+
directory 'docs/'
|
10
|
+
# Alias for docs task
|
11
|
+
task :doc => :docs
|
12
|
+
|
13
|
+
desc 'Build docs and open in browser for the reading'
|
14
|
+
task :read => :docs do
|
15
|
+
sh 'open docs/lib/chef-extensions.html'
|
16
|
+
end
|
17
|
+
|
18
|
+
# Make index.html a copy of chef-extensions.html
|
19
|
+
file 'docs/index.html' => 'docs/lib/chef-extensions.html' do |f|
|
20
|
+
cp 'docs/lib/chef-extensions.html', 'docs/index.html', :preserve => true
|
21
|
+
end
|
22
|
+
task :docs => 'docs/index.html'
|
23
|
+
CLEAN.include 'docs/index.html'
|
24
|
+
|
25
|
+
# Update the pages/ directory clone
|
26
|
+
file 'docs/.git' => ['docs/', '.git/refs/heads/gh-pages'] do |f|
|
27
|
+
sh "cd docs && git init -q && git remote add o ../.git" if !File.exist?(f.name)
|
28
|
+
sh "cd docs && git fetch -q o && git reset -q --hard o/gh-pages && touch ."
|
29
|
+
end
|
30
|
+
CLOBBER.include 'docs/.git'
|
31
|
+
|
32
|
+
# GITHUB PAGES ===============================================================
|
33
|
+
|
34
|
+
desc 'Update gh-pages branch'
|
35
|
+
task :pages => ['docs/.git', :docs] do
|
36
|
+
rev = `git rev-parse --short HEAD`.strip
|
37
|
+
Dir.chdir 'docs' do
|
38
|
+
sh "git add *.html"
|
39
|
+
sh "git commit -m 'rebuild pages from #{rev}'" do |ok,res|
|
40
|
+
if ok
|
41
|
+
verbose { puts "gh-pages updated" }
|
42
|
+
sh "git push -q o HEAD:gh-pages"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "chef-extensions/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "chef-extensions"
|
7
|
+
s.version = Chef::Extensions::VERSION
|
8
|
+
s.authors = ["Gerhard Lazu"]
|
9
|
+
s.email = ["gerhard@lazu.co.uk"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Chef extensions, can be used stand-alone}
|
12
|
+
s.description = %q{Commands useful for checking internet connectivity, VM presence etc.}
|
13
|
+
|
14
|
+
s.rubyforge_project = "chef-extensions"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_development_dependency "rdiscount"
|
22
|
+
s.add_development_dependency "rocco"
|
23
|
+
s.add_development_dependency "guard-rocco"
|
24
|
+
end
|
data/docs/index.html
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
5
|
+
<title>chef-extensions.rb</title>
|
6
|
+
<link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<div id='container'>
|
10
|
+
<div id="background"></div>
|
11
|
+
<div id="jump_to">
|
12
|
+
Jump To …
|
13
|
+
<div id="jump_wrapper">
|
14
|
+
<div id="jump_page">
|
15
|
+
<a class="source" href="chef-extensions.html">chef-extensions.rb</a>
|
16
|
+
<a class="source" href="chef-extensions/version.html">version.rb</a>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
<table cellspacing=0 cellpadding=0>
|
21
|
+
<thead>
|
22
|
+
<tr>
|
23
|
+
<th class=docs><h1>chef-extensions.rb</h1></th>
|
24
|
+
<th class=code></th>
|
25
|
+
</tr>
|
26
|
+
</thead>
|
27
|
+
<tbody>
|
28
|
+
<tr id='section-1'>
|
29
|
+
<td class=docs>
|
30
|
+
<div class="pilwrap">
|
31
|
+
<a class="pilcrow" href="#section-1">¶</a>
|
32
|
+
</div>
|
33
|
+
|
34
|
+
</td>
|
35
|
+
<td class=code>
|
36
|
+
<div class='highlight'><pre><span class="nb">require</span> <span class="s1">'chef-extensions/version'</span>
|
37
|
+
<span class="nb">require</span> <span class="s1">'securerandom'</span>
|
38
|
+
|
39
|
+
<span class="k">module</span> <span class="nn">Chef</span>
|
40
|
+
<span class="k">module</span> <span class="nn">Extensions</span>
|
41
|
+
<span class="kp">extend</span> <span class="nb">self</span></pre></div>
|
42
|
+
</td>
|
43
|
+
</tr>
|
44
|
+
<tr id='section-2'>
|
45
|
+
<td class=docs>
|
46
|
+
<div class="pilwrap">
|
47
|
+
<a class="pilcrow" href="#section-2">¶</a>
|
48
|
+
</div>
|
49
|
+
<p><strong>Ping Google’s DNS.</strong> <br />
|
50
|
+
If it doesn’t hear back within 1s, it’s safe to
|
51
|
+
assume that we don’t have internet connectivity</p>
|
52
|
+
</td>
|
53
|
+
<td class=code>
|
54
|
+
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">wan_up?</span>
|
55
|
+
<span class="sb">`ping -c 1 8.8.8.8 -W 2`</span><span class="o">.</span><span class="n">include?</span> <span class="s2">"1 received"</span>
|
56
|
+
<span class="k">end</span></pre></div>
|
57
|
+
</td>
|
58
|
+
</tr>
|
59
|
+
<tr id='section-3'>
|
60
|
+
<td class=docs>
|
61
|
+
<div class="pilwrap">
|
62
|
+
<a class="pilcrow" href="#section-3">¶</a>
|
63
|
+
</div>
|
64
|
+
<p><strong>Checks if vagrant user exists.</strong> <br />
|
65
|
+
If it does, we’re running in the context of a VirtualBox VM, provisioned
|
66
|
+
through Vagrant.</p>
|
67
|
+
</td>
|
68
|
+
<td class=code>
|
69
|
+
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">vagrant?</span>
|
70
|
+
<span class="vi">@vagrant</span> <span class="o">||=</span> <span class="sb">`id vagrant 2>&1`</span><span class="o">.</span><span class="n">index</span> <span class="s1">'uid'</span>
|
71
|
+
<span class="k">end</span></pre></div>
|
72
|
+
</td>
|
73
|
+
</tr>
|
74
|
+
<tr id='section-4'>
|
75
|
+
<td class=docs>
|
76
|
+
<div class="pilwrap">
|
77
|
+
<a class="pilcrow" href="#section-4">¶</a>
|
78
|
+
</div>
|
79
|
+
<p><strong>Get this instance’s ID.</strong> <br />
|
80
|
+
If within 1s it gets a response which starts with ‘i-’, it’s safe to
|
81
|
+
assume that we’re running within the context of an EC2 instance.</p>
|
82
|
+
</td>
|
83
|
+
<td class=code>
|
84
|
+
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">ec2?</span>
|
85
|
+
<span class="vi">@ec2</span> <span class="o">||=</span> <span class="sb">`curl --connect-timeout 1 http://169.254.169.254/2011-01-01/meta-data/instance-id 2>&1`</span><span class="o">.</span><span class="n">include?</span><span class="p">(</span><span class="s1">'i-'</span><span class="p">)</span>
|
86
|
+
<span class="k">end</span></pre></div>
|
87
|
+
</td>
|
88
|
+
</tr>
|
89
|
+
<tr id='section-5'>
|
90
|
+
<td class=docs>
|
91
|
+
<div class="pilwrap">
|
92
|
+
<a class="pilcrow" href="#section-5">¶</a>
|
93
|
+
</div>
|
94
|
+
<p><strong>Generate base64 password using SecureRandom.</strong> <br />
|
95
|
+
Trims the ending ==.</p>
|
96
|
+
|
97
|
+
</td>
|
98
|
+
<td class=code>
|
99
|
+
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">password</span><span class="p">(</span><span class="n">length</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span>
|
100
|
+
<span class="no">SecureRandom</span><span class="o">.</span><span class="n">base64</span><span class="p">(</span><span class="n">length</span><span class="o">+</span><span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">tr</span><span class="p">(</span><span class="s1">'='</span><span class="p">,</span> <span class="s1">''</span><span class="p">)</span>
|
101
|
+
<span class="k">end</span>
|
102
|
+
<span class="k">end</span>
|
103
|
+
<span class="k">end</span></pre></div>
|
104
|
+
</td>
|
105
|
+
</tr>
|
106
|
+
</table>
|
107
|
+
</div>
|
108
|
+
</body>
|
@@ -0,0 +1,108 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
5
|
+
<title>chef-extensions.rb</title>
|
6
|
+
<link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<div id='container'>
|
10
|
+
<div id="background"></div>
|
11
|
+
<div id="jump_to">
|
12
|
+
Jump To …
|
13
|
+
<div id="jump_wrapper">
|
14
|
+
<div id="jump_page">
|
15
|
+
<a class="source" href="chef-extensions.html">chef-extensions.rb</a>
|
16
|
+
<a class="source" href="chef-extensions/version.html">version.rb</a>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
<table cellspacing=0 cellpadding=0>
|
21
|
+
<thead>
|
22
|
+
<tr>
|
23
|
+
<th class=docs><h1>chef-extensions.rb</h1></th>
|
24
|
+
<th class=code></th>
|
25
|
+
</tr>
|
26
|
+
</thead>
|
27
|
+
<tbody>
|
28
|
+
<tr id='section-1'>
|
29
|
+
<td class=docs>
|
30
|
+
<div class="pilwrap">
|
31
|
+
<a class="pilcrow" href="#section-1">¶</a>
|
32
|
+
</div>
|
33
|
+
|
34
|
+
</td>
|
35
|
+
<td class=code>
|
36
|
+
<div class='highlight'><pre><span class="nb">require</span> <span class="s1">'chef-extensions/version'</span>
|
37
|
+
<span class="nb">require</span> <span class="s1">'securerandom'</span>
|
38
|
+
|
39
|
+
<span class="k">module</span> <span class="nn">Chef</span>
|
40
|
+
<span class="k">module</span> <span class="nn">Extensions</span>
|
41
|
+
<span class="kp">extend</span> <span class="nb">self</span></pre></div>
|
42
|
+
</td>
|
43
|
+
</tr>
|
44
|
+
<tr id='section-2'>
|
45
|
+
<td class=docs>
|
46
|
+
<div class="pilwrap">
|
47
|
+
<a class="pilcrow" href="#section-2">¶</a>
|
48
|
+
</div>
|
49
|
+
<p><strong>Ping Google’s DNS.</strong> <br />
|
50
|
+
If it doesn’t hear back within 1s, it’s safe to
|
51
|
+
assume that we don’t have internet connectivity</p>
|
52
|
+
</td>
|
53
|
+
<td class=code>
|
54
|
+
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">wan_up?</span>
|
55
|
+
<span class="sb">`ping -c 1 8.8.8.8 -W 2`</span><span class="o">.</span><span class="n">include?</span> <span class="s2">"1 received"</span>
|
56
|
+
<span class="k">end</span></pre></div>
|
57
|
+
</td>
|
58
|
+
</tr>
|
59
|
+
<tr id='section-3'>
|
60
|
+
<td class=docs>
|
61
|
+
<div class="pilwrap">
|
62
|
+
<a class="pilcrow" href="#section-3">¶</a>
|
63
|
+
</div>
|
64
|
+
<p><strong>Checks if vagrant user exists.</strong> <br />
|
65
|
+
If it does, we’re running in the context of a VirtualBox VM, provisioned
|
66
|
+
through Vagrant.</p>
|
67
|
+
</td>
|
68
|
+
<td class=code>
|
69
|
+
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">vagrant?</span>
|
70
|
+
<span class="vi">@vagrant</span> <span class="o">||=</span> <span class="sb">`id vagrant 2>&1`</span><span class="o">.</span><span class="n">index</span> <span class="s1">'uid'</span>
|
71
|
+
<span class="k">end</span></pre></div>
|
72
|
+
</td>
|
73
|
+
</tr>
|
74
|
+
<tr id='section-4'>
|
75
|
+
<td class=docs>
|
76
|
+
<div class="pilwrap">
|
77
|
+
<a class="pilcrow" href="#section-4">¶</a>
|
78
|
+
</div>
|
79
|
+
<p><strong>Get this instance’s ID.</strong> <br />
|
80
|
+
If within 1s it gets a response which starts with ‘i-’, it’s safe to
|
81
|
+
assume that we’re running within the context of an EC2 instance.</p>
|
82
|
+
</td>
|
83
|
+
<td class=code>
|
84
|
+
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">ec2?</span>
|
85
|
+
<span class="vi">@ec2</span> <span class="o">||=</span> <span class="sb">`curl --connect-timeout 1 http://169.254.169.254/2011-01-01/meta-data/instance-id 2>&1`</span><span class="o">.</span><span class="n">include?</span><span class="p">(</span><span class="s1">'i-'</span><span class="p">)</span>
|
86
|
+
<span class="k">end</span></pre></div>
|
87
|
+
</td>
|
88
|
+
</tr>
|
89
|
+
<tr id='section-5'>
|
90
|
+
<td class=docs>
|
91
|
+
<div class="pilwrap">
|
92
|
+
<a class="pilcrow" href="#section-5">¶</a>
|
93
|
+
</div>
|
94
|
+
<p><strong>Generate base64 password using SecureRandom.</strong> <br />
|
95
|
+
Trims the ending ==.</p>
|
96
|
+
|
97
|
+
</td>
|
98
|
+
<td class=code>
|
99
|
+
<div class='highlight'><pre> <span class="k">def</span> <span class="nf">password</span><span class="p">(</span><span class="n">length</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span>
|
100
|
+
<span class="no">SecureRandom</span><span class="o">.</span><span class="n">base64</span><span class="p">(</span><span class="n">length</span><span class="o">+</span><span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">tr</span><span class="p">(</span><span class="s1">'='</span><span class="p">,</span> <span class="s1">''</span><span class="p">)</span>
|
101
|
+
<span class="k">end</span>
|
102
|
+
<span class="k">end</span>
|
103
|
+
<span class="k">end</span></pre></div>
|
104
|
+
</td>
|
105
|
+
</tr>
|
106
|
+
</table>
|
107
|
+
</div>
|
108
|
+
</body>
|
@@ -0,0 +1,56 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
5
|
+
<title>version.rb</title>
|
6
|
+
<link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<div id='container'>
|
10
|
+
<div id="background"></div>
|
11
|
+
<div id="jump_to">
|
12
|
+
Jump To …
|
13
|
+
<div id="jump_wrapper">
|
14
|
+
<div id="jump_page">
|
15
|
+
<a class="source" href="../chef-extensions.html">chef-extensions.rb</a>
|
16
|
+
<a class="source" href="version.html">version.rb</a>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
<table cellspacing=0 cellpadding=0>
|
21
|
+
<thead>
|
22
|
+
<tr>
|
23
|
+
<th class=docs><h1>version.rb</h1></th>
|
24
|
+
<th class=code></th>
|
25
|
+
</tr>
|
26
|
+
</thead>
|
27
|
+
<tbody>
|
28
|
+
<tr id='section-1'>
|
29
|
+
<td class=docs>
|
30
|
+
<div class="pilwrap">
|
31
|
+
<a class="pilcrow" href="#section-1">¶</a>
|
32
|
+
</div>
|
33
|
+
|
34
|
+
</td>
|
35
|
+
<td class=code>
|
36
|
+
<div class='highlight'><pre><span class="k">module</span> <span class="nn">Chef</span>
|
37
|
+
<span class="k">module</span> <span class="nn">Extensions</span></pre></div>
|
38
|
+
</td>
|
39
|
+
</tr>
|
40
|
+
<tr id='section-2'>
|
41
|
+
<td class=docs>
|
42
|
+
<div class="pilwrap">
|
43
|
+
<a class="pilcrow" href="#section-2">¶</a>
|
44
|
+
</div>
|
45
|
+
<p>Gem version</p>
|
46
|
+
|
47
|
+
</td>
|
48
|
+
<td class=code>
|
49
|
+
<div class='highlight'><pre> <span class="no">VERSION</span> <span class="o">=</span> <span class="s2">"0.1.0"</span>
|
50
|
+
<span class="k">end</span>
|
51
|
+
<span class="k">end</span></pre></div>
|
52
|
+
</td>
|
53
|
+
</tr>
|
54
|
+
</table>
|
55
|
+
</div>
|
56
|
+
</body>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'chef-extensions/version'
|
2
|
+
require 'securerandom'
|
3
|
+
|
4
|
+
module Chef
|
5
|
+
module Extensions
|
6
|
+
extend self
|
7
|
+
|
8
|
+
# **Ping Google's DNS.** <br />
|
9
|
+
# If it doesn't hear back within 1s, it's safe to
|
10
|
+
# assume that we don't have internet connectivity
|
11
|
+
def wan_up?
|
12
|
+
`ping -c 1 8.8.8.8 -W 2`.include? "1 received"
|
13
|
+
end
|
14
|
+
|
15
|
+
# **Checks if vagrant user exists.** <br />
|
16
|
+
# If it does, we're running in the context of a VirtualBox VM, provisioned
|
17
|
+
# through Vagrant.
|
18
|
+
def vagrant?
|
19
|
+
@vagrant ||= `id vagrant 2>&1`.index 'uid'
|
20
|
+
end
|
21
|
+
|
22
|
+
# **Get this instance's ID.** <br />
|
23
|
+
# If within 1s it gets a response which starts with 'i-', it's safe to
|
24
|
+
# assume that we're running within the context of an EC2 instance.
|
25
|
+
def ec2?
|
26
|
+
@ec2 ||= `curl --connect-timeout 1 http://169.254.169.254/2011-01-01/meta-data/instance-id 2>&1`.include?('i-')
|
27
|
+
end
|
28
|
+
|
29
|
+
# **Generate base64 password using SecureRandom.** <br />
|
30
|
+
# Trims the ending ==.
|
31
|
+
def password(length=20)
|
32
|
+
SecureRandom.base64(length+2).tr('=', '')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chef-extensions
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Gerhard Lazu
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-10 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rdiscount
|
16
|
+
requirement: &2168499960 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2168499960
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rocco
|
27
|
+
requirement: &2168501840 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2168501840
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: guard-rocco
|
38
|
+
requirement: &2168517340 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2168517340
|
47
|
+
description: Commands useful for checking internet connectivity, VM presence etc.
|
48
|
+
email:
|
49
|
+
- gerhard@lazu.co.uk
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
56
|
+
- Guardfile
|
57
|
+
- LICENSE
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- chef-extensions.gemspec
|
61
|
+
- docs/index.html
|
62
|
+
- docs/lib/chef-extensions.html
|
63
|
+
- docs/lib/chef-extensions/version.html
|
64
|
+
- lib/chef-extensions.rb
|
65
|
+
- lib/chef-extensions/version.rb
|
66
|
+
homepage: ''
|
67
|
+
licenses: []
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project: chef-extensions
|
86
|
+
rubygems_version: 1.8.10
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: Chef extensions, can be used stand-alone
|
90
|
+
test_files: []
|
91
|
+
has_rdoc:
|