Skip to content

Commit

Permalink
Merge pull request #10 from nbering/individual-vars
Browse files Browse the repository at this point in the history
Individual vars
  • Loading branch information
nbering authored May 20, 2019
2 parents a3fa837 + 876db69 commit 344d541
Show file tree
Hide file tree
Showing 8 changed files with 377 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Support for `ansible_host_var` resource type
- Support for `ansible_group_var` resource type

### Fixed
- Corrected a minor issue where `ansible_host` or `ansible_host_var` resources with the same `inventory_hostname` would result in multiple copies of the hostname in any groups they shared in common (including the "all" group)

## [2.0.0] - 2019-05-05
### Added
Expand Down
47 changes: 47 additions & 0 deletions sample_data/0.11.x/individual-vars/expect.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"_meta": {
"hostvars": {
"db.example.com": {
"bar": "ddd",
"foo": "ccc"
},
"www.example.com": {
"bar": "bbb",
"db_host": "db.example.com",
"foo": "aaa"
}
}
},
"all": {
"children": [],
"hosts": [
"www.example.com",
"db.example.com"
],
"vars": {}
},
"db": {
"children": [],
"hosts": [
"db.example.com"
],
"vars": {
"ansible_user": "postgres"
}
},
"example": {
"children": [],
"hosts": [
"www.example.com",
"db.example.com"
],
"vars": {}
},
"web": {
"children": [],
"hosts": [
"www.example.com"
],
"vars": {}
}
}
29 changes: 29 additions & 0 deletions sample_data/0.11.x/individual-vars/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
resource "ansible_host" "www" {
inventory_hostname = "www.example.com"
groups = ["example", "web"]
vars = {
foo = "aaa"
bar = "bbb"
}
}

resource "ansible_host" "db" {
inventory_hostname = "db.example.com"
groups = ["example", "db"]
vars = {
foo = "ccc"
bar = "ddd"
}
}

resource "ansible_host_var" "extra" {
inventory_hostname = "www.example.com"
key = "db_host"
value = "${ansible_host.db.inventory_hostname}"
}

resource "ansible_group_var" "extra" {
inventory_group_name = "db"
key = "ansible_user"
value = "postgres"
}
95 changes: 95 additions & 0 deletions sample_data/0.11.x/individual-vars/terraform.tfstate
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"version": 3,
"terraform_version": "0.11.14",
"serial": 1,
"lineage": "fd5627d8-41cc-2c58-f463-66453b5f2978",
"modules": [
{
"path": [
"root"
],
"outputs": {},
"resources": {
"ansible_group_var.extra": {
"type": "ansible_group_var",
"depends_on": [],
"primary": {
"id": "db/ansible_user",
"attributes": {
"id": "db/ansible_user",
"inventory_group_name": "db",
"key": "ansible_user",
"value": "postgres"
},
"meta": {},
"tainted": false
},
"deposed": [],
"provider": "provider.ansible"
},
"ansible_host.db": {
"type": "ansible_host",
"depends_on": [],
"primary": {
"id": "db.example.com",
"attributes": {
"groups.#": "2",
"groups.0": "example",
"groups.1": "db",
"id": "db.example.com",
"inventory_hostname": "db.example.com",
"vars.%": "2",
"vars.bar": "ddd",
"vars.foo": "ccc"
},
"meta": {},
"tainted": false
},
"deposed": [],
"provider": "provider.ansible"
},
"ansible_host.www": {
"type": "ansible_host",
"depends_on": [],
"primary": {
"id": "www.example.com",
"attributes": {
"groups.#": "2",
"groups.0": "example",
"groups.1": "web",
"id": "www.example.com",
"inventory_hostname": "www.example.com",
"vars.%": "2",
"vars.bar": "bbb",
"vars.foo": "aaa"
},
"meta": {},
"tainted": false
},
"deposed": [],
"provider": "provider.ansible"
},
"ansible_host_var.extra": {
"type": "ansible_host_var",
"depends_on": [
"ansible_host.db"
],
"primary": {
"id": "www.example.com/db_host",
"attributes": {
"id": "www.example.com/db_host",
"inventory_hostname": "www.example.com",
"key": "db_host",
"value": "db.example.com"
},
"meta": {},
"tainted": false
},
"deposed": [],
"provider": "provider.ansible"
}
},
"depends_on": []
}
]
}
47 changes: 47 additions & 0 deletions sample_data/0.12.x/individual-vars/expect.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"_meta": {
"hostvars": {
"db.example.com": {
"bar": "ddd",
"foo": "ccc"
},
"www.example.com": {
"bar": "bbb",
"db_host": "db.example.com",
"foo": "aaa"
}
}
},
"all": {
"children": [],
"hosts": [
"db.example.com",
"www.example.com"
],
"vars": {}
},
"db": {
"children": [],
"hosts": [
"db.example.com"
],
"vars": {
"ansible_user": "postgres"
}
},
"example": {
"children": [],
"hosts": [
"db.example.com",
"www.example.com"
],
"vars": {}
},
"web": {
"children": [],
"hosts": [
"www.example.com"
],
"vars": {}
}
}
29 changes: 29 additions & 0 deletions sample_data/0.12.x/individual-vars/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
resource "ansible_host" "www" {
inventory_hostname = "www.example.com"
groups = ["example", "web"]
vars = {
foo = "aaa"
bar = "bbb"
}
}

resource "ansible_host" "db" {
inventory_hostname = "db.example.com"
groups = ["example", "db"]
vars = {
foo = "ccc"
bar = "ddd"
}
}

resource "ansible_host_var" "extra" {
inventory_hostname = "www.example.com"
key = "db_host"
value = "${ansible_host.db.inventory_hostname}"
}

resource "ansible_group_var" "extra" {
inventory_group_name = "db"
key = "ansible_user"
value = "postgres"
}
92 changes: 92 additions & 0 deletions sample_data/0.12.x/individual-vars/terraform.tfstate
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"version": 4,
"terraform_version": "0.12.0",
"serial": 5,
"lineage": "40cc4be1-f5ea-02d6-b06a-26813e05cd13",
"outputs": {},
"resources": [
{
"mode": "managed",
"type": "ansible_group_var",
"name": "extra",
"provider": "provider.ansible",
"instances": [
{
"schema_version": 0,
"attributes": {
"id": "db/ansible_user",
"inventory_group_name": "db",
"key": "ansible_user",
"value": "postgres"
}
}
]
},
{
"mode": "managed",
"type": "ansible_host",
"name": "db",
"provider": "provider.ansible",
"instances": [
{
"schema_version": 0,
"attributes": {
"groups": [
"example",
"db"
],
"id": "db.example.com",
"inventory_hostname": "db.example.com",
"vars": {
"bar": "ddd",
"foo": "ccc"
}
}
}
]
},
{
"mode": "managed",
"type": "ansible_host",
"name": "www",
"provider": "provider.ansible",
"instances": [
{
"schema_version": 0,
"attributes": {
"groups": [
"example",
"web"
],
"id": "www.example.com",
"inventory_hostname": "www.example.com",
"vars": {
"bar": "bbb",
"foo": "aaa"
}
}
}
]
},
{
"mode": "managed",
"type": "ansible_host_var",
"name": "extra",
"provider": "provider.ansible",
"instances": [
{
"schema_version": 0,
"attributes": {
"id": "www.example.com/db_host",
"inventory_hostname": "www.example.com",
"key": "db_host",
"value": "db.example.com"
},
"depends_on": [
"ansible_host.db"
]
}
]
}
]
}
Loading

0 comments on commit 344d541

Please sign in to comment.