moose-inventory 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -12
- data/lib/moose_inventory/db/db.rb +8 -1
- data/lib/moose_inventory/db/models.rb +14 -5
- data/lib/moose_inventory/version.rb +1 -1
- data/spec/lib/moose_inventory/db/models_spec.rb +45 -19
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62c6b9792b94606206b9ef3fd2ec764f84246974
|
4
|
+
data.tar.gz: 4e5ad255cbf9c5107da696c0189b6c84ffdd7e0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2c10d0f8e93835356f5877225495a9de546ce06dabd878519e59586da837676113c0cf67cebdae530199ac32daa94f438c7078044526b6d0d49a971e1701602
|
7
|
+
data.tar.gz: 55c989d8dd9ee2f63fb4b07fa14a7c62b29ef6249676a97061b5b2a66bb44849f2a037f4c4a405cf41add5ae0a4ed0ed142d03a01b714b1a83f0908652fa2b4f
|
data/README.md
CHANGED
@@ -6,19 +6,22 @@ Note: This software is intended for use on UNIX, Linux, or similar systems. It
|
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
|
-
|
9
|
+
The tool is a ruby gem.
|
10
|
+
|
11
|
+
It can be install from the command line as follows.
|
12
|
+
|
13
|
+
$ gem install moose-inventory
|
14
|
+
|
15
|
+
Alternatively, it can be installed by adding the following line to a Gemfile:
|
10
16
|
|
11
17
|
```ruby
|
12
18
|
gem 'moose-inventory'
|
13
19
|
```
|
14
20
|
|
15
|
-
And then
|
21
|
+
And then executing:
|
16
22
|
|
17
23
|
$ bundle
|
18
|
-
|
19
|
-
```ruby
|
20
|
-
$ gem install moose-inventory
|
21
|
-
```
|
24
|
+
|
22
25
|
|
23
26
|
## Configuration
|
24
27
|
The [moose-inventory](https://github.com/RusDavies/moose-inventory) tool makes use of a simple YAML configuration file.
|
@@ -86,7 +89,6 @@ The tool itself provides a convenient help feature. For example, try each of th
|
|
86
89
|
> moose-inventory group help add
|
87
90
|
|
88
91
|
###Global switches
|
89
|
-
Not described in the built-in help system are a handful of top-level switches, as follows.
|
90
92
|
|
91
93
|
#### Option `--config <FILE>`
|
92
94
|
The *--config* flag sets the configuration file to be used. If specified, then the file must exist. This takes precedence over all other config files in other locations. If not provided, then the default is to search standard locations, see later.
|
@@ -341,11 +343,6 @@ Alternatively, if you are using an [Ansible configuration file](http://docs.ansi
|
|
341
343
|
inventory = ./shim.sh
|
342
344
|
|
343
345
|
Yet another option is to copy the shim script to */etc/ansible/hosts* and `chmod +x` it. However, since this would essentially fix the config file and environment used, doing so would defeat the flexibility intended for *moose-inventory*.
|
344
|
-
|
345
|
-
##Missing features
|
346
|
-
The following desired features are yet to be implemented:
|
347
|
-
|
348
|
-
1. Groups of groups
|
349
346
|
|
350
347
|
## Contributing
|
351
348
|
1. Fork it (https://github.com/RusDavies/moose-inventory/fork )
|
@@ -154,11 +154,18 @@ module Moose
|
|
154
154
|
unless @db.table_exists? :groups
|
155
155
|
@db.create_table(:groups) do
|
156
156
|
primary_key :id
|
157
|
-
foreign_key :parent_id
|
158
157
|
column :name, :text, unique: true
|
159
158
|
end
|
160
159
|
end
|
161
160
|
|
161
|
+
unless @db.table_exists? :groups_groups
|
162
|
+
@db.create_table(:groups_groups) do
|
163
|
+
primary_key :id
|
164
|
+
foreign_key :parent_id, :groups
|
165
|
+
foreign_key :child_id, :groups
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
162
169
|
unless @db.table_exists? :groupvars
|
163
170
|
@db.create_table(:groupvars) do
|
164
171
|
primary_key :id
|
@@ -11,11 +11,20 @@ module Moose
|
|
11
11
|
##
|
12
12
|
# Model for the groups table
|
13
13
|
class Group < Sequel::Model
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
|
15
|
+
many_to_many :parents,
|
16
|
+
:left_key=>:parent_id,
|
17
|
+
:right_key=>:child_id,
|
18
|
+
:class=>self
|
19
|
+
|
20
|
+
many_to_many :children,
|
21
|
+
:left_key=>:child_id,
|
22
|
+
:right_key=>:parent_id,
|
23
|
+
:class=>self
|
24
|
+
|
25
|
+
many_to_many :hosts
|
26
|
+
one_to_many :groupvars
|
27
|
+
end
|
19
28
|
|
20
29
|
##
|
21
30
|
# Model for the hostvars table
|
@@ -126,25 +126,51 @@ RSpec.describe 'models' do
|
|
126
126
|
expect(hosts.count).to eq(1)
|
127
127
|
expect(hosts.first[:name]).to eq('Host-test')
|
128
128
|
end
|
129
|
-
end
|
130
|
-
|
131
|
-
it 'should have relationships with Hostvars' do
|
132
|
-
groupname = 'group-test'
|
133
|
-
groupvarname = 'groupvar-test'
|
134
|
-
groupvarval = '1'
|
135
|
-
|
136
|
-
group = @db.models[:group].create(name: groupname)
|
137
|
-
groupvar = @db.models[:groupvar].create(name: groupvarname,
|
138
|
-
value: groupvarval)
|
139
|
-
|
140
|
-
group.add_groupvar(groupvar)
|
141
129
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
130
|
+
it 'should have a many-to-many self-referential relationship (i.e. GROUPS of GROUPS)' do
|
131
|
+
|
132
|
+
parent1 = @db.models[:group].create(name: 'parent1')
|
133
|
+
parent2 = @db.models[:group].create(name: 'parent2')
|
134
|
+
child1 = @db.models[:group].create(name: 'child1')
|
135
|
+
child2 = @db.models[:group].create(name: 'child2')
|
136
|
+
|
137
|
+
parent1.add_child(child1)
|
138
|
+
parent1.add_child(child2)
|
139
|
+
|
140
|
+
parent2.add_child(child1)
|
141
|
+
parent2.add_child(child2)
|
142
|
+
|
143
|
+
group = @db.models[:group].find(name: 'parent1')
|
144
|
+
children = group.children_dataset
|
145
|
+
|
146
|
+
expect(children).not_to be_nil
|
147
|
+
expect(children.count).to eq(2)
|
148
|
+
|
149
|
+
group = @db.models[:group].find(name: 'parent2')
|
150
|
+
children = group.children_dataset
|
151
|
+
|
152
|
+
expect(children).not_to be_nil
|
153
|
+
expect(children.count).to eq(2)
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'should have relationships with Hostvars' do
|
157
|
+
groupname = 'group-test'
|
158
|
+
groupvarname = 'groupvar-test'
|
159
|
+
groupvarval = '1'
|
160
|
+
|
161
|
+
group = @db.models[:group].create(name: groupname)
|
162
|
+
groupvar = @db.models[:groupvar].create(name: groupvarname,
|
163
|
+
value: groupvarval)
|
164
|
+
|
165
|
+
group.add_groupvar(groupvar)
|
166
|
+
|
167
|
+
group = @db.models[:group].find(name: groupname)
|
168
|
+
groupvars = group.groupvars_dataset
|
169
|
+
|
170
|
+
expect(groupvars).not_to be_nil
|
171
|
+
expect(groupvars.count).to eq(1)
|
172
|
+
expect(groupvars.first[:name]).to eq(groupvarname)
|
173
|
+
expect(groupvars.first[:value]).to eq(groupvarval)
|
174
|
+
end
|
149
175
|
end
|
150
176
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moose-inventory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Russell Davies
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: indentation
|