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",
|
Name: "inventory",
|
||||||
Usage: "path to inventory file",
|
Usage: "path to inventory file",
|
||||||
EnvVars: []string{"PLUGIN_INVENTORY", "PLUGIN_INVENTORIES"},
|
EnvVars: []string{"PLUGIN_INVENTORY", "PLUGIN_INVENTORIES"},
|
||||||
|
Required: true,
|
||||||
Destination: &settings.Inventories,
|
Destination: &settings.Inventories,
|
||||||
Category: category,
|
Category: category,
|
||||||
},
|
},
|
||||||
@ -35,6 +36,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
|
|||||||
Name: "playbook",
|
Name: "playbook",
|
||||||
Usage: "list of playbooks to apply",
|
Usage: "list of playbooks to apply",
|
||||||
EnvVars: []string{"PLUGIN_PLAYBOOK", "PLUGIN_PLAYBOOKS"},
|
EnvVars: []string{"PLUGIN_PLAYBOOK", "PLUGIN_PLAYBOOKS"},
|
||||||
|
Required: true,
|
||||||
Destination: &settings.Playbooks,
|
Destination: &settings.Playbooks,
|
||||||
Category: category,
|
Category: category,
|
||||||
},
|
},
|
||||||
|
@ -76,7 +76,7 @@ properties:
|
|||||||
description: |
|
description: |
|
||||||
Path to inventory file.
|
Path to inventory file.
|
||||||
type: list
|
type: list
|
||||||
required: false
|
required: true
|
||||||
|
|
||||||
- name: limit
|
- name: limit
|
||||||
description: |
|
description: |
|
||||||
@ -115,7 +115,7 @@ properties:
|
|||||||
description: |
|
description: |
|
||||||
List of playbooks to apply.
|
List of playbooks to apply.
|
||||||
type: list
|
type: list
|
||||||
required: false
|
required: true
|
||||||
|
|
||||||
- name: private_key
|
- name: private_key
|
||||||
description: |
|
description: |
|
||||||
|
@ -18,10 +18,10 @@ const (
|
|||||||
ansibleFolder = "/etc/ansible"
|
ansibleFolder = "/etc/ansible"
|
||||||
ansibleConfig = "/etc/ansible/ansible.cfg"
|
ansibleConfig = "/etc/ansible/ansible.cfg"
|
||||||
|
|
||||||
pipBin = "/usr/bin/pip"
|
pipBin = "/usr/local/bin/pip"
|
||||||
ansibleBin = "/usr/bin/ansible"
|
ansibleBin = "/usr/local/bin/ansible"
|
||||||
ansibleGalaxyBin = "/usr/bin/ansible-galaxy"
|
ansibleGalaxyBin = "/usr/local/bin/ansible-galaxy"
|
||||||
ansiblePlaybookBin = "/usr/bin/ansible-playbook"
|
ansiblePlaybookBin = "/usr/local/bin/ansible-playbook"
|
||||||
|
|
||||||
strictFilePerm = 0o600
|
strictFilePerm = 0o600
|
||||||
)
|
)
|
||||||
|
@ -2,7 +2,6 @@ package plugin
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
@ -10,13 +9,7 @@ import (
|
|||||||
"golang.org/x/sys/execabs"
|
"golang.org/x/sys/execabs"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
func (p *Plugin) run(_ context.Context) error {
|
||||||
ErrPluginPlaybookNotSet = errors.New("playbook is required")
|
|
||||||
ErrPluginInventoryNotSet = errors.New("inventory is required")
|
|
||||||
)
|
|
||||||
|
|
||||||
//nolint:revive
|
|
||||||
func (p *Plugin) run(ctx context.Context) error {
|
|
||||||
if err := p.Validate(); err != nil {
|
if err := p.Validate(); err != nil {
|
||||||
return fmt.Errorf("validation failed: %w", err)
|
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.
|
// Validate handles the settings validation of the plugin.
|
||||||
func (p *Plugin) Validate() error {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user