mirror of
https://github.com/thegeeklab/wp-ansible.git
synced 2024-11-23 06:10:39 +00:00
fix: fix static bin paths and required flags (#50)
This commit is contained in:
parent
93819eb5b2
commit
2f1a89a6cb
@ -28,6 +28,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
|
||||
Name: "inventory",
|
||||
Usage: "path to inventory file",
|
||||
EnvVars: []string{"PLUGIN_INVENTORY", "PLUGIN_INVENTORIES"},
|
||||
Required: true,
|
||||
Destination: &settings.Inventories,
|
||||
Category: category,
|
||||
},
|
||||
@ -35,6 +36,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
|
||||
Name: "playbook",
|
||||
Usage: "list of playbooks to apply",
|
||||
EnvVars: []string{"PLUGIN_PLAYBOOK", "PLUGIN_PLAYBOOKS"},
|
||||
Required: true,
|
||||
Destination: &settings.Playbooks,
|
||||
Category: category,
|
||||
},
|
||||
|
@ -76,7 +76,7 @@ properties:
|
||||
description: |
|
||||
Path to inventory file.
|
||||
type: list
|
||||
required: false
|
||||
required: true
|
||||
|
||||
- name: limit
|
||||
description: |
|
||||
@ -115,7 +115,7 @@ properties:
|
||||
description: |
|
||||
List of playbooks to apply.
|
||||
type: list
|
||||
required: false
|
||||
required: true
|
||||
|
||||
- name: private_key
|
||||
description: |
|
||||
|
@ -18,10 +18,10 @@ const (
|
||||
ansibleFolder = "/etc/ansible"
|
||||
ansibleConfig = "/etc/ansible/ansible.cfg"
|
||||
|
||||
pipBin = "/usr/bin/pip"
|
||||
ansibleBin = "/usr/bin/ansible"
|
||||
ansibleGalaxyBin = "/usr/bin/ansible-galaxy"
|
||||
ansiblePlaybookBin = "/usr/bin/ansible-playbook"
|
||||
pipBin = "/usr/local/bin/pip"
|
||||
ansibleBin = "/usr/local/bin/ansible"
|
||||
ansibleGalaxyBin = "/usr/local/bin/ansible-galaxy"
|
||||
ansiblePlaybookBin = "/usr/local/bin/ansible-playbook"
|
||||
|
||||
strictFilePerm = 0o600
|
||||
)
|
||||
|
@ -2,7 +2,6 @@ package plugin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
@ -10,13 +9,7 @@ import (
|
||||
"golang.org/x/sys/execabs"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrPluginPlaybookNotSet = errors.New("playbook is required")
|
||||
ErrPluginInventoryNotSet = errors.New("inventory is required")
|
||||
)
|
||||
|
||||
//nolint:revive
|
||||
func (p *Plugin) run(ctx context.Context) error {
|
||||
func (p *Plugin) run(_ context.Context) error {
|
||||
if err := p.Validate(); err != nil {
|
||||
return fmt.Errorf("validation failed: %w", err)
|
||||
}
|
||||
@ -30,14 +23,6 @@ func (p *Plugin) run(ctx context.Context) error {
|
||||
|
||||
// Validate handles the settings validation of the plugin.
|
||||
func (p *Plugin) Validate() error {
|
||||
if len(p.Settings.Playbooks.Value()) == 0 {
|
||||
return ErrPluginPlaybookNotSet
|
||||
}
|
||||
|
||||
if len(p.Settings.Inventories.Value()) == 0 {
|
||||
return ErrPluginInventoryNotSet
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user