mirror of
https://github.com/thegeeklab/wp-ansible.git
synced 2024-11-24 12:40:39 +00:00
chore: cleanup docs and use cmd trace from plugin lib (#9)
This commit is contained in:
parent
c92e1cebd0
commit
01711c9daa
@ -13,6 +13,7 @@ import (
|
||||
"github.com/thegeeklab/wp-ansible/plugin"
|
||||
"github.com/thegeeklab/wp-plugin-go/docs"
|
||||
wp "github.com/thegeeklab/wp-plugin-go/plugin"
|
||||
wp_template "github.com/thegeeklab/wp-plugin-go/template"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
@ -43,7 +44,7 @@ func main() {
|
||||
func toYAML(app *cli.App) (string, error) {
|
||||
var w bytes.Buffer
|
||||
|
||||
yamlTmpl, err := template.New("docs").ParseFS(yamlTemplate, "templates/docs-data.yaml.tmpl")
|
||||
yamlTmpl, err := template.New("docs").Funcs(wp_template.LoadFuncMap()).ParseFS(yamlTemplate, "templates/docs-data.yaml.tmpl")
|
||||
if err != nil {
|
||||
fmt.Println(yamlTmpl)
|
||||
return "", err
|
||||
|
@ -68,7 +68,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
Name: "extra-vars",
|
||||
Usage: "set additional variables as key=value",
|
||||
Usage: "set additional variables as `key=value`",
|
||||
EnvVars: []string{"PLUGIN_EXTRA_VARS", "ANSIBLE_EXTRA_VARS"},
|
||||
Destination: &settings.ExtraVars,
|
||||
Category: category,
|
||||
@ -167,7 +167,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "private-key",
|
||||
Usage: "ssh private key used to authenticate the connection",
|
||||
Usage: "SSH private key used to authenticate the connection",
|
||||
EnvVars: []string{"PLUGIN_PRIVATE_KEY", "ANSIBLE_PRIVATE_KEY"},
|
||||
Destination: &settings.PrivateKey,
|
||||
Category: category,
|
||||
@ -195,28 +195,28 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "ssh-common-args",
|
||||
Usage: "specify common arguments to pass to sftp,scp and ssh connections",
|
||||
Usage: "specify common arguments to pass to SFTP, SCP and SSH connections",
|
||||
EnvVars: []string{"PLUGIN_SSH_COMMON_ARGS"},
|
||||
Destination: &settings.SSHCommonArgs,
|
||||
Category: category,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "sftp-extra-args",
|
||||
Usage: "specify extra arguments to pass to sftp connections only",
|
||||
Usage: "specify extra arguments to pass to SFTP connections only",
|
||||
EnvVars: []string{"PLUGIN_SFTP_EXTRA_ARGS"},
|
||||
Destination: &settings.SFTPExtraArgs,
|
||||
Category: category,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "scp-extra-args",
|
||||
Usage: "specify extra arguments to pass to scp connections only",
|
||||
Usage: "specify extra arguments to pass to SCP connections only",
|
||||
EnvVars: []string{"PLUGIN_SCP_EXTRA_ARGS"},
|
||||
Destination: &settings.SCPExtraArgs,
|
||||
Category: category,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "ssh-extra-args",
|
||||
Usage: "specify extra arguments to pass to ssh connections only",
|
||||
Usage: "specify extra arguments to pass to SSH connections only",
|
||||
EnvVars: []string{"PLUGIN_SSH_EXTRA_ARGS"},
|
||||
Destination: &settings.SSHExtraArgs,
|
||||
Category: category,
|
||||
|
@ -5,10 +5,14 @@ properties:
|
||||
- name: {{ $v.Name }}
|
||||
{{- with $v.Description }}
|
||||
description: |
|
||||
{{ . }}
|
||||
{{ . | ToSentence }}
|
||||
{{- end }}
|
||||
{{- with $v.Type }}
|
||||
type: {{ . }}
|
||||
{{- end }}
|
||||
{{- with $v.Default }}
|
||||
defaultvalue: {{ . }}
|
||||
{{- end }}
|
||||
required: {{ default false $v.Required }}
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
|
@ -3,143 +3,209 @@ properties:
|
||||
- name: become
|
||||
description: |
|
||||
Enable privilege escalation.
|
||||
type: bool
|
||||
defaultvalue: false
|
||||
required: false
|
||||
|
||||
- name: become_method
|
||||
description: |
|
||||
Privilege escalation method to use.
|
||||
type: string
|
||||
required: false
|
||||
|
||||
- name: become_user
|
||||
description: |
|
||||
Privilege escalation user to use.
|
||||
type: string
|
||||
required: false
|
||||
|
||||
- name: check
|
||||
description: |
|
||||
Run a check, do not apply any changes.
|
||||
type: bool
|
||||
defaultvalue: false
|
||||
required: false
|
||||
|
||||
- name: connection
|
||||
description: |
|
||||
Connection type to use.
|
||||
type: string
|
||||
required: false
|
||||
|
||||
- name: diff
|
||||
description: |
|
||||
Show the differences. Be careful when using it in public CI environments as it can print secrets.
|
||||
type: bool
|
||||
defaultvalue: false
|
||||
required: false
|
||||
|
||||
- name: extra_vars
|
||||
description: |
|
||||
Set additional variables as `key=value`.
|
||||
type: list
|
||||
required: false
|
||||
|
||||
- name: flush_cache
|
||||
description: |
|
||||
Clear the fact cache for every host in inventory.
|
||||
type: bool
|
||||
defaultvalue: false
|
||||
required: false
|
||||
|
||||
- name: force_handlers
|
||||
description: |
|
||||
Run handlers even if a task fails.
|
||||
type: bool
|
||||
defaultvalue: false
|
||||
required: false
|
||||
|
||||
- name: forks
|
||||
description: |
|
||||
Specify number of parallel processes to use.
|
||||
type: integer
|
||||
defaultvalue: 5
|
||||
required: false
|
||||
|
||||
- name: galaxy_requirements
|
||||
description: |
|
||||
Path to galaxy requirements file.
|
||||
type: string
|
||||
required: false
|
||||
|
||||
- name: inventory
|
||||
description: |
|
||||
Path to inventory file.
|
||||
type: list
|
||||
required: false
|
||||
|
||||
- name: limit
|
||||
description: |
|
||||
Limit selected hosts to an additional pattern.
|
||||
type: string
|
||||
required: false
|
||||
|
||||
- name: list_hosts
|
||||
description: |
|
||||
Outputs a list of matching hosts.
|
||||
type: bool
|
||||
defaultvalue: false
|
||||
required: false
|
||||
|
||||
- name: list_tags
|
||||
description: |
|
||||
List all available tags.
|
||||
type: bool
|
||||
defaultvalue: false
|
||||
required: false
|
||||
|
||||
- name: list_tasks
|
||||
description: |
|
||||
List all tasks that would be executed.
|
||||
type: bool
|
||||
defaultvalue: false
|
||||
required: false
|
||||
|
||||
- name: module_path
|
||||
description: |
|
||||
Prepend paths to module library.
|
||||
type: list
|
||||
required: false
|
||||
|
||||
- name: playbook
|
||||
description: |
|
||||
List of playbooks to apply.
|
||||
type: list
|
||||
required: false
|
||||
|
||||
- name: private_key
|
||||
description: |
|
||||
SSH private key used to authenticate the connection.
|
||||
type: string
|
||||
required: false
|
||||
|
||||
- name: python_requirements
|
||||
description: |
|
||||
Path to python requirements file.
|
||||
type: string
|
||||
required: false
|
||||
|
||||
- name: scp_extra_args
|
||||
description: |
|
||||
Specify extra arguments to pass to SCP connections only.
|
||||
type: string
|
||||
required: false
|
||||
|
||||
- name: sftp_extra_args
|
||||
description: |
|
||||
Specify extra arguments to pass to SFTP connections only.
|
||||
type: string
|
||||
required: false
|
||||
|
||||
- name: skip_tags
|
||||
description: |
|
||||
Only run plays and tasks whose tags do not match.
|
||||
type: string
|
||||
required: false
|
||||
|
||||
- name: ssh_common_args
|
||||
description: |
|
||||
Specify common arguments to pass to SFTP, SCP and SSH connections.
|
||||
type: string
|
||||
required: false
|
||||
|
||||
- name: ssh_extra_args
|
||||
description: |
|
||||
Specify extra arguments to pass to ssh connections only.
|
||||
Specify extra arguments to pass to SSH connections only.
|
||||
type: string
|
||||
required: false
|
||||
|
||||
- name: start_at_task
|
||||
description: |
|
||||
Start the playbook at the task matching this name.
|
||||
type: string
|
||||
required: false
|
||||
|
||||
- name: syntax_check
|
||||
description: |
|
||||
Perform a syntax check on the playbook.
|
||||
type: bool
|
||||
defaultvalue: false
|
||||
required: false
|
||||
|
||||
- name: tags
|
||||
description: |
|
||||
Only run plays and tasks tagged with these values.
|
||||
type: string
|
||||
required: false
|
||||
|
||||
- name: timeout
|
||||
description: |
|
||||
Override the connection timeout in seconds.
|
||||
type: integer
|
||||
defaultvalue: 0
|
||||
required: false
|
||||
|
||||
- name: user
|
||||
description: |
|
||||
Connect as this user.
|
||||
type: string
|
||||
required: false
|
||||
|
||||
- name: vault_id
|
||||
description: |
|
||||
The vault identity to use.
|
||||
type: string
|
||||
required: false
|
||||
|
||||
- name: vault_password
|
||||
description: |
|
||||
The vault password to use.
|
||||
type: string
|
||||
required: false
|
||||
|
||||
- name: verbose
|
||||
description: |
|
||||
Level of verbosity, 0 up to 4.
|
||||
type: integer
|
||||
defaultvalue: 0
|
||||
required: false
|
||||
|
@ -290,7 +290,3 @@ func (p *Plugin) ansibleCommand(inventory string) *execabs.Cmd {
|
||||
args...,
|
||||
)
|
||||
}
|
||||
|
||||
func trace(cmd *execabs.Cmd) {
|
||||
fmt.Println("$", strings.Join(cmd.Args, " "))
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/thegeeklab/wp-plugin-go/trace"
|
||||
"golang.org/x/sys/execabs"
|
||||
)
|
||||
|
||||
@ -89,7 +90,7 @@ func (p *Plugin) Execute() error {
|
||||
cmd.Env = os.Environ()
|
||||
cmd.Env = append(cmd.Env, "ANSIBLE_FORCE_COLOR=1")
|
||||
|
||||
trace(cmd)
|
||||
trace.Cmd(cmd)
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user