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 +4 -4
- data/README.md +29 -3
- data/Thorfile +6 -2
- data/bin/tinventory +0 -0
- data/lib/terraform_inventory/terraform_state.rb +1 -1
- data/lib/terraform_inventory/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb1dc0be69d25224429142350a53e6aa386e10ad
|
4
|
+
data.tar.gz: 995be478df7ecaab176e562ce1f0422ecfad0574
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c55621646dcb1c9e712647586a185e9d6d30e57c1a98a90b1b80467dd1dd2e495738c44e83a7492b7660ffc8e0a3e21635d77877ad80de079c190081fb99c05
|
7
|
+
data.tar.gz: d2c8b12dbb62e52fae4c9197040e00a730a1920fc856a374f4290d9a5c8b9e6d4e86c18192b661a44142028e21beeb37c669d481374bd0f70ebb789b556800e9
|
data/README.md
CHANGED
@@ -1,11 +1,37 @@
|
|
1
|
-
terraform_inventory
|
1
|
+
terraform_inventory [](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
|
-
|
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:
|
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
|
-
|
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
|
-
|
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?
|
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.
|
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-
|
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
|