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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b70b5c9f5c9a0b7995c21952592dec88f31f92eb
4
- data.tar.gz: 27d851baa44920820ff764da7ceaeb12c09db853
3
+ metadata.gz: 62c6b9792b94606206b9ef3fd2ec764f84246974
4
+ data.tar.gz: 4e5ad255cbf9c5107da696c0189b6c84ffdd7e0c
5
5
  SHA512:
6
- metadata.gz: 3f982bdbafb5859491036dbc16779098183ed003a892909b5faf07a5bc4c45b6644f5dba4428e3ae9e2ba95ca4238723f5db3c92613b1aa791ea996d8b743fd0
7
- data.tar.gz: d9890ba9ae9d41e295a534ee93139b79612ebff138f44496f862c40f7dfa6f440f35cd5d2eb40577e8102fba0009d00c599e13f2bc935a545193eb4e62014fe5
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
- Add this line to your application's Gemfile:
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 execute:
21
+ And then executing:
16
22
 
17
23
  $ bundle
18
- Or install it yourself as:
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
- many_to_one :parent, :class=>self
15
- one_to_many :children, :key=>:parent_id, :class=>self
16
- many_to_many :hosts
17
- one_to_many :groupvars
18
- end
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
@@ -2,6 +2,6 @@ module Moose
2
2
  ##
3
3
  # The Moose-Tools dynamic inventory management library
4
4
  module Inventory
5
- VERSION = '1.0.0'
5
+ VERSION = '1.0.1'
6
6
  end
7
7
  end
@@ -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
- group = @db.models[:group].find(name: groupname)
143
- groupvars = group.groupvars_dataset
144
-
145
- expect(groupvars).not_to be_nil
146
- expect(groupvars.count).to eq(1)
147
- expect(groupvars.first[:name]).to eq(groupvarname)
148
- expect(groupvars.first[:value]).to eq(groupvarval)
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.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-09 00:00:00.000000000 Z
11
+ date: 2015-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: indentation