-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Add example showcasing how to use the ansible-inventory feature"
This reverts commit c5ac97e.
- Loading branch information
1 parent
c5ac97e
commit 990281c
Showing
7 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"github.com/apenella/go-ansible/pkg/inventory" | ||
"log" | ||
) | ||
|
||
func main() { | ||
ansibleInventoryOptions := inventory.AnsibleInventoryOptions{ | ||
Graph: true, | ||
Inventory: "inventory.yml", | ||
Vars: true, | ||
Yaml: true, | ||
} | ||
|
||
inventoryCmd := inventory.AnsibleInventoryCmd{ | ||
Pattern: "all", | ||
Options: &ansibleInventoryOptions, | ||
} | ||
|
||
results, _ := inventoryCmd.Command() | ||
log.Println("Test strings", inventoryCmd.String()) | ||
for _, result := range results { | ||
log.Println("Command Data: ", result) | ||
} | ||
|
||
err := inventoryCmd.Run(context.TODO()) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
all: | ||
children: | ||
webserver: | ||
hosts: | ||
web1: | ||
ansible_host: 192.168.1.101 | ||
http_port: 80 | ||
max_clients: 200 | ||
web2: | ||
ansible_host: 192.168.1.102 | ||
http_port: 80 | ||
max_clients: 150 | ||
|
||
database: | ||
hosts: | ||
db1: | ||
ansible_host: 192.168.1.103 | ||
db_port: 5432 | ||
db_name: 'mydb' | ||
|
||
vars: | ||
ansible_user: 'admin' |
32 changes: 32 additions & 0 deletions
32
examples/ansibleinventory-simple/ansibleinventory-simple.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"github.com/apenella/go-ansible/pkg/inventory" | ||
"log" | ||
) | ||
|
||
func main() { | ||
ansibleInventoryOptions := inventory.AnsibleInventoryOptions{ | ||
Inventory: "inventory.yml", | ||
List: true, | ||
Yaml: true, | ||
} | ||
|
||
inventoryCmd := inventory.AnsibleInventoryCmd{ | ||
Pattern: "all", | ||
Options: &ansibleInventoryOptions, | ||
} | ||
|
||
results, _ := inventoryCmd.Command() | ||
log.Println("Test strings", inventoryCmd.String()) | ||
for _, result := range results { | ||
log.Println("Command Data: ", result) | ||
} | ||
|
||
err := inventoryCmd.Run(context.TODO()) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
all: | ||
children: | ||
webserver: | ||
hosts: | ||
web1: | ||
ansible_host: 192.168.1.101 | ||
http_port: 80 | ||
max_clients: 200 | ||
web2: | ||
ansible_host: 192.168.1.102 | ||
http_port: 80 | ||
max_clients: 150 | ||
|
||
database: | ||
hosts: | ||
db1: | ||
ansible_host: 192.168.1.103 | ||
db_port: 5432 | ||
db_name: 'mydb' | ||
|
||
vars: | ||
ansible_user: 'admin' |
34 changes: 34 additions & 0 deletions
34
examples/ansibleinventory-vaulted-vars/ansible-inventory-vaulted-vars.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"github.com/apenella/go-ansible/pkg/inventory" | ||
"log" | ||
) | ||
|
||
func main() { | ||
ansibleInventoryOptions := inventory.AnsibleInventoryOptions{ | ||
Graph: true, | ||
Inventory: "inventory.yml", | ||
Vars: true, | ||
Yaml: true, | ||
VaultPasswordFile: "vault_password.cfg", | ||
} | ||
|
||
inventoryCmd := inventory.AnsibleInventoryCmd{ | ||
Pattern: "all", | ||
Options: &ansibleInventoryOptions, | ||
} | ||
|
||
results, _ := inventoryCmd.Command() | ||
log.Println("Test strings", inventoryCmd.String()) | ||
for _, result := range results { | ||
log.Println("Command Data: ", result) | ||
} | ||
|
||
err := inventoryCmd.Run(context.TODO()) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
all: | ||
children: | ||
database_servers: | ||
hosts: | ||
db1.example.com: | ||
db2.example.com: | ||
vars: | ||
ansible_ssh_user: dbadmin | ||
ansible_ssh_pass: !vault | | ||
$ANSIBLE_VAULT;1.1;AES256 | ||
35666433353234313161636238653633313264383230316233656236313935313465666533646164 | ||
3039353461343961616134653164666663646362646336360a383332663562396237613264386636 | ||
66663233616235396662383434343966333665383937653839326633333861366162616365353533 | ||
6237653031613664340a383736643130303935633164366536363561663334643763343661666138 | ||
62343234643536663061316666626466343265353065333439643065313134633132 | ||
db_port: 5432 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ThatIsAPassword |