-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ⭐️ ansible provider * Add missing ansible.lr.manifest.yaml file Signed-off-by: Tim Smith <[email protected]> --------- Signed-off-by: Tim Smith <[email protected]> Co-authored-by: Tim Smith <[email protected]>
- Loading branch information
1 parent
66387fa
commit 39bb10f
Showing
29 changed files
with
3,180 additions
and
24 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,27 @@ | ||
// Copyright (c) Mondoo, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
package config | ||
|
||
import ( | ||
"go.mondoo.com/cnquery/v11/providers-sdk/v1/plugin" | ||
"go.mondoo.com/cnquery/v11/providers/ansible/provider" | ||
) | ||
|
||
var Config = plugin.Provider{ | ||
Name: "ansible", | ||
ID: "go.mondoo.com/cnquery/v11/providers/ansible", | ||
Version: "10.0.0", | ||
ConnectionTypes: []string{provider.DefaultConnectionType}, | ||
Connectors: []plugin.Connector{ | ||
{ | ||
Name: "ansible", | ||
Use: "ansible PATH", | ||
Short: "an Ansible playbook", | ||
MinArgs: 1, | ||
MaxArgs: 1, | ||
Discovery: []string{}, | ||
Flags: []plugin.Flag{}, | ||
}, | ||
}, | ||
} |
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,67 @@ | ||
// Copyright (c) Mondoo, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
package connection | ||
|
||
import ( | ||
"go.mondoo.com/cnquery/v11/providers-sdk/v1/inventory" | ||
"go.mondoo.com/cnquery/v11/providers-sdk/v1/plugin" | ||
"go.mondoo.com/cnquery/v11/providers/ansible/play" | ||
"io" | ||
"os" | ||
) | ||
|
||
var _ plugin.Connection = (*AnsibleConnection)(nil) | ||
|
||
type AnsibleConnection struct { | ||
plugin.Connection | ||
Conf *inventory.Config | ||
asset *inventory.Asset | ||
// Add custom connection fields here | ||
path string | ||
playbook play.Playbook | ||
} | ||
|
||
func NewAnsibleConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (*AnsibleConnection, error) { | ||
conn := &AnsibleConnection{ | ||
Connection: plugin.NewConnection(id, asset), | ||
Conf: conf, | ||
asset: asset, | ||
} | ||
|
||
// initialize your connection here | ||
cc := asset.Connections[0] | ||
path := cc.Options["path"] | ||
conn.path = path | ||
|
||
f, err := os.Open(path) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer f.Close() | ||
|
||
data, err := io.ReadAll(f) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
playbook, err := play.DecodePlaybook(data) | ||
if err != nil { | ||
return nil, err | ||
} | ||
conn.playbook = playbook | ||
|
||
return conn, nil | ||
} | ||
|
||
func (c *AnsibleConnection) Name() string { | ||
return "ansible" | ||
} | ||
|
||
func (c *AnsibleConnection) Asset() *inventory.Asset { | ||
return c.asset | ||
} | ||
|
||
func (c *AnsibleConnection) Playbook() play.Playbook { | ||
return c.playbook | ||
} |
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,13 @@ | ||
// Copyright (c) Mondoo, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
package main | ||
|
||
import ( | ||
"go.mondoo.com/cnquery/v11/providers-sdk/v1/plugin/gen" | ||
"go.mondoo.com/cnquery/v11/providers/ansible/config" | ||
) | ||
|
||
func main() { | ||
gen.CLI(&config.Config) | ||
} |
Oops, something went wrong.