Documentation ¶
Index ¶
Constants ¶
const ( // DefaultAnsibleAdhocBinary is the default value for ansible binary file to run adhoc modules DefaultAnsibleAdhocBinary = "ansible" // ArgsFlag module arguments ArgsFlag = "--args" // AskVaultPasswordFlag ask for vault password AskVaultPasswordFlag = "--ask-vault-password" // BackgroundFlag un asynchronously, failing after X seconds (default=N/A) BackgroundFlag = "--background" // CheckFlag don't make any changes; instead, try to predict some of the changes that may occur CheckFlag = "--check" // DiffFlag when changing (small) files and templates, show the differences in those files; works great with --check DiffFlag = "--diff" // ExtraVarsFlag is the extra variables flag for ansible-playbook ExtraVarsFlag = "--extra-vars" // ForksFlag specify number of parallel processes to use (default=50) ForksFlag = "--forks" // InventoryFlag is the inventory flag for ansible-playbook InventoryFlag = "--inventory" // LimitFlag is the limit flag for ansible-playbook LimitFlag = "--limit" // ListHostsFlag is the list hosts flag for ansible-playbook ListHostsFlag = "--list-hosts" // ModuleNameFlag module name to execute (default=command) ModuleNameFlag = "--module-name" // ModulePathFlag repend colon-separated path(s) to module library (default=~/.ansible/plugins/modules:/usr/share/ansible/plugins/modules) ModulePathFlag = "--module-path" // OneLineFlag condense output OneLineFlag = "--one-line" // PlaybookDirFlag since this tool does not use playbooks, use this as a substitute playbook directory.This sets the relative path for many features including roles/ group_vars/ etc. PlaybookDirFlag = "--playbook-dir" // PollFlag set the poll interval if using -B (default=15) PollFlag = "--poll" // SyntaxCheckFlag is the syntax check flag for ansible-playbook SyntaxCheckFlag = "--syntax-check" // TreeFlag log output to this directory TreeFlag = "--tree" // VaultIDFlag the vault identity to use VaultIDFlag = "--vault-id" // VaultPasswordFileFlag is the vault password file flag for ansible-playbook VaultPasswordFileFlag = "--vault-password-file" // VersionFlag show program's version number, config file location, configured module search path, module location, executable location and exit VersionFlag = "--version" // VerboseFlag verbose mode enabled to connection debugging VerboseFlag = "-vvvv" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnsibleAdhocCmd ¶
type AnsibleAdhocCmd struct { // Ansible binary file Binary string // Exec is the executor item Exec execute.Executor // Pattern is the ansible's host pattern Pattern string // Options are the ansible's playbook options Options *AnsibleAdhocOptions // ConnectionOptions are the ansible's playbook specific options for connection ConnectionOptions *options.AnsibleConnectionOptions // PrivilegeEscalationOptions are the ansible's playbook privilage escalation options PrivilegeEscalationOptions *options.AnsiblePrivilegeEscalationOptions // StdoutCallback defines which is the stdout callback method. By default is used 'default' method. Supported stdout method by go-ansible are: debug, default, dense, json, minimal, null, oneline, stderr, timer, yaml StdoutCallback string }
AnsibleAdhocCmd object is the main object which defines the `ansible` adhoc command and how to execute it.
func (*AnsibleAdhocCmd) Command ¶
func (a *AnsibleAdhocCmd) Command() ([]string, error)
Command generate the ansible command which will be executed
func (*AnsibleAdhocCmd) Run ¶
func (a *AnsibleAdhocCmd) Run(ctx context.Context) error
Run method runs the ansible-playbook
func (*AnsibleAdhocCmd) String ¶
func (a *AnsibleAdhocCmd) String() string
String returns AnsibleAdhocCmd as string
type AnsibleAdhocOptions ¶
type AnsibleAdhocOptions struct { // Args module arguments Args string // AskVaultPassword ask for vault password AskVaultPassword bool // Background un asynchronously, failing after X seconds (default=N/A) Background int // Check don't make any changes; instead, try to predict some of the changes that may occur Check bool // Diff when changing (small) files and templates, show the differences in those files; works great with --check Diff bool // ExtraVars is a map of extra variables used on ansible-playbook execution ExtraVars map[string]interface{} // ExtraVarsFile is a list of files used to load extra-vars ExtraVarsFile []string // Forks specify number of parallel processes to use (default=50) Forks string // Inventory specify inventory host path Inventory string // Limit is selected hosts additional pattern Limit string // ListHosts outputs a list of matching hosts ListHosts bool // ModulePath repend colon-separated path(s) to module library (default=~/.ansible/plugins/modules:/usr/share/ansible/plugins/modules) ModulePath string // ModuleName module name to execute (default=command) ModuleName string // OneLine condense output OneLine bool // PlaybookDir since this tool does not use playbooks, use this as a substitute playbook directory.This sets the relative path for many features including roles/ group_vars/ etc. PlaybookDir string // Poll set the poll interval if using -B (default=15) Poll int // SyntaxCheck is the syntax check flag for ansible-playbook SyntaxCheck bool // Tree log output to this directory Tree string // VaultID the vault identity to use VaultID string // VaultPasswordFile path to the file holding vault decryption key VaultPasswordFile string // Verbose verbose mode enabled to connection debugging Verbose bool // Version show program's version number, config file location, configured module search path, module location, executable location and exit Version bool }
AnsibleAdhocOptions object has those parameters described on `Options` section within ansible-playbook's man page, and which defines which should be the ansible-playbook execution behavior.
func (*AnsibleAdhocOptions) AddExtraVar ¶
func (o *AnsibleAdhocOptions) AddExtraVar(name string, value interface{}) error
AddExtraVar registers a new extra variable
func (*AnsibleAdhocOptions) AddExtraVarsFile ¶
func (o *AnsibleAdhocOptions) AddExtraVarsFile(file string) error
AddExtraVarsFile adds an extra-vars file on ansible-playbook options item
func (*AnsibleAdhocOptions) GenerateAnsibleAdhocOptions ¶
func (o *AnsibleAdhocOptions) GenerateAnsibleAdhocOptions() ([]string, error)
GenerateCommandAdhocOptions return a list of command options flags to be used on ansible execution
func (*AnsibleAdhocOptions) String ¶
func (o *AnsibleAdhocOptions) String() string
GenerateCommandCommonOptions return a list of command options flags to be used on ansible execution
type AnsibleAdhocOptionsFunc ¶
type AnsibleAdhocOptionsFunc func(*AnsibleAdhocCmd)
AnsibleAdhocOptionsFunc is a function to set executor options