-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
import changes from v1.3.0 and adapt the AnsibleInventoryCmd to implement the Commander interface.
- Loading branch information
Showing
14 changed files
with
856 additions
and
14 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
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
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
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" | ||
"fmt" | ||
|
||
"github.com/apenella/go-ansible/pkg/execute" | ||
"github.com/apenella/go-ansible/pkg/inventory" | ||
) | ||
|
||
func main() { | ||
ansibleInventoryOptions := inventory.AnsibleInventoryOptions{ | ||
Graph: true, | ||
Inventory: "inventory.yml", | ||
Vars: true, | ||
Yaml: true, | ||
} | ||
|
||
inventoryCmd := &inventory.AnsibleInventoryCmd{ | ||
Pattern: "all", | ||
Options: &ansibleInventoryOptions, | ||
} | ||
|
||
fmt.Println("Test strings:", inventoryCmd.String()) | ||
Check failure Code scanning / CodeQL Clear-text logging of sensitive information High Sensitive data returned by an access to VaultPasswordFile Error loading related location Loading |
||
|
||
exec := execute.NewDefaultExecute( | ||
execute.WithCmd(inventoryCmd), | ||
) | ||
|
||
err := exec.Execute(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' |
33 changes: 33 additions & 0 deletions
33
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,33 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/apenella/go-ansible/pkg/execute" | ||
"github.com/apenella/go-ansible/pkg/inventory" | ||
) | ||
|
||
func main() { | ||
ansibleInventoryOptions := inventory.AnsibleInventoryOptions{ | ||
Inventory: "inventory.yml", | ||
List: true, | ||
Yaml: true, | ||
} | ||
|
||
inventoryCmd := &inventory.AnsibleInventoryCmd{ | ||
Pattern: "all", | ||
Options: &ansibleInventoryOptions, | ||
} | ||
|
||
fmt.Println("Test strings:", inventoryCmd.String()) | ||
Check failure Code scanning / CodeQL Clear-text logging of sensitive information High Sensitive data returned by an access to VaultPasswordFile Error loading related location Loading |
||
|
||
exec := execute.NewDefaultExecute( | ||
execute.WithCmd(inventoryCmd), | ||
) | ||
|
||
err := exec.Execute(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' |
35 changes: 35 additions & 0 deletions
35
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,35 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/apenella/go-ansible/pkg/execute" | ||
"github.com/apenella/go-ansible/pkg/inventory" | ||
) | ||
|
||
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, | ||
} | ||
|
||
fmt.Println("Test strings:", inventoryCmd.String()) | ||
Check failure Code scanning / CodeQL Clear-text logging of sensitive information High Sensitive data returned by an access to VaultPasswordFile Error loading related location Loading |
||
|
||
exec := execute.NewDefaultExecute( | ||
execute.WithCmd(inventoryCmd), | ||
) | ||
|
||
err := exec.Execute(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 |
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
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
Oops, something went wrong.