Simple implementation of "ansible_group_var" resource.
This commit is contained in:
Родитель
8367f61f61
Коммит
6361ca4a84
|
@ -8,9 +8,10 @@ import (
|
|||
func Provider() terraform.ResourceProvider {
|
||||
return &schema.Provider{
|
||||
ResourcesMap: map[string]*schema.Resource{
|
||||
"ansible_host": resourceHost(),
|
||||
"ansible_host_var": resourceHostVar(),
|
||||
"ansible_group": resourceGroup(),
|
||||
"ansible_host": resourceHost(),
|
||||
"ansible_host_var": resourceHostVar(),
|
||||
"ansible_group": resourceGroup(),
|
||||
"ansible_group_var": resourceGroupVar(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package ansible
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
func resourceGroupVar() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
Create: resourceAnsibleGroupVarCreate,
|
||||
Read: schema.Noop,
|
||||
Update: schema.Noop,
|
||||
Delete: schema.Noop,
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"inventory_group_name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"key": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"value": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func resourceAnsibleGroupVarCreate(d *schema.ResourceData, _ interface{}) error {
|
||||
d.SetId(fmt.Sprintf("%s/%s", d.Get("inventory_group_name"), d.Get("key")))
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package ansible
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAnsibleGroupVar(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
Providers: testAccProviders,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAnsibleGroupVarConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
resource.TestCheckResourceAttr(
|
||||
"ansible_group_var.groupvar_1", "id", "web/baz"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"ansible_group_var.groupvar_1", "inventory_group_name", "web"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"ansible_group_var.groupvar_1", "key", "baz"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"ansible_group_var.groupvar_1", "value", "bup"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const testAnsibleGroupVarConfig = `
|
||||
resource "ansible_group_var" "groupvar_1" {
|
||||
inventory_group_name = "web"
|
||||
key = "baz"
|
||||
value = "bup"
|
||||
}
|
||||
`
|
Загрузка…
Ссылка в новой задаче