terraform_inventory 0.1.0 → 0.1.1

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,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 752923f38af589a6e9df6232e9892d9759bcff3a
4
- data.tar.gz: d4748a2f30ff7599c733eb049e9657cc82b2eb82
3
+ metadata.gz: fb1dc0be69d25224429142350a53e6aa386e10ad
4
+ data.tar.gz: 995be478df7ecaab176e562ce1f0422ecfad0574
5
5
  SHA512:
6
- metadata.gz: 941355c9930033fe7eb6218fc2df8c7aa11e2d2902fcf26feea113bcdc79948824b754ad7082abf99758313d19ac4826374bcf006066892e83d2b2f8b91883df
7
- data.tar.gz: 725b48d538389aa18264e3ecc45a0488e83c1dedff1e08b6998972966e020274d86ad55965f16ffa86738bcb90814ce10d8936f47e31d8abd4bdbfdb5ec2a1f5
6
+ metadata.gz: 9c55621646dcb1c9e712647586a185e9d6d30e57c1a98a90b1b80467dd1dd2e495738c44e83a7492b7660ffc8e0a3e21635d77877ad80de079c190081fb99c05
7
+ data.tar.gz: d2c8b12dbb62e52fae4c9197040e00a730a1920fc856a374f4290d9a5c8b9e6d4e86c18192b661a44142028e21beeb37c669d481374bd0f70ebb789b556800e9
data/README.md CHANGED
@@ -1,11 +1,37 @@
1
- terraform_inventory
1
+ terraform_inventory [![Build Status](https://travis-ci.org/bandwidthcom/terraform-inventory.svg)](https://travis-ci.org/bandwidthcom/terraform-inventory)
2
2
  =========
3
3
 
4
4
  Create an Ansible inventory file from a Terraform state file.
5
5
 
6
- This tool was written so that Terraform can be used for only creating infrastructure and then Ansible for configuration management.
6
+ The main objective of this tool is to be able to select whatever resources you need in Terraform state and build an Ansible inventory file. This should be possible without changing a Terraform plan by only relying on the output of ```terraform show```. It must be possible to place a resource in multiple host groups.
7
+
8
+ This mostly makes sense with the following resources since we are targetting Ansible:
9
+ - [aws_instance](http://www.terraform.io/docs/providers/aws/r/instance.html)
10
+ - [digitalocean_droplet](http://www.terraform.io/docs/providers/do/r/droplet.html) (not supported yet)
11
+
12
+ #### Installation
13
+ gem install thor
7
14
 
8
15
  #### Example
9
16
  ```
10
- tinventory --map=aws_instance.web:web aws_instance.web.1:db ./inventory
17
+ tinventory --map=aws_instance.web:web aws_instance.web.0:blog aws_instance.web.1:api ./inventory
11
18
  ```
19
+ Translation:
20
+ - Put all aws_instance resources named web in the web host group of the inventory file
21
+ - Put the first aws_instance resource named web in the blog host group of the inventory file
22
+ - Put the second aws_instance resource named web in the api host group of the inventory file
23
+ - The inventory file is called "./inventory"
24
+
25
+ This scenario demonstrates that you can select resources from Terraform state and put the resulting resources in a specific host group of the Ansible inventory file.
26
+
27
+ #### Commands
28
+ Options:
29
+ - --map=resource_selector:host_group (required)
30
+ - Maps between Terraform resource selector and Ansible host group.
31
+ - The "none" host group puts the hosts IP address at the top of the file without a group
32
+ - --state=<path to state file> (optional)
33
+ - Path to a Terraform state file.
34
+ - Default: /home/tyler/Projects/terraform_inventory/terraform.tfstate
35
+
36
+ #### License
37
+ [MIT](LICENSE.md)
data/Thorfile CHANGED
@@ -24,12 +24,16 @@ class Default < Thor
24
24
 
25
25
  desc "rubocop", "Run Rubocop on all Ruby files"
26
26
  def rubocop
27
- exec "rubocop"
27
+ say "Performing linting and style checking with rubocop...", :white
28
+ success = system "rubocop"
29
+ exit(!success) unless success
28
30
  end
29
31
 
30
32
  desc "spec", "Run tests."
31
33
  def spec
32
- exec "rspec spec"
34
+ say "Running all rspec tests...", :white
35
+ success = system "rspec spec"
36
+ exit(!success) unless success
33
37
  end
34
38
 
35
39
  desc "check", "Lint, style, and test."
data/bin/tinventory CHANGED
File without changes
@@ -49,7 +49,7 @@ module TerraformInventory
49
49
  private
50
50
 
51
51
  def parse_resource_selector(resource_selector)
52
- resource_selector_regex = /^(\w+)\.(\w+)(?:\.(\d+))?$/
52
+ resource_selector_regex = /^(\w+)\.([\w@\-]+)(?:\.(\d+))?$/
53
53
  matches = resource_selector_regex.match(resource_selector)
54
54
 
55
55
  raise Exception::InvalidResourceSelectorException, resource_selector if matches.nil?
@@ -1,3 +1,3 @@
1
1
  module TerraformInventory
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terraform_inventory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
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-13 00:00:00.000000000 Z
11
+ date: 2014-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -84,5 +84,5 @@ signing_key:
84
84
  specification_version: 4
85
85
  summary: Map Terraform state to an Ansible inventory file
86
86
  test_files:
87
- - spec/terraform_inventory/terraform_state_spec.rb
88
87
  - spec/spec_helper.rb
88
+ - spec/terraform_inventory/terraform_state_spec.rb