All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- New example that show how to run Ansible commands within a Docker Container #116
- Use Golang 1.25
- Use Docker images python:3.14-alpine3.23 and golang:1.25-trixie on the examples and test
- When ansible-playbook fails it return a nil instead of an error #178
- Use errgroup to manage the concurrent operations in the defaultExecutor and results structs.
- Fixed a deadlock in the defaultExecutor that occurred while handling the stdout and stderr output messages. #176
- Use the GNU convention arg=value to create arguments. This fixes an issue detected generating SSH extra arguments.
- Update dependencies
- Use Golang 1.24
- Add the examples
ansibleplaybook-posix-jsonl-stdoutandansibleplaybook-posix-jsonl-stdout-persistenceto demostrate the usage of theAnsiblePosixJsonlStdoutCallbackExecuteexecutor. - Include the
AnsiblePlaybookJSONLEventResultsstruct into thegithub.com/apenella/go-ansible/v2/pkg/execute/result/jsonpackage that represent theansible.posix.jsonlevents. - Include the
JSONLEventStdoutCallbackResultsstruct into thegithub.com/apenella/go-ansible/v2/pkg/execute/result/jsonas aResultsOutputerto handle theansible.posix.jsonlstdout callback method events. - Support the stdout callback plugin
ansible.posix.jsonlby adding a stdout callback executor:AnsiblePosixJsonlStdoutCallbackExecute.
- Bump from golang 1.22 to 1.23
- Bump golang.org/x/crypto from 0.22.0 to 0.31.0
- Bump golang.org/x/net v0.24.0 to v0.36.0
- New example ansibleplaybook-ssh-become-root-with-password/, showcasing how to execute a playbook that requires to become root user and set the user password through the variable ansible_sudo_pass
- The internal package
internal/executable/os/exechas been moved topkg/execute/exec, making it public. Along with this change, theExecstruct has been renamed toOsExec.
- Fixed the String method on the AnsiblePlaybookOptions and AnsibleAdhocOptions structs that do not return the verbose flags correctly.
Version 2.0.0 of go-ansible introduces several disruptive changes. Read the upgrade guide carefully before proceeding with the upgrade.
Note The latest major version of go-ansible, version 2.x, introduced significant and breaking changes. If you are currently using a version prior to 2.x, please refer to the upgrade guide for detailed information on how to migrate to version 2.x.
- The Go module name has been changed from
github.com/apenella/go-ansibletogithub.com/apenella/go-ansible/v2. So, you need to update your import paths to use the new module name. - The relationship between the executor and
AnsiblePlaybookCmd/AnsibleAdhocCmd/AnsibleInvetoryCmdhas undergone important changes.- Inversion of responsibilities: The executor is now responsible for executing external commands, while
AnsiblePlaybookCmd,AnsibleInventoryCmdandAnsibleAdhocCmdhave cut down their responsibilities, primarily focusing on generating the command to be executed. - Method and Attribute Removal: The following methods and attributes have been removed on
AnsiblePlaybookCmd,AnsibleInventoryCmdandAnsibleAdhocCmd:- The
Runmethod. - The
ExecandStdoutCallbackattributes.
- The
- Attributes Renaming: The
Optionsattribute has been renamed toPlaybookOptionsinAnsiblePlaybookCmd,AdhocOptionsinAnsibleAdhocCmdandInventoryOptionsinAnsibleInventoryCmd.
- Inversion of responsibilities: The executor is now responsible for executing external commands, while
- The
Executorinterface has undergone a significant signature change. This change entails the removal of the following argumentsresultsFuncandoptions. The current signature is:Execute(ctx context.Context) error. - The
github.com/apenella/go-ansible/pkg/optionspackage has been removed. After that deletion, the attributes fromAnsibleConnectionOptionsandAnsiblePrivilegeEscalationOptionsattributes have been moved to thePlaybookOptions,AdhocOptionsandInventoryOptionsstructs. - The
github.com/apenella/go-ansible/pkg/stdoutcallbackpackage has been removed. Its responsibilities have been absorbed by two distinc packagesgithub.com/apenella/go-ansible/v2/pkg/execute/result, which manages the output of the commands, andgithub.com/apenella/go-ansible/v2/pkg/execute/stdoutcallbackthat enables the setting of the stdout callback. - The constants
AnsibleForceColorEnvandAnsibleHostKeyCheckingEnvhave been removed from thegithub.com/apenella/go-ansible/pkg/optionspackage. - The functions
AnsibleForceColor,AnsibleAvoidHostKeyCheckingandAnsibleSetEnvhave been removed from thegithub.com/apenella/go-ansible/pkg/optionspackage. Use theExecutorWithAnsibleConfigurationSettingsdecorator instead defined in thegithub.com/apenella/go-ansible/v2/pkg/execute/configurationpackage. - The methods
WithWriteandWithShowdurationhave been removed from theExecutorTimeMeasurementdecorator. Instead, a new method namedDurationhas been introduced for obtaining the duration of the execution. - In the
AnsiblePlaybookJSONResultsPlayTaskHostsItemstruct, the attributesStdoutLinesandStderrLineshave chnage their type from[]stringto[]interface{}.
- Quote properly the attributes
SCPExtraArgs,SFTPExtraArgs,SSHCommonArgs,SSHExtraArgsinAnsibleAdhocOptionsandAnsiblePlaybookOptionsstructs when generating the command to be executed. #140 - When using the JSON Stdout Callback method combined with enabled verbosity in the command, it causes an error during JSON parsing. To resolve this issue, the
DefaultExecutestruct includes theQuietmethod, which removes verbosity from the executed command. #110
AnsibleAdhocExecuteexecutor has been introduced. That executor allows you to create an executor to runansiblecommands using the default settings ofDefaultExecute. This executor is located in thegithub.com/apenella/go-ansible/v2/pkg/execute/adhocpackage.AnsibleInventoryExecuteexecutor has been introduced. That executor allows you to create an executor to runansible-inventorycommands using the default settings ofDefaultExecute. This executor is located in thegithub.com/apenella/go-ansible/v2/pkg/execute/inventorypackage.ansibleplaybook-embed-pythonexample to demonstrate how to usego-ansiblelibrary along with thego-embed-pythonpackage.ansibleplaybook-extravarsexample to show how to configure extra vars when running an Ansible playbook command.ansibleplaybook-sshexample to show how to execute an Ansible playbook using SSH as the connection method.AnsiblePlaybookExecuteexecutor has been introduced. That executor allows you to create an executor to runansible-playbookcommands using the default settings ofDefaultExecute. This executor is located in thegithub.com/apenella/go-ansible/v2/pkg/execute/playbookpackage.Commanderinterface has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/executepackage. This interface defines the criteria for a struct to be compliant in generating execution commands.ErrorEnricherinterface has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/executepackage. This interface defines the criteria for a struct to be compliant in enriching the error message of the command execution.Executablerinterface has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/executepackage. This interface defines the criteria for a struct to be compliant in executing external commands.ExecutorEnvVarSetterinterface ingithub.com/apenella/go-ansible/v2/pkg/execute/configurationdefines the criteria for a struct to be compliant in setting Ansible configuration.ExecutorQuietStdoutCallbackSetterinterface has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/execute/stdoutcallbackpackage. This interface defines the criteria for a struct to be compliant in setting an executor that accepts the stdout callback configuration and that enables theQuietmethod for Ansible executions.ExecutorStdoutCallbackSetterinterface has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/execute/stdoutcallbackpackage. This interface defines the criteria for a struct to be compliant in setting an executor that accepts the stdout callback configuration for Ansible executions.github.com/apenella/go-ansible/v2/internal/executable/os/execpackage has been introduced. This package serves as a wrapper foros.exec.github.com/apenella/go-ansible/v2/pkg/execute/configurationpackage includes theExecutorWithAnsibleConfigurationSettingsstruct, which acts as a decorator that facilitates the configuration of Ansible settings within the executor.github.com/apenella/go-ansible/v2/pkg/execute/result/defaultpackage has been introduced. This package offers the default component for printing execution results. It supersedes theDefaultStdoutCallbackResultsfunction that was previously defined in thegithub.com/apenella/go-ansible/v2/pkg/stdoutcallbackpackage.github.com/apenella/go-ansible/v2/pkg/execute/result/jsonpackage has been introduced. This package offers the component for printing execution results from the JSON stdout callback. It supersedes theJSONStdoutCallbackResultsfunction that was previously defined in thegithub.com/apenella/go-ansible/v2/pkg/stdoutcallbackpackage.github.com/apenella/go-ansible/v2/pkg/execute/stdoutcallback. package has been introduced and offers multiple decorators designed to set the stdout callback for Ansible executions.github.com/apenella/go-ansible/v2/pkg/execute/workflowpackage has been introduced and allows you to define a workflow for executing multiple commands in a sequence.github.com/apenella/go-ansible/v2/pkg/galaxy/collection/installpackage has been introduced. This package allows you to install Ansible collections from the Ansible Galaxy. Along with this package, the exampleworkflowexecute-ansibleplaybook-with-galaxy-install-collectionhas been added to demonstrate how to install an Ansible collection and execute an Ansible playbook in a sequence.github.com/apenella/go-ansible/v2/pkg/galaxy/role/installpackage has been introduced. This package allows you to install Ansible roles from the Ansible Galaxy. Along with this package, the exampleworkflowexecute-ansibleplaybook-with-galaxy-install-rolehas been added to demonstrate how to install an Ansible role and execute an Ansible playbook in a sequence.golangci-linthas been added to the CI/CD pipeline to ensure the code quality.NewAnsibleAdhocCmd,NewAnsibleInventoryCmdandNewAnsiblePlaybookCmdfunctions have been introduced. These functions are responsible for creating theAnsibleAdhocCmd,AnsibleInventoryCmdandAnsiblePlaybookCmdstructs, respectively.Pathattribute has been added to theAnsiblePlaybookJSONResultsPlayTaskHostsItemstruct.ResultsOutputerinterface has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/execute/resultpackage. This interface defines the criteria for a struct to be compliant in printing execution results.- A utility to generate the code for the configuration package has been introduced. This utility is located in the
utils/cmd/configGenerator.go. - The
Quietmethod has been added to theDefaultExecutestruct. This method forces to remove verbosity from the executed command.
DefaultExecuteused theStringmethod from theCommanderto include the command in the error message when the execution fails, instead of using the theStringmethod from theos/exec.Cmdstruct.- In the
AnsiblePlaybookJSONResultsPlayTaskHostsItemstruct, the attributesStdoutLinesandStderrLineshave chnage their type from[]stringto[]interface{}. - The
AnsibleAdhocCmdstruct has been updated to implement theCommanderinterface. - The
AnsibleInventoryCmdstruct has been updated to implement theCommanderinterface. - The
AnsiblePlaybookCmdstruct has been updated to implement theCommanderinterface. - The
AnsiblePlaybookOptionsandAnsibleAdhocOptionsstructs have been updated to include the attributes fromAnsibleConnectionOptionsandAnsiblePrivilegeEscalationOptions. - The
DefaultExecutestruct has been updated to have a new attribute namedExecof typeExecutablerthat is responsible for executing external commands. - The
DefaultExecutestruct has been updated to have a new attribute namedOutputof typeResultsOutputerthat is responsible for printing the execution's output. - The
DefaultExecutestruct has been updated to implement theExecutorinterface. - The
DefaultExecutestruct has been updated to implement theExecutorEnvVarSetterinterface. - The
DefaultExecutestruct has been updated to implement theExecutorStdoutCallbackSetterinterface. - The
Executemethod in theDefaultExecutestruct has been updated to return an error on the deferred function when the command execution fails. - The
Optionsattribute inAnsibleAdhocCmdstruct has been renamed toAdhocOptions. - The
Optionsattribute inAnsibleInventoryCmdstruct has been renamed toInventoryOptions. - The
Optionsattribute inAnsiblePlaybookCmdstruct has been renamed toPlaybookOptions. - The
Readmethod in theReadPasswordFromEnvVarstruct from thegithub.com/apenella/go-ansible/v2/vault/password/envvarspackage has been updated to log a warning message when the environment variable is not set. - The examples has been adapted to use executor as the component to execute Ansible commands.
- The package
github.com/apenella/go-ansible/pkg/stdoutcallback/result/transformerhas been moved togithub.com/apenella/go-ansible/v2/pkg/execute/result/transformer. - Upgrade the Go version from
1.19to1.22.
- Remove from
DefaultExecuteansible-playbook error enrichment. - The
Execattribute has been removed fromAnsiblePlaybookCmdandAdhocPlaybookCmd. - The
github.com/apenella/go-ansible/pkg/optionspackage has been removed. After theAnsibleConnectionOptionsandAnsiblePrivilegeEscalationOptionsstructs are not available anymore. - The
github.com/apenella/go-ansible/pkg/stdoutcallbackpackage has been removed. - The
Runmethod has been removed from theAnsiblePlaybookCmdandAdhocPlaybookCmdstructs. - The
ShowDurationattribute in theDefaultExecutestruct has been removed. - The
StdoutCallbackattribute has been removed fromAnsiblePlaybookCmdandAdhocPlaybookCmd. - The constants
AnsibleForceColorEnvandAnsibleHostKeyCheckingEnvhave been removed from thegithub.com/apenella/go-ansible/pkg/optionspackage. - The functions
AnsibleForceColor,AnsibleAvoidHostKeyCheckingandAnsibleSetEnvhave been removed from thegithub.com/apenella/go-ansible/pkg/optionspackage. Use theExecutorWithAnsibleConfigurationSettingsdecorator instead defined in thegithub.com/apenella/go-ansible/v2/pkg/execute/configurationpackage. - The methods
WithWriteandwithshowdurationhave been removed from theExecutorTimeMeasurementdecorator.
Version 2.0.0 of go-ansible introduces several disruptive changes. Read the upgrade guide carefully before proceeding with the upgrade.
Note The latest major version of go-ansible, version 2.x, introduced significant and breaking changes. If you are currently using a version prior to 2.x, please refer to the upgrade guide for detailed information on how to migrate to version 2.x.
- The Go module name has been changed from
github.com/apenella/go-ansibletogithub.com/apenella/go-ansible/v2. So, you need to update your import paths to use the new module name. - The relationship between the executor and
AnsiblePlaybookCmd/AnsibleAdhocCmd/AnsibleInvetoryCmdhas undergone important changes.- Inversion of responsibilities: The executor is now responsible for executing external commands, while
AnsiblePlaybookCmd,AnsibleInventoryCmdandAnsibleAdhocCmdhave cut down their responsibilities, primarily focusing on generating the command to be executed. - Method and Attribute Removal: The following methods and attributes have been removed on
AnsiblePlaybookCmd,AnsibleInventoryCmdandAnsibleAdhocCmd:- The
Runmethod. - The
ExecandStdoutCallbackattributes.
- The
- Attributes Renaming: The
Optionsattribute has been renamed toPlaybookOptionsinAnsiblePlaybookCmd,AdhocOptionsinAnsibleAdhocCmdandInventoryOptionsinAnsibleInventoryCmd.
- Inversion of responsibilities: The executor is now responsible for executing external commands, while
- The
Executorinterface has undergone a significant signature change. This change entails the removal of the following argumentsresultsFuncandoptions. The current signature is:Execute(ctx context.Context) error. - The
github.com/apenella/go-ansible/pkg/optionspackage has been removed. After that deletion, the attributes fromAnsibleConnectionOptionsandAnsiblePrivilegeEscalationOptionsattributes have been moved to thePlaybookOptions,AdhocOptionsandInventoryOptionsstructs. - The
github.com/apenella/go-ansible/pkg/stdoutcallbackpackage has been removed. Its responsibilities have been absorbed by two distinc packagesgithub.com/apenella/go-ansible/v2/pkg/execute/result, which manages the output of the commands, andgithub.com/apenella/go-ansible/v2/pkg/execute/stdoutcallbackthat enables the setting of the stdout callback. - The constants
AnsibleForceColorEnvandAnsibleHostKeyCheckingEnvhave been removed from thegithub.com/apenella/go-ansible/pkg/optionspackage. - The functions
AnsibleForceColor,AnsibleAvoidHostKeyCheckingandAnsibleSetEnvhave been removed from thegithub.com/apenella/go-ansible/pkg/optionspackage. Use theExecutorWithAnsibleConfigurationSettingsdecorator instead defined in thegithub.com/apenella/go-ansible/v2/pkg/execute/configurationpackage. - The methods
WithWriteandWithShowdurationhave been removed from theExecutorTimeMeasurementdecorator. Instead, a new method namedDurationhas been introduced for obtaining the duration of the execution.
- Quote properly the attributes
SCPExtraArgs,SFTPExtraArgs,SSHCommonArgs,SSHExtraArgsinAnsibleAdhocOptionsandAnsiblePlaybookOptionsstructs when generating the command to be executed. #140
AnsibleAdhocExecuteexecutor has been introduced. That executor allows you to create an executor to runansiblecommands using the default settings ofDefaultExecute. This executor is located in thegithub.com/apenella/go-ansible/v2/pkg/execute/adhocpackage.AnsibleInventoryExecuteexecutor has been introduced. That executor allows you to create an executor to runansible-inventorycommands using the default settings ofDefaultExecute. This executor is located in thegithub.com/apenella/go-ansible/v2/pkg/execute/inventorypackage.ansibleplaybook-extravarsexample to show how to configure extra vars when running an Ansible playbook command.ansibleplaybook-sshexample to show how to execute an Ansible playbook using SSH as the connection method.AnsiblePlaybookExecuteexecutor has been introduced. That executor allows you to create an executor to runansible-playbookcommands using the default settings ofDefaultExecute. This executor is located in thegithub.com/apenella/go-ansible/v2/pkg/execute/playbookpackage.Commanderinterface has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/executepackage. This interface defines the criteria for a struct to be compliant in generating execution commands.Executablerinterface has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/executepackage. This interface defines the criteria for a struct to be compliant in executing external commands.ExecutorEnvVarSetterinterface ingithub.com/apenella/go-ansible/v2/pkg/execute/configurationdefines the criteria for a struct to be compliant in setting Ansible configuration.ExecutorStdoutCallbackSetterinterface has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/execute/stdoutcallbackpackage. This interface defines the criteria for a struct to be compliant in setting an executor that accepts the stdout callback configuration for Ansible executions.github.com/apenella/go-ansible/v2/internal/executable/os/execpackage has been introduced. This package serves as a wrapper foros.exec.github.com/apenella/go-ansible/v2/pkg/execute/configurationpackage includes theExecutorWithAnsibleConfigurationSettingsstruct, which acts as a decorator that facilitates the configuration of Ansible settings within the executor.github.com/apenella/go-ansible/v2/pkg/execute/result/defaultpackage has been introduced. This package offers the default component for printing execution results. It supersedes theDefaultStdoutCallbackResultsfunction that was previously defined in thegithub.com/apenella/go-ansible/v2/pkg/stdoutcallbackpackage.github.com/apenella/go-ansible/v2/pkg/execute/result/jsonpackage has been introduced. This package offers the component for printing execution results from the JSON stdout callback. It supersedes theJSONStdoutCallbackResultsfunction that was previously defined in thegithub.com/apenella/go-ansible/v2/pkg/stdoutcallbackpackage.github.com/apenella/go-ansible/v2/pkg/execute/stdoutcallback. package has been introduced and offers multiple decorators designed to set the stdout callback for Ansible executions.github.com/apenella/go-ansible/v2/pkg/execute/workflowpackage has been introduced and allows you to define a workflow for executing multiple commands in a sequence.github.com/apenella/go-ansible/v2/pkg/galaxy/collection/installpackage has been introduced. This package allows you to install Ansible collections from the Ansible Galaxy. Along with this package, the exampleworkflowexecute-ansibleplaybook-with-galaxy-install-collectionhas been added to demonstrate how to install an Ansible collection and execute an Ansible playbook in a sequence.github.com/apenella/go-ansible/v2/pkg/galaxy/role/installpackage has been introduced. This package allows you to install Ansible roles from the Ansible Galaxy. Along with this package, the exampleworkflowexecute-ansibleplaybook-with-galaxy-install-rolehas been added to demonstrate how to install an Ansible role and execute an Ansible playbook in a sequence.NewAnsibleAdhocCmd,NewAnsibleInventoryCmdandNewAnsiblePlaybookCmdfunctions have been introduced. These functions are responsible for creating theAnsibleAdhocCmd,AnsibleInventoryCmdandAnsiblePlaybookCmdstructs, respectively.ResultsOutputerinterface has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/execute/resultpackage. This interface defines the criteria for a struct to be compliant in printing execution results.- A utility to generate the code for the configuration package has been introduced. This utility is located in the
utils/cmd/configGenerator.go.
- The
AnsibleAdhocCmdstruct has been updated to implement theCommanderinterface. - The
AnsibleInventoryCmdstruct has been updated to implement theCommanderinterface. - The
AnsiblePlaybookCmdstruct has been updated to implement theCommanderinterface. - The
AnsiblePlaybookOptionsandAnsibleAdhocOptionsstructs have been updated to include the attributes fromAnsibleConnectionOptionsandAnsiblePrivilegeEscalationOptions. - The
DefaultExecutestruct has been updated to have a new attribute namedExecof typeExecutablerthat is responsible for executing external commands. - The
DefaultExecutestruct has been updated to have a new attribute namedOutputof typeResultsOutputerthat is responsible for printing the execution's output. - The
DefaultExecutestruct has been updated to implement theExecutorinterface. - The
DefaultExecutestruct has been updated to implement theExecutorEnvVarSetterinterface. - The
DefaultExecutestruct has been updated to implement theExecutorStdoutCallbackSetterinterface. - The
Optionsattribute inAnsibleAdhocCmdstruct has been renamed toAdhocOptions. - The
Optionsattribute inAnsibleInventoryCmdstruct has been renamed toInventoryOptions. - The
Optionsattribute inAnsiblePlaybookCmdstruct has been renamed toPlaybookOptions. - The examples has been adapted to use executor as the component to execute Ansible commands.
- The package
github.com/apenella/go-ansible/pkg/stdoutcallback/result/transformerhas been moved togithub.com/apenella/go-ansible/v2/pkg/execute/result/transformer.
- The
Execattribute has been removed fromAnsiblePlaybookCmdandAdhocPlaybookCmd. - The
github.com/apenella/go-ansible/pkg/optionspackage has been removed. After theAnsibleConnectionOptionsandAnsiblePrivilegeEscalationOptionsstructs are not available anymore. - The
github.com/apenella/go-ansible/pkg/stdoutcallbackpackage has been removed. - The
Runmethod has been removed from theAnsiblePlaybookCmdandAdhocPlaybookCmdstructs. - The
ShowDurationattribute in theDefaultExecutestruct has been removed. - The
StdoutCallbackattribute has been removed fromAnsiblePlaybookCmdandAdhocPlaybookCmd. - The constants
AnsibleForceColorEnvandAnsibleHostKeyCheckingEnvhave been removed from thegithub.com/apenella/go-ansible/pkg/optionspackage. - The functions
AnsibleForceColor,AnsibleAvoidHostKeyCheckingandAnsibleSetEnvhave been removed from thegithub.com/apenella/go-ansible/pkg/optionspackage. Use theExecutorWithAnsibleConfigurationSettingsdecorator instead defined in thegithub.com/apenella/go-ansible/v2/pkg/execute/configurationpackage. - The methods
WithWriteandwithshowdurationhave been removed from theExecutorTimeMeasurementdecorator.
Version 2.0.0 of go-ansible introduces several disruptive changes. Read the upgrade guide carefully before proceeding with the upgrade.
Note The latest major version of go-ansible, version 2.x, introduced significant and breaking changes. If you are currently using a version prior to 2.x, please refer to the upgrade guide for detailed information on how to migrate to version 2.x.
- The Go module name has been changed from
github.com/apenella/go-ansibletogithub.com/apenella/go-ansible/v2. So, you need to update your import paths to use the new module name. - The relationship between the executor and
AnsiblePlaybookCmd/AnsibleAdhocCmd/AnsibleInvetoryCmdhas undergone important changes.- Inversion of responsabilities: The executor is now responsible for executing external commands, while
AnsiblePlaybookCmd,AnsibleInventoryCmdandAnsibleAdhocCmdhave cut down their responsibilities, primarily focusing on generating the command to be executed. - Method and Attribute Removal: The following methods and attributes have been removed on
AnsiblePlaybookCmd,AnsibleInventoryCmdandAnsibleAdhocCmd:- The
Runmethod. - The
ExecandStdoutCallbackattributes.
- The
- Attributes Renaming: The
Optionsattribute has been renamed toPlaybookOptionsinAnsiblePlaybookCmd,AdhocOptionsinAnsibleAdhocCmdandInventoryOptionsinAnsibleInventoryCmd.
- Inversion of responsabilities: The executor is now responsible for executing external commands, while
- The
Executorinterface has undergone a significant signature change. This change entails the removal of the following argumentsresultsFuncandoptions. The current signature is:Execute(ctx context.Context) error. - The
github.com/apenella/go-ansible/pkg/optionspackage has been removed. After that deletion, the attributes fromAnsibleConnectionOptionsandAnsiblePrivilegeEscalationOptionsattributes have been moved to thePlaybookOptions,AdhocOptionsandInventoryOptionsstructs. - The
github.com/apenella/go-ansible/pkg/stdoutcallbackpackage has been removed. Its responsibilities have been absorbed by two distinc packagesgithub.com/apenella/go-ansible/v2/pkg/execute/result, which manages the output of the commands, andgithub.com/apenella/go-ansible/v2/pkg/execute/stdoutcallbackthat enables the setting of the stdout callback. - The constants
AnsibleForceColorEnvandAnsibleHostKeyCheckingEnvhave been removed from thegithub.com/apenella/go-ansible/pkg/optionspackage. - The functions
AnsibleForceColor,AnsibleAvoidHostKeyCheckingandAnsibleSetEnvhave been removed from thegithub.com/apenella/go-ansible/pkg/optionspackage. Use theExecutorWithAnsibleConfigurationSettingsdecorator instead defined in thegithub.com/apenella/go-ansible/v2/pkg/execute/configurationpackage. - The methods
WithWriteandWithShowdurationhave been removed from theExecutorTimeMeasurementdecorator. Instead, a new method namedDurationhas been introduced for obtaining the duration of the execution.
- A new executor
AnsibleAdhocExecutehas been introduced. That executor allows you to create an executor to runansiblecommands using the default settings ofDefaultExecute. This executor is located in thegithub.com/apenella/go-ansible/v2/pkg/execute/adhocpackage. - A new executor
AnsibleInventoryExecutehas been introduced. That executor allows you to create an executor to runansible-inventorycommands using the default settings ofDefaultExecute. This executor is located in thegithub.com/apenella/go-ansible/v2/pkg/execute/inventorypackage. - A new executor
AnsiblePlaybookExecutehas been introduced. That executor allows you to create an executor to runansible-playbookcommands using the default settings ofDefaultExecute. This executor is located in thegithub.com/apenella/go-ansible/v2/pkg/execute/playbookpackage. - A new interface
Commanderhas been introduced in thegithub.com/apenella/go-ansible/v2/pkg/executepackage. This interface defines the criteria for a struct to be compliant in generating execution commands. - A new interface
Executablerhas been introduced in thegithub.com/apenella/go-ansible/v2/pkg/executepackage. This interface defines the criteria for a struct to be compliant in executing external commands. - A new interface
ExecutorEnvVarSetteringithub.com/apenella/go-ansible/v2/pkg/execute/configurationthat defines the criteria for a struct to be compliant in setting Ansible configuration. - A new interface
ExecutorStdoutCallbackSetterhas been introduced in thegithub.com/apenella/go-ansible/v2/pkg/execute/stdoutcallbackpackage. This interface defines the criteria for a struct to be compliant in setting an executor that accepts the stdout callback configuration for Ansible executions. - A new interface named
ResultsOutputerhas been introduced in thegithub.com/apenella/go-ansible/v2/pkg/execute/resultpacakge. This interface defines the criteria for a struct to be compliant in printing execution results. - A new package
github.com/apenella/go-ansible/v2/internal/executable/os/exechas been introduced. This package serves as a wrapper foros.exec. - A new package
github.com/apenella/go-ansible/v2/pkg/execute/configurationthat incldues theExecutorWithAnsibleConfigurationSettingsstruct, which acts as a decorator that facilitates the configuration of Ansible settings within the executor. - A new package
github.com/apenella/go-ansible/v2/pkg/execute/result/defaulthas been introduced. This package offers the default component for printing execution results. It supersedes theDefaultStdoutCallbackResultsfunction that was previously defined in thegithub.com/apenella/go-ansible/v2/pkg/stdoutcallbackpackage. - A new package
github.com/apenella/go-ansible/v2/pkg/execute/result/jsonhas been introduced. This package offers the component for printing execution results from the JSON stdout callback. It supersedes theJSONStdoutCallbackResultsfunction that was previously defined in thegithub.com/apenella/go-ansible/v2/pkg/stdoutcallbackpackage. - A new package
github.com/apenella/go-ansible/v2/pkg/execute/stdoutcallback. This package offers multiple decorators designed to set the stdout callback for Ansible executions. - A new package
github.com/apenella/go-ansible/v2/pkg/execute/workflowhas been introduced. This package allows you to define a workflow for executing multiple commands in a sequence. - An utility to generate the code for the configuration package has been introduced. This utility is located in the
utils/cmd/configGenerator.go.
- The
AnsibleAdhocCmdstruct has been updated to implement theCommanderinterface. - The
AnsibleInventoryCmdstruct has been updated to implement theCommanderinterface. - The
AnsiblePlaybookCmdstruct has been updated to implement theCommanderinterface. - The
AnsiblePlaybookOptionsandAnsibleAdhocOptionsstructs have been updated to include the attributes fromAnsibleConnectionOptionsandAnsiblePrivilegeEscalationOptions. - The
DefaultExecutestruct has been updated to have a new attribute namedExecof typeExecutablerthat is responsible for executing external commands. - The
DefaultExecutestruct has been updated to have a new attribute namedOutputof typeResultsOutputerthat is responsible for printing the execution's output. - The
DefaultExecutestruct has been updated to implement theExecutorinterface. - The
DefaultExecutestruct has been updated to implement theExecutorEnvVarSetterinterface. - The
DefaultExecutestruct has been updated to implement theExecutorStdoutCallbackSetterinterface. - The
Optionsattribute inAnsibleAdhocCmdstruct has been renamed toAdhocOptions. - The
Optionsattribute inAnsibleInventoryCmdstruct has been renamed toInventoryOptions. - The
Optionsattribute inAnsiblePlaybookCmdstruct has been renamed toPlaybookOptions. - The examples has been adapted to use executor as the component to execute Ansible commands.
- The package
github.com/apenella/go-ansible/pkg/stdoutcallback/result/transformerhas been moved togithub.com/apenella/go-ansible/v2/pkg/execute/result/transformer.
- The
Execattribute has been removed fromAnsiblePlaybookCmdandAdhocPlaybookCmd. - The
github.com/apenella/go-ansible/pkg/optionspackage has been removed. After theAnsibleConnectionOptionsandAnsiblePrivilegeEscalationOptionsstructs are not available anymore. - The
github.com/apenella/go-ansible/pkg/stdoutcallbackpackage has been removed. - The
Runmethod has been removed from theAnsiblePlaybookCmdandAdhocPlaybookCmdstructs. - The
ShowDurationattribute in theDefaultExecutestruct has been removed. - The
StdoutCallbackattribute has been removed fromAnsiblePlaybookCmdandAdhocPlaybookCmd. - The constants
AnsibleForceColorEnvandAnsibleHostKeyCheckingEnvhave been removed from thegithub.com/apenella/go-ansible/pkg/optionspackage. - The functions
AnsibleForceColor,AnsibleAvoidHostKeyCheckingandAnsibleSetEnvhave been removed from thegithub.com/apenella/go-ansible/pkg/optionspackage. Use theExecutorWithAnsibleConfigurationSettingsdecorator instead defined in thegithub.com/apenella/go-ansible/v2/pkg/execute/configurationpackage. - The methods
WithWriteandwithshowdurationhave been removed from theExecutorTimeMeasurementdecorator.
- New feature to execute the Ansible inventory command. #132
- Bump golang.org/x/crypto from 0.8.0 to 0.17.0
- In
AnsibleConnectionOptions, add quotes to ssh, sftp, and scp arguments when generating the command
- Introducing the
github.com/apenella/go-ansible/pkg/vaultpackage, which enables variable encryption. - Added the
github.com/apenella/go-ansible/pkg/vault/password/textpackage for reading encryption passwords as plain text. - Introduced the
github.com/apenella/go-ansible/pkg/vault/password/resolvepackage, which helps in resolving an encryption password. - Added the
github.com/apenella/go-ansible/pkg/vault/password/filepackage for reading encryption passwords from a file. - Introduced the
github.com/apenella/go-ansible/pkg/vault/password/envvarspackage, allowing the reading of encryption passwords from an environment variable. - Added the
github.com/apenella/go-ansible/pkg/vault/encryptpackage, which provides the ability to encrypt strings using thehttps://github.com/sosedoff/ansible-vault-gopackage. - Included an example using
embed.FS.
- On
AnsiblePlaybookJSONResultsPlayTaskHostsItem, attributesStdoutandStderrhas been changed fromstringtointerface{}#109
- On
AnsiblePlaybookJSONResultsPlayTaskHostsItem, fixUnreachableattribute type tobool#103
- Quote
Argsvalue onAnsibleAdhocCmd'sStringmethod #91 - On default executor, set all parent process environment variables to
cmd.Envwhen a custom env vars is defined #94 - Fix parsing of long lines in output #101
ExecutorTimeMeasurementis a decorator defined ongithub.com/apenella/go-ansible/pkg/execute, that measures the duration of an execution, it receives anExecutorwhich is measured the execution time #92- Add
unreachablestate on task play results structAnsiblePlaybookJSONResultsPlayTaskHostsItem#100
MockExecuteusesgithub.com/stretchr/testify/mock#92- Examples' name are prefixed by
ansibleplaybookoransibleadhoc
DefaultExecutordoes not measures the execution duration anymore. Instead of it,ExecutorTimeMeasurementmust be used #92
- New function
WithEnvVarongithub.com/apenella/go-ansible/pkg/executepackage that adds environment variables toDefaultExecutorcommand.
- Include missing attributes on
AnsiblePlaybookJSONResultsPlayTaskHostsItem. Those attributes arecmd,skipped,skip_reason,failed, andfailed_when_result
- New function
ParseJSONResultsStreamon"github.com/apenella/go-ansible/pkg/stdoutcallback/results"that allow to parse ansible stdout json output as a stream. That method supports to parse json output when multiple playbooks are executed.
- New attribute
ExtraVarsFileonAnsiblePlaybookOptionsthat allows to use YAML/JSON files to define extra-vars - New attribute
ExtraVarsFileonAnsibleAdhocOptionsthat allows to use YAML/JSON files to define extra-vars
- Include
stdoutandstdout_linestoAnsiblePlaybookJSONResultsPlayTaskHostsItem - Include
stderrandstderr_linestoAnsiblePlaybookJSONResultsPlayTaskHostsItem
- update dependency package github.com/apenella/go-common-utils/error
- update dependency package github.com/apenella/go-common-utils/data
- Fixed(#57) typos and language mistakes on Readme file
- Fixed(#64) update
Msgtype onAnsiblePlaybookJSONResultsPlayTaskHostsItemfromstringtointerface{}
- support for stdin on
DefaultExecuteExecute method
- Included
ansible-playbookversion2.10.6options onAnsiblePlaybookOptions - Included
github.com/apenella/go-ansible/pkg/adhocpackage to interact toansibleadhoc command - New function type
ExecuteOptionsto provide options to executor instances - New
DefaultExecuteconstructorNewDefaultExecutethat accepts a list ofExecuteOptions - New component to customize ansible output lines. That component is named transformer
- Include a bunch of transformers that can be already used:
- Prepend(string): Prepends and string to the output line
- Append(string): Appends and string to the output line
- LogFormat(string): Prepends date time to the output line
- IgnoreMessage([]string): Ignores the output lines based on input strings
- New private method
outputonresultspackage to manage how to write the output lines and that can be used by anyStdoutCallbackResultsFunc
- BREAKING CHANGE:
ansiblerhas been restructured and splitted to multiple packages:- Type
AnsiblePlaybookConnectionOptionsis renamed toAnsibleConnectionOptionsand placed togithub.com/apenella/go-ansible/pkg/options - Type
AnsiblePlaybookPrivilegeEscalationOptionsis renamed toAnsiblePrivilegeEscalationOptionsand placed togithub.com/apenella/go-ansible/pkg/options - All constants regarding connection options and privileged escalations options has been placed to
github.com/apenella/go-ansible/pkg/options AnsiblePlaybookCmdandAnsiblePlaybookOptionshas been placed togithub.com/apenella/go-ansible/pkg/playbook- All constants regarding ansible-playbook command interaction has been placed to
github.com/apenella/go-ansible/pkg/playbook
- Type
- BREAKING CHANGE:
Playbookattribute onAnsiblePlaybookCmdhas been replaced toPlaybooksattribut which accept multiple playbooks to be run - BREAKING CHANGE:
Executorinterface has been moved fromansiblerpackage togithub.com/apenella/go-ansible/pkg/executepackage - BREAKING CHANGE:
Executorinterface is changed toExecute(ctx context.Context, command []string, resultsFunc stdoutcallback.StdoutCallbackResultsFunc, options ...ExecuteOptions) error - BREAKING CHANGE:
DefaultExecutehas been updated to use options pattern design, and includes a bunch ofWithXXXmethods to set its attributes - BREAKING CHANGE:
StdoutCallbackResultsFuncsignature has been updated tofunc(context.Context, io.Reader, io.Writer, ...results.TransformerFunc) error. Prefix argument has been removed and a list of transformers could be passed to the function DefaultStdoutCallbackResultsandJSONStdoutCallbackResultsprepares default transformers for default output an callsoutput, instead of managing the output by its own
- BREAKING CHANGE: Remove
ExecPrefixfromAnsiblePlaybookCmd - BREAKING CHANGE: Remove
CmdRunDirfromAnsiblePlaybookCmd - BREAKING CHANGE: Remove
WriterfromAnsiblePlaybookCmd - BREAKING CHANGE: Remove
ResultsFuncfromDefaultExecute - BREAKING CHANGE: Remove
PrefixfromDefaultExecute. Prefix is not manatory any more and could be added using thePrependtransformer. skipLinemethod has been removed. Replaced byIgnoreMessagetransformer
- Include attribute CmdRunDir on AnsiblePlaybookCmd which defines the playbook run directory
- Include attribute CmdRunDir on DefaultExecutor
- fix to do not use a multireader for stdout and stderr on DefaultExecutor
- Add Binary attribute to AnsiblePlaybookCmd
- Add VaultPasswordFile to AnsiblePlaybookOptions
- On error, write to output writer either stdout and stderr
- Quote extravars when return command as string
- New method CheckStats on results package that validates AnsiblePlaybookJSONResults stats
- JSONStdoutCallbackResults on results package does not manipulates ansible JSON output, writes output as is into a writer
- JSONParser on results package has changed its signature to JSONParse(data []byte) (*AnsiblePlaybookJSONResults, error)
- simple-ansibleplaybook-json example has been modified to use a custom executor to manipulate the JSON output.
- Use github.com/apenella/go-common-utils/error to manage errors
- #12: Fix the concurrency issue in the defaultExecute.go
- Changelog based on Keep a Changelog
- New package to manage
ansible-playbookoutput - Manage Json stdout callback results
- DefaultExecutor includes an error managemnt depending on
ansible-playbookexit code - Use go mod to manage dependencies
- start using go mod as dependencies manager
- fix bug ansible always showing error " error: unrecognized arguments" when use private key
- Include privilege escalation options
- AnsiblePlaybookCmd has a Write attribute, which must be defined by user.
- Use package github.com/apenella/go-common-utils
- Change package name to ansibler