terraform_inventory 0.1.7 → 0.1.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a32cbd51c782d0ef4f1678edc7d65574b0845519
4
- data.tar.gz: 814ade3f5770612e0421ffe6c079697deb881a00
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MTcyMzNjNWQ2Y2MxZDE0ZWNlMjk3MmVmNDJiMmIyZjg5NmQ2YTY2OA==
5
+ data.tar.gz: !binary |-
6
+ YTg2ODNlYjk0MWVkNWY4YWE1OWI2MGI5Zjk0YjgxMTQzMjMyZjEyYg==
5
7
  SHA512:
6
- metadata.gz: 4152352d362b6d9994d86a02df75411e0a367af0bb69373e4b43db81dd0515546bdba59969593f7167cafdfa82b598ecde29ef2af37fec280475a3ab5a131000
7
- data.tar.gz: a95e82ae5e28d47ae0de065600b97684a3c961ebaa11a2cb82f550ddc941a32a9c8a80119023e969069cf075b942fea436a78a534ed5694b8715a52e76b93901
8
+ metadata.gz: !binary |-
9
+ YjNhMzI4N2MyOGQ2NmZiZTdlOGRiYTc5MzBkYTJlZmJjZDA4NDkwMWFlM2M3
10
+ NTNiZmY0MmUxMWNkMTI3NDI3ZGVhNGNiMTI2ZTRjMDRiMzVjNDBkYTZkMDUy
11
+ N2E0ZGIzOTkwOGNkNzBkZWE3Y2EzNjE4YTk3MjdjNjBhNTNhZWY=
12
+ data.tar.gz: !binary |-
13
+ MTdkMzg1ZmZlMWNiOWU2YzU2ODhhOTU3NmUyZDY0MmI1ZWRkODRlMjQxMDhi
14
+ YTMxZjBiMGRiMGRjMTM3MWNmM2Q4ZDBjOTc0MWYyMzg3YzNmZGMwZmM1Mjdl
15
+ MjM0Y2FiZWM4ODM2ODE3NjdlMmIxNzliNjlkMTVjNTA0ZDRiNWQ=
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- terraform_inventory [![Build Status](https://travis-ci.org/bandwidthcom/terraform-inventory.svg)](https://travis-ci.org/bandwidthcom/terraform-inventory)
1
+ terraform_inventory [![Build Status](https://travis-ci.org/bandwidthcom/terraform-inventory.svg?branch=master)](https://travis-ci.org/bandwidthcom/terraform-inventory)
2
2
  =========
3
3
 
4
4
  Create an Ansible inventory file from a Terraform state file.
@@ -10,7 +10,7 @@ This mostly makes sense with the following resources since we are targetting Ans
10
10
  - [digitalocean_droplet](http://www.terraform.io/docs/providers/do/r/droplet.html) (not supported yet)
11
11
 
12
12
  #### Installation
13
- gem install thor
13
+ gem install terraform_inventory
14
14
 
15
15
  #### Example
16
16
  ```
@@ -31,7 +31,7 @@ Options:
31
31
  - The "none" host group puts the hosts IP address at the top of the file without a group
32
32
  - --state=<path to state file> (optional)
33
33
  - Path to a Terraform state file.
34
- - Default: /home/tyler/Projects/terraform_inventory/terraform.tfstate
34
+ - Default: `File.join(Dir.pwd, "terraform.tfstate")`
35
35
 
36
36
  #### License
37
37
  [MIT](LICENSE.md)
@@ -14,6 +14,11 @@ module TerraformInventory
14
14
  banner: "resource_selector:host_group",
15
15
  desc: "Maps between Terraform resource selector and Ansible host group."
16
16
  }
17
+ option :ip_type, {
18
+ banner: "public|private",
19
+ desc: "Whether to use the public or private ip address",
20
+ default: "public"
21
+ }
17
22
  option :state, {
18
23
  banner: "<path to state file>",
19
24
  desc: "Path to a Terraform state file.",
@@ -31,10 +36,11 @@ module TerraformInventory
31
36
  @ungrouped_resources = @groups[:none] || []
32
37
  @groups.delete(:none)
33
38
 
34
- template(
35
- "inventory.erb",
36
- inventory_path
37
- )
39
+ config = {
40
+ ip_type: "#{options[:ip_type]}_ip"
41
+ }
42
+
43
+ template("inventory.erb", inventory_path, config)
38
44
  end
39
45
  end
40
46
 
@@ -3,9 +3,8 @@ require "terraform_inventory/exception"
3
3
 
4
4
  module TerraformInventory
5
5
  class TerraformState
6
- def resources
7
- @state
8
- end
6
+ attr_reader :state
7
+ alias_method :resources, :state
9
8
 
10
9
  # Find resources given a resource selector.
11
10
  #
@@ -1,3 +1,3 @@
1
1
  module TerraformInventory
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -1,6 +1,6 @@
1
- <% for resource in @ungrouped_resources %><%= resource["public_ip"] %><% end %>
1
+ <% for resource in @ungrouped_resources %><%= resource[config[:ip_type]] %><% end %>
2
2
  <% for group_name, resources in @groups %>
3
3
  [<%= group_name %>]
4
- <% for resource in resources %><%= resource["public_ip"] %>
4
+ <% for resource in resources %><%= resource[config[:ip_type]] %>
5
+ <% end %>
5
6
  <% end %>
6
- <% end %>
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terraform_inventory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Cross
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-25 00:00:00.000000000 Z
11
+ date: 2015-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - ! '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - ! '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.6'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.6'
41
41
  description: Map Terraform state to an Ansible inventory file
@@ -69,20 +69,20 @@ require_paths:
69
69
  - lib
70
70
  required_ruby_version: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - ">="
72
+ - - ! '>='
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  requirements:
77
- - - ">="
77
+ - - ! '>='
78
78
  - !ruby/object:Gem::Version
79
79
  version: '0'
80
80
  requirements: []
81
81
  rubyforge_project:
82
- rubygems_version: 2.2.2
82
+ rubygems_version: 2.4.8
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: Map Terraform state to an Ansible inventory file
86
86
  test_files:
87
- - spec/spec_helper.rb
88
87
  - spec/terraform_inventory/terraform_state_spec.rb
88
+ - spec/spec_helper.rb