inventory

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecCmd

func ExecCmd(cmd string, arg string, tfsFile string) (interface{}, error)

ExecCmd executes one of available commands: list, host and inventory. It checks if a tfstate is given in command line argument or not. If yes, it will use it. Otherwise, it checks 2 environment variables TF_BIN (path to terraform binary) and TF_DIR (path to terraform folder). If they are set, so `terraform state pull` is executed automatically to get Terrafrm tftstate to parse.

Types

type Group

type Group struct {
	Name  string                 `json:"-"`
	Vars  map[string]interface{} `json:"vars"`
	Hosts []string               `json:"hosts"`
}

Group represents an Ansible inventory group

type Groups

type Groups map[string]*Group

Groups is map representing a list of groups

type Host

type Host struct {
	Name      string                 `json:"-"`
	GroupName string                 `json:"-"`
	Vars      map[string]interface{} `json:"vars"`
}

Host represents an Ansible inventory host

type Hosts

type Hosts map[string]*Host

Hosts is map representing a list of hosts

type Module

type Module struct {
	Path      []string            `json:"path"`
	Outputs   map[string]Output   `json:"outputs"`
	Resources map[string]Resource `json:"resources"`
	DependsOn []string            `json:"depends_on"`
}

Module represents module element in Terraform tfstate

type Output

type Output struct {
	Sensitive bool        `json:"sensitive"`
	Type      string      `json:"type"`
	Value     interface{} `json:"value"`
}

Output represents output characteristics in Terraform tfstate

type Primary

type Primary struct {
	ID         string                 `json:"id"`
	Attributes map[string]string      `json:"attributes"`
	Meta       map[string]interface{} `json:"meta"`
	Tainted    bool                   `json:"tainted"`
}

Primary represents a primary element in Terraform tfstate

type Resource

type Resource struct {
	Type      string   `json:"type"`
	DependsOn []string `json:"depends_on"`
	Primary   Primary  `json:"primary"`
	Deposed   []string `json:"deposed"`
	Provider  string   `json:"provider"`
}

Resource represents a resource element in Terraform tfstate

type TFState

type TFState struct {
	Modules []Module `json:"modules"`
}

TFState is a struct representing terraform tfstate

func (*TFState) Parse

func (t *TFState) Parse(tfs []byte) (*TFStateParsed, error)

Parse parse and fill up TFState struct

type TFStateParsed

type TFStateParsed struct {
	Hosts  Hosts
	Groups Groups
}

TFStateParsed represents a tfstate under Ansible inventory format

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL