ansibler 0.1.0 → 0.2.0

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: ff6735bf081815a1f5b2b48734b1990e504ca203
4
- data.tar.gz: 900163d141fe1d783807bfb5646d300256d6f87f
3
+ metadata.gz: 95e7c9a2379c008caf95e317891315d9ebc67971
4
+ data.tar.gz: f01f321426e0223a86cc0af1ffa88ef3ac281f1e
5
5
  SHA512:
6
- metadata.gz: a46e5a87a00359a28fed84eccd3962ea6dd3e98a320775d95e2b9938ed3db72b26e0cbb69b4cba7d5764fae6c95f880c620705dbe6fc6b3fc5757f75e46de7e7
7
- data.tar.gz: 16758599fb76a1b1322fd008ffc40b33762e87c406840699ba131a9e96268346b8ce1d6a812b816d487c551b4cecec97db91f7e077c04a3501c6f791190d2423
6
+ metadata.gz: c907bed830f960cb561411749c7dbc466c3193a64bf2fc53457136013edf6b761ade574dbee1cf253e7e4fa47e9bea550d78285de45ca4aac850f8c56618b351
7
+ data.tar.gz: 0a096596765d08339431d1720163e15dd84b08ed8cffcf7c5f6c50a23a3baaaf507c8da51f520c878f30895ce7b5c799972ce2cbd6efb9be8909b5dad18f537d
data/Gemfile CHANGED
@@ -9,8 +9,10 @@ group :development do
9
9
  gem 'jeweler', '~> 2.0.1'
10
10
 
11
11
  # Use cucumber & rspec for tests
12
- gem 'cucumber', '~> 2.0'
13
12
  gem 'rspec', '~> 3.2'
13
+ gem 'cucumber', '~> 2.0'
14
+ # https://github.com/cucumber/aruba
15
+ gem 'aruba', '0.6.2'
14
16
 
15
17
  # Code coverage using simplecov
16
18
  gem 'simplecov', '>= 0'
@@ -20,7 +22,7 @@ group :development do
20
22
 
21
23
  # Documentation
22
24
  gem 'rdoc', '~> 4.2.0'
23
- gem 'yard', '~> 0.8.7'
25
+ gem 'yard', '~> 0.8.7', require: false
24
26
  gem 'redcarpet'
25
27
 
26
28
  end
data/Gemfile.lock CHANGED
@@ -8,10 +8,16 @@ GEM
8
8
  thread_safe (~> 0.3, >= 0.3.4)
9
9
  tzinfo (~> 1.1)
10
10
  addressable (2.3.8)
11
+ aruba (0.6.2)
12
+ childprocess (>= 0.3.6)
13
+ cucumber (>= 1.1.1)
14
+ rspec-expectations (>= 2.7.0)
11
15
  ast (2.0.0)
12
16
  astrolabe (1.3.0)
13
17
  parser (>= 2.2.0.pre.3, < 3.0)
14
18
  builder (3.2.2)
19
+ childprocess (0.5.6)
20
+ ffi (~> 1.0, >= 1.0.11)
15
21
  cucumber (2.0.0)
16
22
  builder (>= 2.1.2)
17
23
  cucumber-core (~> 1.1.3)
@@ -27,6 +33,7 @@ GEM
27
33
  docile (1.1.5)
28
34
  faraday (0.9.1)
29
35
  multipart-post (>= 1.2, < 3)
36
+ ffi (1.9.8)
30
37
  gherkin (2.12.2)
31
38
  multi_json (~> 1.3)
32
39
  git (1.2.9.1)
@@ -109,6 +116,7 @@ PLATFORMS
109
116
 
110
117
  DEPENDENCIES
111
118
  activesupport (= 4.2.1)
119
+ aruba (= 0.6.2)
112
120
  bundler (~> 1.0)
113
121
  cucumber (~> 2.0)
114
122
  jeweler (~> 2.0.1)
data/README.md CHANGED
@@ -27,6 +27,10 @@ inventory.groups.first.name # => "mysql"
27
27
  inventory.groups.first.hosts.first.vars['ansible_ssh_user'] # => "ubuntu"
28
28
  ```
29
29
 
30
+ ## Documentation
31
+
32
+ Full documentation is available [here](https://www.relishapp.com/aisrael/ansibler/docs).
33
+
30
34
  ## Contributing to ansibler
31
35
 
32
36
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
data/Rakefile CHANGED
@@ -21,14 +21,18 @@ Jeweler::Tasks.new do |gem|
21
21
  gem.description = 'ansibler is a Ruby gem that provides utility classes for modeling, reading and writing Ansible inventory and playbook files.'
22
22
  gem.email = 'aisrael@gmail.com'
23
23
  gem.authors = ['Alistair A. Israel']
24
+
24
25
  # dependencies defined in Gemfile
26
+
27
+ gem.files = `git ls-files`.split("\n").delete_if {|f| f.start_with?('.')}
28
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
25
29
  end
26
30
  Jeweler::RubygemsDotOrgTasks.new
27
31
 
28
32
  require 'cucumber'
29
33
  require 'cucumber/rake/task'
30
34
  Cucumber::Rake::Task.new(:features) do |t|
31
- t.cucumber_opts = %w(features/*.features --format pretty)
35
+ t.cucumber_opts = %w(features/*.feature --format pretty)
32
36
  end
33
37
 
34
38
  desc 'Code coverage detail'
@@ -37,7 +41,7 @@ task :simplecov do
37
41
  Rake::Task['test'].execute
38
42
  end
39
43
 
40
- task :default => :test
44
+ task :default => :features
41
45
 
42
46
  require 'yard'
43
47
  YARD::Rake::YardocTask.new do |t|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/ansibler.gemspec ADDED
@@ -0,0 +1,85 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: ansibler 0.2.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "ansibler"
9
+ s.version = "0.2.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Alistair A. Israel"]
14
+ s.date = "2015-05-20"
15
+ s.description = "ansibler is a Ruby gem that provides utility classes for modeling, reading and writing Ansible inventory and playbook files."
16
+ s.email = "aisrael@gmail.com"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.md"
20
+ ]
21
+ s.files = [
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.md",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "ansibler.gemspec",
29
+ "features/.nav",
30
+ "features/README.md",
31
+ "features/inventory.feature",
32
+ "features/step_definitions/inventory_steps.rb",
33
+ "features/support/env.rb",
34
+ "lib/ansible/inventory.rb",
35
+ "lib/ansibler.rb"
36
+ ]
37
+ s.homepage = "http://github.com/aisrael/ansibler"
38
+ s.licenses = ["MIT"]
39
+ s.rubygems_version = "2.4.6"
40
+ s.summary = "Ruby gem for reading and writing Ansible files"
41
+ s.test_files = ["features/README.md", "features/inventory.feature", "features/step_definitions/inventory_steps.rb", "features/support/env.rb"]
42
+
43
+ if s.respond_to? :specification_version then
44
+ s.specification_version = 4
45
+
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ s.add_runtime_dependency(%q<activesupport>, ["= 4.2.1"])
48
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
49
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
50
+ s.add_development_dependency(%q<rspec>, ["~> 3.2"])
51
+ s.add_development_dependency(%q<cucumber>, ["~> 2.0"])
52
+ s.add_development_dependency(%q<aruba>, ["= 0.6.2"])
53
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
54
+ s.add_development_dependency(%q<rubocop>, [">= 0"])
55
+ s.add_development_dependency(%q<rdoc>, ["~> 4.2.0"])
56
+ s.add_development_dependency(%q<yard>, ["~> 0.8.7"])
57
+ s.add_development_dependency(%q<redcarpet>, [">= 0"])
58
+ else
59
+ s.add_dependency(%q<activesupport>, ["= 4.2.1"])
60
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
61
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
62
+ s.add_dependency(%q<rspec>, ["~> 3.2"])
63
+ s.add_dependency(%q<cucumber>, ["~> 2.0"])
64
+ s.add_dependency(%q<aruba>, ["= 0.6.2"])
65
+ s.add_dependency(%q<simplecov>, [">= 0"])
66
+ s.add_dependency(%q<rubocop>, [">= 0"])
67
+ s.add_dependency(%q<rdoc>, ["~> 4.2.0"])
68
+ s.add_dependency(%q<yard>, ["~> 0.8.7"])
69
+ s.add_dependency(%q<redcarpet>, [">= 0"])
70
+ end
71
+ else
72
+ s.add_dependency(%q<activesupport>, ["= 4.2.1"])
73
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
74
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
75
+ s.add_dependency(%q<rspec>, ["~> 3.2"])
76
+ s.add_dependency(%q<cucumber>, ["~> 2.0"])
77
+ s.add_dependency(%q<aruba>, ["= 0.6.2"])
78
+ s.add_dependency(%q<simplecov>, [">= 0"])
79
+ s.add_dependency(%q<rubocop>, [">= 0"])
80
+ s.add_dependency(%q<rdoc>, ["~> 4.2.0"])
81
+ s.add_dependency(%q<yard>, ["~> 0.8.7"])
82
+ s.add_dependency(%q<redcarpet>, [">= 0"])
83
+ end
84
+ end
85
+
data/features/.nav ADDED
@@ -0,0 +1 @@
1
+ - inventory.feature
@@ -0,0 +1,35 @@
1
+ ansibler is a Ruby gem for reading and writing Ansible files.
2
+
3
+ ## tl;dr
4
+
5
+ Given an `inventory_file` that contains:
6
+
7
+ ```
8
+ ip-172-31-6-85
9
+ ip-172-31-3-134 ansible_ssh_host=172.31.3.134 ansible_ssh_user=ubuntu
10
+
11
+ [mysql]
12
+ ip-172-31-3-134
13
+ ```
14
+
15
+ Then
16
+
17
+ ```ruby
18
+ inventory = Ansible::Inventory.read_file('inventory_file')
19
+ inventory.hosts.count # => 2
20
+ inventory.hosts.first.name # => "ip-172-31-6-85"
21
+ inventory.hosts.last.vars.count # => 2
22
+ inventory.hosts.last.vars['ansible_ssh_host'] # => "172.31.3.134"
23
+ inventory.groups.count # => 1
24
+ inventory.groups.first.name # => "mysql"
25
+ inventory.groups.first.hosts.first.vars['ansible_ssh_user'] # => "ubuntu"
26
+ ```
27
+
28
+ ## Use the source
29
+
30
+ https://github.com/aisrael/ansibler
31
+
32
+ ## Copyright
33
+
34
+ Copyright (c) 2015 Alistair A. Israel. See LICENSE.txt for
35
+ further details.
@@ -0,0 +1,81 @@
1
+ Feature: Inventory
2
+ In order to read and write Ansible inventory files
3
+
4
+ Scenario: read a simple inventory file
5
+ Given an Ansible inventory file containing:
6
+ """
7
+ ip-172-31-6-85
8
+ ip-172-31-3-134
9
+ """
10
+ When we read the Ansible inventory file using Ansible::Inventory.read_file
11
+ Then `hosts.count` should be 2
12
+ And `hosts.first.name` should be "ip-172-31-6-85"
13
+ And `hosts.last.name` should be "ip-172-31-3-134"
14
+
15
+ Scenario: read an inventory file with host variables
16
+ Given an Ansible inventory file containing:
17
+ """
18
+ ip-172-31-6-85 ansible_ssh_host=172.31.6.85 ansible_ssh_user=ubuntu ansible_ssh_private_key_file=aws_private_key.pem
19
+ ip-172-31-3-134 ansible_ssh_host=172.31.3.134 ansible_ssh_user=ubuntu ansible_ssh_private_key_file=aws_private_key.pem
20
+ """
21
+ When we read the Ansible inventory file using Ansible::Inventory.read_file
22
+ And `hosts.first.name` should be "ip-172-31-6-85"
23
+ And `hosts.first.vars['ansible_ssh_private_key_file']` should be "aws_private_key.pem"
24
+ And `hosts.last.vars['ansible_ssh_user']` should be "ubuntu"
25
+
26
+ Scenario: read an inventory file with hosts and groups
27
+ Given an Ansible inventory file containing:
28
+ """
29
+ ip-172-31-6-85
30
+ ip-172-31-3-134 ansible_ssh_host=172.31.3.134 ansible_ssh_user=ubuntu ansible_ssh_private_key_file=aws_private_key.pem
31
+
32
+ [mysql]
33
+ ip-172-31-3-134
34
+ """
35
+ When we read the Ansible inventory file using Ansible::Inventory.read_file
36
+ Then `groups.count` should be 1
37
+ And the first group's name should be "mysql"
38
+ And the first group should have 1 host
39
+ And `groups.first.hosts.first.name` should be "ip-172-31-3-134"
40
+ And `groups.first.hosts.first.vars['ansible_ssh_user']` should be "ubuntu"
41
+
42
+ Scenario: read an inventory file with group variables
43
+ Given an Ansible inventory file containing:
44
+ """
45
+ ip-172-31-6-85
46
+
47
+ [mysql]
48
+ ip-172-31-6-85
49
+
50
+ [mysql:vars]
51
+ mysql_root_password=secret
52
+ mysql_user_name=mysql
53
+ mysql_user_password=mysql
54
+ """
55
+ When we read the Ansible inventory file using Ansible::Inventory.read_file
56
+ Then `groups.count` should be 1
57
+ And the first group's name should be "mysql"
58
+ And the first group should have 3 vars
59
+ And `groups.first.vars.keys.first` should be "mysql_root_password"
60
+ And `groups.first.vars['mysql_user_name']` should be "mysql"
61
+
62
+ Scenario: write an inventory file using Ansible::Inventory methods
63
+ Given the following code snippet:
64
+ """
65
+ inventory = Ansible::Inventory.new
66
+ host = inventory.hosts.add 'ip-172-31-3-134', ansible_ssh_host: '172.31.3.134'
67
+ mysql_group = inventory.groups.add 'mysql'
68
+ mysql_group.hosts.add host
69
+ mysql_group.vars['mysql_root_password'] = 'secret'
70
+ inventory.write_file('ansible_inventory')
71
+ """
72
+ Then the file "ansible_inventory" should contain:
73
+ """
74
+ ip-172-31-3-134 ansible_ssh_host=172.31.3.134
75
+
76
+ [mysql]
77
+ ip-172-31-3-134
78
+
79
+ [mysql:vars]
80
+ mysql_root_password=secret
81
+ """
@@ -1,12 +1,11 @@
1
- Given /^an Ansible inventory file containing$/ do |body|
2
- @ansible_inventory_file = Tempfile.open('ansibler-') do |f|
3
- f.write body
4
- f
5
- end
1
+ WORKING_DIR = File.join %w(tmp aruba)
2
+
3
+ Given /^an Ansible inventory file containing:$/ do |contents|
4
+ step 'a file named "ansible_inventory" with:', contents
6
5
  end
7
6
 
8
- When(/^we read the file using Ansible::Inventory\.read_file$/) do
9
- @ansible_inventory = Ansible::Inventory.read_file(@ansible_inventory_file.path)
7
+ When(/^we read the Ansible inventory file using Ansible::Inventory\.read_file$/) do
8
+ @ansible_inventory = Ansible::Inventory.read_file(File.join WORKING_DIR, 'ansible_inventory')
10
9
  end
11
10
 
12
11
  Then(/^`(\S+)` should be (\d+)$/) do |something, value|
@@ -30,6 +29,22 @@ end
30
29
 
31
30
  Then(/^the (first|last) (\S+) should have (\d+) (\S+)$/) do |first_or_last, collection, n, sub_collection|
32
31
  steps %Q{
33
- Then `#{collection}s.#{first_or_last}.#{sub_collection}s.count` should be #{n}
32
+ Then `#{collection}s.#{first_or_last}.#{sub_collection.pluralize}.count` should be #{n}
34
33
  }
35
- end
34
+ end
35
+
36
+ def in_dir(dir, &block)
37
+ pwd = Dir.pwd
38
+ begin
39
+ Dir.chdir dir
40
+ block.call
41
+ ensure
42
+ Dir.chdir pwd
43
+ end
44
+ end
45
+
46
+ Given(/^the following code snippet:$/) do |snippet|
47
+ in_dir WORKING_DIR do
48
+ eval snippet
49
+ end
50
+ end
@@ -2,3 +2,6 @@
2
2
  $: << File.expand_path(File.join('..', '..', '..', 'lib'), __FILE__)
3
3
 
4
4
  require 'ansibler'
5
+
6
+ require 'active_support/all'
7
+ require 'aruba/cucumber'
@@ -6,35 +6,73 @@ module Ansible
6
6
  def read_file(file)
7
7
  inventory = Inventory.new
8
8
  last_group = nil
9
+ in_vars = false
9
10
  File.foreach(file) do |line|
10
11
  case
11
12
  when line =~ /^\[\S+\]$/
12
13
  group_name = line[/^\[(\S+)\]$/, 1]
13
- last_group = Group.new group_name
14
- inventory.groups << last_group
14
+ in_vars = group_name.end_with?(':vars')
15
+ if in_vars
16
+ actual_group_name = group_name[0, group_name.index(':')]
17
+ last_group = inventory.groups.find { |g| g.name == actual_group_name }
18
+ last_group ||= inventory.groups.add(actual_group_name)
19
+ else
20
+ last_group = inventory.groups.add(group_name)
21
+ end
15
22
  when line =~ /^\s*[^\[]\S+\s*(\S+=\S+\s*)*$/
16
23
  host_name, *rest = line.split
17
- vars = Hash[rest.map {|s| s.split('=')}]
18
- if last_group
19
- host = inventory.hosts.find {|h| h.name == host_name} || Host.new(host_name, vars)
20
- last_group.hosts << host
24
+ if in_vars && host_name.index('=') && rest.empty?
25
+ k, v = host_name.split('=')
26
+ last_group.vars[k] = v
21
27
  else
22
- host = Host.new host_name, vars
23
- inventory.hosts << host
28
+ vars = Hash[rest.map {|s| s.split('=')}]
29
+ if last_group
30
+ host = inventory.hosts.find {|h| h.name == host_name} || Host.new(host_name, vars)
31
+ last_group.hosts << host
32
+ else
33
+ inventory.hosts.add host_name, vars
34
+ end
24
35
  end
25
-
36
+ else
37
+ puts line
26
38
  end
27
39
  end
28
40
  inventory
29
41
  end
30
42
  end
31
43
 
44
+ def write_file(file)
45
+ File.open(file, 'w') do |f|
46
+ hosts.each {|host|
47
+ f.puts ([host.name] + host.vars.map {|k, v| "#{k}=#{v}"}).join(' ')
48
+ }
49
+ groups.each {|group|
50
+ f.puts
51
+ f.puts "[#{group.name}]"
52
+ group.hosts.each {|host|
53
+ if hosts.find {|h| h == host }
54
+ f.puts host.name
55
+ else
56
+ f.puts ([host.name] + host.vars.map {|k, v| "#{k}=#{v}"}).join(' ')
57
+ end
58
+ }
59
+ unless group.vars.empty?
60
+ f.puts
61
+ f.puts "[#{group.name}:vars]"
62
+ group.vars.each {|k, v|
63
+ f.puts "#{k}=#{v}"
64
+ }
65
+ end
66
+ }
67
+ end
68
+ end
69
+
32
70
  attr_reader :hosts
33
71
  attr_reader :groups
34
72
 
35
73
  def initialize
36
- @hosts = []
37
- @groups = []
74
+ @hosts = Host::Collection.new
75
+ @groups = Group::Collection.new
38
76
  end
39
77
 
40
78
  class Host < Struct.new :name, :vars
@@ -42,14 +80,31 @@ module Ansible
42
80
  super
43
81
  self.vars = {} unless vars
44
82
  end
83
+ class Collection < Array
84
+ def add(*args)
85
+ host = if args.first.is_a?(Host)
86
+ args.first
87
+ else
88
+ Host.new(*args)
89
+ end
90
+ self << host
91
+ host
92
+ end
93
+ end
45
94
  end
46
95
 
47
96
  class Group < Struct.new :name, :hosts, :vars
48
97
  def initialize(*args)
49
98
  super
50
- self.hosts = [] unless hosts
99
+ self.hosts = Host::Collection.new unless hosts
51
100
  self.vars = {} unless vars
52
101
  end
102
+ class Collection < Array
103
+ def add(*args)
104
+ self << group = Group.new(*args)
105
+ group
106
+ end
107
+ end
53
108
  end
54
109
  end
55
110
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ansibler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alistair A. Israel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-19 00:00:00.000000000 Z
11
+ date: 2015-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 2.0.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.2'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.2'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: cucumber
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -67,19 +81,19 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '2.0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: rspec
84
+ name: aruba
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - "~>"
87
+ - - '='
74
88
  - !ruby/object:Gem::Version
75
- version: '3.2'
89
+ version: 0.6.2
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - "~>"
94
+ - - '='
81
95
  - !ruby/object:Gem::Version
82
- version: '3.2'
96
+ version: 0.6.2
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: simplecov
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -159,16 +173,16 @@ extra_rdoc_files:
159
173
  - LICENSE.txt
160
174
  - README.md
161
175
  files:
162
- - ".ruby-gemset"
163
- - ".ruby-version"
164
- - ".yardopts"
165
176
  - Gemfile
166
177
  - Gemfile.lock
167
178
  - LICENSE.txt
168
179
  - README.md
169
180
  - Rakefile
170
181
  - VERSION
171
- - features/inventory.features
182
+ - ansibler.gemspec
183
+ - features/.nav
184
+ - features/README.md
185
+ - features/inventory.feature
172
186
  - features/step_definitions/inventory_steps.rb
173
187
  - features/support/env.rb
174
188
  - lib/ansible/inventory.rb
@@ -197,5 +211,8 @@ rubygems_version: 2.4.6
197
211
  signing_key:
198
212
  specification_version: 4
199
213
  summary: Ruby gem for reading and writing Ansible files
200
- test_files: []
201
- has_rdoc:
214
+ test_files:
215
+ - features/README.md
216
+ - features/inventory.feature
217
+ - features/step_definitions/inventory_steps.rb
218
+ - features/support/env.rb
data/.ruby-gemset DELETED
@@ -1 +0,0 @@
1
- ansibler
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- ruby-2.2.2
data/.yardopts DELETED
@@ -1 +0,0 @@
1
- --markup markdown
@@ -1,40 +0,0 @@
1
- Feature: Inventory
2
- In order to read and write Ansible inventory files
3
-
4
- Scenario: read a simple inventory file
5
- Given an Ansible inventory file containing
6
- """
7
- ip-172-31-6-85
8
- ip-172-31-3-134
9
- """
10
- When we read the file using Ansible::Inventory.read_file
11
- Then `hosts.count` should be 2
12
- And `hosts.first.name` should be "ip-172-31-6-85"
13
- And `hosts.last.name` should be "ip-172-31-3-134"
14
-
15
- Scenario: read an inventory file with host variables
16
- Given an Ansible inventory file containing
17
- """
18
- ip-172-31-6-85 ansible_ssh_host=172.31.6.85 ansible_ssh_user=ubuntu ansible_ssh_private_key_file=aws_private_key.pem
19
- ip-172-31-3-134 ansible_ssh_host=172.31.3.134 ansible_ssh_user=ubuntu ansible_ssh_private_key_file=aws_private_key.pem
20
- """
21
- When we read the file using Ansible::Inventory.read_file
22
- And `hosts.first.name` should be "ip-172-31-6-85"
23
- And `hosts.first.vars['ansible_ssh_private_key_file']` should be "aws_private_key.pem"
24
- And `hosts.last.vars['ansible_ssh_user']` should be "ubuntu"
25
-
26
- Scenario: read an inventory file with hosts and groups
27
- Given an Ansible inventory file containing
28
- """
29
- ip-172-31-6-85
30
- ip-172-31-3-134 ansible_ssh_host=172.31.3.134 ansible_ssh_user=ubuntu ansible_ssh_private_key_file=aws_private_key.pem
31
-
32
- [mysql]
33
- ip-172-31-3-134
34
- """
35
- When we read the file using Ansible::Inventory.read_file
36
- Then `groups.count` should be 1
37
- And the first group's name should be "mysql"
38
- And the first group should have 1 host
39
- And `groups.first.hosts.first.name` should be "ip-172-31-3-134"
40
- And `groups.first.hosts.first.vars['ansible_ssh_user']` should be "ubuntu"