searchef 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +52 -0
- data/lib/searchef.rb +4 -0
- data/lib/searchef/version.rb +1 -1
- metadata +2 -8
data/README.md
CHANGED
@@ -19,6 +19,8 @@ Or install it yourself as:
|
|
19
19
|
|
20
20
|
## Usage
|
21
21
|
|
22
|
+
### Setup
|
23
|
+
|
22
24
|
Require the library and include the `Searchef::API` module for convenience:
|
23
25
|
|
24
26
|
```ruby
|
@@ -27,6 +29,8 @@ require 'searchef'
|
|
27
29
|
include Searchef::API
|
28
30
|
```
|
29
31
|
|
32
|
+
### Stubbing Node Searches
|
33
|
+
|
30
34
|
```ruby
|
31
35
|
# stub search for all nodes with the `web_node` role in their run list
|
32
36
|
stub_search(:node, "roles:web_node").to_return([
|
@@ -46,6 +50,54 @@ query.search(:node, "roles:web_node")
|
|
46
50
|
# => [[node[web1.example.com], node[web2.example.com]], 0, 2]
|
47
51
|
```
|
48
52
|
|
53
|
+
You can also stub more complicated nodes with specific data:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
# setting a node platform and platform verson
|
57
|
+
node_stub("node1.example.com", :platform => "centos", :version => "6.3")
|
58
|
+
|
59
|
+
# overriding default fauxhai ohai data
|
60
|
+
node_stub("node2.example.com", :ohai => { :ipaddress => "19.2.168.10.1" })
|
61
|
+
|
62
|
+
# set node attribute data, such as the run_list
|
63
|
+
node_stub("node2.example.com", :attrs => {
|
64
|
+
:run_list => [ 'recipe[common::base]', 'role[load_balancer]' ]
|
65
|
+
})
|
66
|
+
|
67
|
+
# using a block which provides access to the attributes file dsl methods
|
68
|
+
node_stub("node3.example.com", :ohai => { :ipaddress => "10.10.12.27" }) do
|
69
|
+
default['mysql']['tunable']['tmp_table_size'] = "64M"
|
70
|
+
end
|
71
|
+
```
|
72
|
+
|
73
|
+
### Stubbing Data Bag Searches
|
74
|
+
|
75
|
+
Data bags are a hash of data, so you can return data bag items as an array of
|
76
|
+
hashes:
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
stub_search(:users, 'groups:admin').to_return([
|
80
|
+
{
|
81
|
+
"id" => "adam",
|
82
|
+
"comment" => "Adam Administrator",
|
83
|
+
"groups" => [
|
84
|
+
"admin"
|
85
|
+
],
|
86
|
+
"ssh_keys" => [],
|
87
|
+
"shell" => "/bin/bash"
|
88
|
+
}
|
89
|
+
])
|
90
|
+
```
|
91
|
+
|
92
|
+
If your `data_bag_path` is setup, you could also fectch the data from a real
|
93
|
+
data bag, using the `data_bag_item` method:
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
stub_search(:users, 'groups:admin').to_return([
|
97
|
+
data_bag_item("users", "adam")
|
98
|
+
])
|
99
|
+
```
|
100
|
+
|
49
101
|
## Contributing
|
50
102
|
|
51
103
|
1. Fork it
|
data/lib/searchef.rb
CHANGED
data/lib/searchef/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: searchef
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
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-02-
|
12
|
+
date: 2013-02-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef
|
@@ -89,18 +89,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
89
|
- - ! '>='
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
|
-
segments:
|
93
|
-
- 0
|
94
|
-
hash: 2900810078172785449
|
95
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
93
|
none: false
|
97
94
|
requirements:
|
98
95
|
- - ! '>='
|
99
96
|
- !ruby/object:Gem::Version
|
100
97
|
version: '0'
|
101
|
-
segments:
|
102
|
-
- 0
|
103
|
-
hash: 2900810078172785449
|
104
98
|
requirements: []
|
105
99
|
rubyforge_project:
|
106
100
|
rubygems_version: 1.8.24
|