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.
- The internal package
internal/executable/os/exec
has been moved topkg/execute/exec
, making it public.
- 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-ansible
togithub.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
/AnsibleInvetoryCmd
has undergone important changes.- Inversion of responsibilities: The executor is now responsible for executing external commands, while
AnsiblePlaybookCmd
,AnsibleInventoryCmd
andAnsibleAdhocCmd
have 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
,AnsibleInventoryCmd
andAnsibleAdhocCmd
:- The
Run
method. - The
Exec
andStdoutCallback
attributes.
- The
- Attributes Renaming: The
Options
attribute has been renamed toPlaybookOptions
inAnsiblePlaybookCmd
,AdhocOptions
inAnsibleAdhocCmd
andInventoryOptions
inAnsibleInventoryCmd
.
- Inversion of responsibilities: The executor is now responsible for executing external commands, while
- The
Executor
interface has undergone a significant signature change. This change entails the removal of the following argumentsresultsFunc
andoptions
. The current signature is:Execute(ctx context.Context) error
. - The
github.com/apenella/go-ansible/pkg/options
package has been removed. After that deletion, the attributes fromAnsibleConnectionOptions
andAnsiblePrivilegeEscalationOptions
attributes have been moved to thePlaybookOptions
,AdhocOptions
andInventoryOptions
structs. - The
github.com/apenella/go-ansible/pkg/stdoutcallback
package 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/stdoutcallback
that enables the setting of the stdout callback. - The constants
AnsibleForceColorEnv
andAnsibleHostKeyCheckingEnv
have been removed from thegithub.com/apenella/go-ansible/pkg/options
package. - The functions
AnsibleForceColor
,AnsibleAvoidHostKeyChecking
andAnsibleSetEnv
have been removed from thegithub.com/apenella/go-ansible/pkg/options
package. Use theExecutorWithAnsibleConfigurationSettings
decorator instead defined in thegithub.com/apenella/go-ansible/v2/pkg/execute/configuration
package. - The methods
WithWrite
andWithShowduration
have been removed from theExecutorTimeMeasurement
decorator. Instead, a new method namedDuration
has been introduced for obtaining the duration of the execution. - In the
AnsiblePlaybookJSONResultsPlayTaskHostsItem
struct, the attributesStdoutLines
andStderrLines
have chnage their type from[]string
to[]interface{}
.
- Quote properly the attributes
SCPExtraArgs
,SFTPExtraArgs
,SSHCommonArgs
,SSHExtraArgs
inAnsibleAdhocOptions
andAnsiblePlaybookOptions
structs 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
DefaultExecute
struct includes theQuiet
method, which removes verbosity from the executed command. #110
AnsibleAdhocExecute
executor has been introduced. That executor allows you to create an executor to runansible
commands using the default settings ofDefaultExecute
. This executor is located in thegithub.com/apenella/go-ansible/v2/pkg/execute/adhoc
package.AnsibleInventoryExecute
executor has been introduced. That executor allows you to create an executor to runansible-inventory
commands using the default settings ofDefaultExecute
. This executor is located in thegithub.com/apenella/go-ansible/v2/pkg/execute/inventory
package.ansibleplaybook-embed-python
example to demonstrate how to usego-ansible
library along with thego-embed-python
package.ansibleplaybook-extravars
example to show how to configure extra vars when running an Ansible playbook command.ansibleplaybook-ssh
example to show how to execute an Ansible playbook using SSH as the connection method.AnsiblePlaybookExecute
executor has been introduced. That executor allows you to create an executor to runansible-playbook
commands using the default settings ofDefaultExecute
. This executor is located in thegithub.com/apenella/go-ansible/v2/pkg/execute/playbook
package.Commander
interface has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/execute
package. This interface defines the criteria for a struct to be compliant in generating execution commands.ErrorEnricher
interface has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/execute
package. This interface defines the criteria for a struct to be compliant in enriching the error message of the command execution.Executabler
interface has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/execute
package. This interface defines the criteria for a struct to be compliant in executing external commands.ExecutorEnvVarSetter
interface ingithub.com/apenella/go-ansible/v2/pkg/execute/configuration
defines the criteria for a struct to be compliant in setting Ansible configuration.ExecutorQuietStdoutCallbackSetter
interface has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/execute/stdoutcallback
package. This interface defines the criteria for a struct to be compliant in setting an executor that accepts the stdout callback configuration and that enables theQuiet
method for Ansible executions.ExecutorStdoutCallbackSetter
interface has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/execute/stdoutcallback
package. 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/exec
package has been introduced. This package serves as a wrapper foros.exec
.github.com/apenella/go-ansible/v2/pkg/execute/configuration
package includes theExecutorWithAnsibleConfigurationSettings
struct, which acts as a decorator that facilitates the configuration of Ansible settings within the executor.github.com/apenella/go-ansible/v2/pkg/execute/result/default
package has been introduced. This package offers the default component for printing execution results. It supersedes theDefaultStdoutCallbackResults
function that was previously defined in thegithub.com/apenella/go-ansible/v2/pkg/stdoutcallback
package.github.com/apenella/go-ansible/v2/pkg/execute/result/json
package has been introduced. This package offers the component for printing execution results from the JSON stdout callback. It supersedes theJSONStdoutCallbackResults
function that was previously defined in thegithub.com/apenella/go-ansible/v2/pkg/stdoutcallback
package.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/workflow
package 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/install
package 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-collection
has 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/install
package 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-role
has been added to demonstrate how to install an Ansible role and execute an Ansible playbook in a sequence.golangci-lint
has been added to the CI/CD pipeline to ensure the code quality.NewAnsibleAdhocCmd
,NewAnsibleInventoryCmd
andNewAnsiblePlaybookCmd
functions have been introduced. These functions are responsible for creating theAnsibleAdhocCmd
,AnsibleInventoryCmd
andAnsiblePlaybookCmd
structs, respectively.Path
attribute has been added to theAnsiblePlaybookJSONResultsPlayTaskHostsItem
struct.ResultsOutputer
interface has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/execute/result
package. 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
Quiet
method has been added to theDefaultExecute
struct. This method forces to remove verbosity from the executed command.
DefaultExecute
used theString
method from theCommander
to include the command in the error message when the execution fails, instead of using the theString
method from theos/exec.Cmd
struct.- In the
AnsiblePlaybookJSONResultsPlayTaskHostsItem
struct, the attributesStdoutLines
andStderrLines
have chnage their type from[]string
to[]interface{}
. - The
AnsibleAdhocCmd
struct has been updated to implement theCommander
interface. - The
AnsibleInventoryCmd
struct has been updated to implement theCommander
interface. - The
AnsiblePlaybookCmd
struct has been updated to implement theCommander
interface. - The
AnsiblePlaybookOptions
andAnsibleAdhocOptions
structs have been updated to include the attributes fromAnsibleConnectionOptions
andAnsiblePrivilegeEscalationOptions
. - The
DefaultExecute
struct has been updated to have a new attribute namedExec
of typeExecutabler
that is responsible for executing external commands. - The
DefaultExecute
struct has been updated to have a new attribute namedOutput
of typeResultsOutputer
that is responsible for printing the execution's output. - The
DefaultExecute
struct has been updated to implement theExecutor
interface. - The
DefaultExecute
struct has been updated to implement theExecutorEnvVarSetter
interface. - The
DefaultExecute
struct has been updated to implement theExecutorStdoutCallbackSetter
interface. - The
Execute
method in theDefaultExecute
struct has been updated to return an error on the deferred function when the command execution fails. - The
Options
attribute inAnsibleAdhocCmd
struct has been renamed toAdhocOptions
. - The
Options
attribute inAnsibleInventoryCmd
struct has been renamed toInventoryOptions
. - The
Options
attribute inAnsiblePlaybookCmd
struct has been renamed toPlaybookOptions
. - The
Read
method in theReadPasswordFromEnvVar
struct from thegithub.com/apenella/go-ansible/v2/vault/password/envvars
package 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/transformer
has been moved togithub.com/apenella/go-ansible/v2/pkg/execute/result/transformer
. - Upgrade the Go version from
1.19
to1.22
.
- Remove from
DefaultExecute
ansible-playbook error enrichment. - The
Exec
attribute has been removed fromAnsiblePlaybookCmd
andAdhocPlaybookCmd
. - The
github.com/apenella/go-ansible/pkg/options
package has been removed. After theAnsibleConnectionOptions
andAnsiblePrivilegeEscalationOptions
structs are not available anymore. - The
github.com/apenella/go-ansible/pkg/stdoutcallback
package has been removed. - The
Run
method has been removed from theAnsiblePlaybookCmd
andAdhocPlaybookCmd
structs. - The
ShowDuration
attribute in theDefaultExecute
struct has been removed. - The
StdoutCallback
attribute has been removed fromAnsiblePlaybookCmd
andAdhocPlaybookCmd
. - The constants
AnsibleForceColorEnv
andAnsibleHostKeyCheckingEnv
have been removed from thegithub.com/apenella/go-ansible/pkg/options
package. - The functions
AnsibleForceColor
,AnsibleAvoidHostKeyChecking
andAnsibleSetEnv
have been removed from thegithub.com/apenella/go-ansible/pkg/options
package. Use theExecutorWithAnsibleConfigurationSettings
decorator instead defined in thegithub.com/apenella/go-ansible/v2/pkg/execute/configuration
package. - The methods
WithWrite
andwithshowduration
have been removed from theExecutorTimeMeasurement
decorator.
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-ansible
togithub.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
/AnsibleInvetoryCmd
has undergone important changes.- Inversion of responsibilities: The executor is now responsible for executing external commands, while
AnsiblePlaybookCmd
,AnsibleInventoryCmd
andAnsibleAdhocCmd
have 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
,AnsibleInventoryCmd
andAnsibleAdhocCmd
:- The
Run
method. - The
Exec
andStdoutCallback
attributes.
- The
- Attributes Renaming: The
Options
attribute has been renamed toPlaybookOptions
inAnsiblePlaybookCmd
,AdhocOptions
inAnsibleAdhocCmd
andInventoryOptions
inAnsibleInventoryCmd
.
- Inversion of responsibilities: The executor is now responsible for executing external commands, while
- The
Executor
interface has undergone a significant signature change. This change entails the removal of the following argumentsresultsFunc
andoptions
. The current signature is:Execute(ctx context.Context) error
. - The
github.com/apenella/go-ansible/pkg/options
package has been removed. After that deletion, the attributes fromAnsibleConnectionOptions
andAnsiblePrivilegeEscalationOptions
attributes have been moved to thePlaybookOptions
,AdhocOptions
andInventoryOptions
structs. - The
github.com/apenella/go-ansible/pkg/stdoutcallback
package 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/stdoutcallback
that enables the setting of the stdout callback. - The constants
AnsibleForceColorEnv
andAnsibleHostKeyCheckingEnv
have been removed from thegithub.com/apenella/go-ansible/pkg/options
package. - The functions
AnsibleForceColor
,AnsibleAvoidHostKeyChecking
andAnsibleSetEnv
have been removed from thegithub.com/apenella/go-ansible/pkg/options
package. Use theExecutorWithAnsibleConfigurationSettings
decorator instead defined in thegithub.com/apenella/go-ansible/v2/pkg/execute/configuration
package. - The methods
WithWrite
andWithShowduration
have been removed from theExecutorTimeMeasurement
decorator. Instead, a new method namedDuration
has been introduced for obtaining the duration of the execution.
- Quote properly the attributes
SCPExtraArgs
,SFTPExtraArgs
,SSHCommonArgs
,SSHExtraArgs
inAnsibleAdhocOptions
andAnsiblePlaybookOptions
structs when generating the command to be executed. #140
AnsibleAdhocExecute
executor has been introduced. That executor allows you to create an executor to runansible
commands using the default settings ofDefaultExecute
. This executor is located in thegithub.com/apenella/go-ansible/v2/pkg/execute/adhoc
package.AnsibleInventoryExecute
executor has been introduced. That executor allows you to create an executor to runansible-inventory
commands using the default settings ofDefaultExecute
. This executor is located in thegithub.com/apenella/go-ansible/v2/pkg/execute/inventory
package.ansibleplaybook-extravars
example to show how to configure extra vars when running an Ansible playbook command.ansibleplaybook-ssh
example to show how to execute an Ansible playbook using SSH as the connection method.AnsiblePlaybookExecute
executor has been introduced. That executor allows you to create an executor to runansible-playbook
commands using the default settings ofDefaultExecute
. This executor is located in thegithub.com/apenella/go-ansible/v2/pkg/execute/playbook
package.Commander
interface has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/execute
package. This interface defines the criteria for a struct to be compliant in generating execution commands.Executabler
interface has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/execute
package. This interface defines the criteria for a struct to be compliant in executing external commands.ExecutorEnvVarSetter
interface ingithub.com/apenella/go-ansible/v2/pkg/execute/configuration
defines the criteria for a struct to be compliant in setting Ansible configuration.ExecutorStdoutCallbackSetter
interface has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/execute/stdoutcallback
package. 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/exec
package has been introduced. This package serves as a wrapper foros.exec
.github.com/apenella/go-ansible/v2/pkg/execute/configuration
package includes theExecutorWithAnsibleConfigurationSettings
struct, which acts as a decorator that facilitates the configuration of Ansible settings within the executor.github.com/apenella/go-ansible/v2/pkg/execute/result/default
package has been introduced. This package offers the default component for printing execution results. It supersedes theDefaultStdoutCallbackResults
function that was previously defined in thegithub.com/apenella/go-ansible/v2/pkg/stdoutcallback
package.github.com/apenella/go-ansible/v2/pkg/execute/result/json
package has been introduced. This package offers the component for printing execution results from the JSON stdout callback. It supersedes theJSONStdoutCallbackResults
function that was previously defined in thegithub.com/apenella/go-ansible/v2/pkg/stdoutcallback
package.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/workflow
package 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/install
package 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-collection
has 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/install
package 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-role
has been added to demonstrate how to install an Ansible role and execute an Ansible playbook in a sequence.NewAnsibleAdhocCmd
,NewAnsibleInventoryCmd
andNewAnsiblePlaybookCmd
functions have been introduced. These functions are responsible for creating theAnsibleAdhocCmd
,AnsibleInventoryCmd
andAnsiblePlaybookCmd
structs, respectively.ResultsOutputer
interface has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/execute/result
package. 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
AnsibleAdhocCmd
struct has been updated to implement theCommander
interface. - The
AnsibleInventoryCmd
struct has been updated to implement theCommander
interface. - The
AnsiblePlaybookCmd
struct has been updated to implement theCommander
interface. - The
AnsiblePlaybookOptions
andAnsibleAdhocOptions
structs have been updated to include the attributes fromAnsibleConnectionOptions
andAnsiblePrivilegeEscalationOptions
. - The
DefaultExecute
struct has been updated to have a new attribute namedExec
of typeExecutabler
that is responsible for executing external commands. - The
DefaultExecute
struct has been updated to have a new attribute namedOutput
of typeResultsOutputer
that is responsible for printing the execution's output. - The
DefaultExecute
struct has been updated to implement theExecutor
interface. - The
DefaultExecute
struct has been updated to implement theExecutorEnvVarSetter
interface. - The
DefaultExecute
struct has been updated to implement theExecutorStdoutCallbackSetter
interface. - The
Options
attribute inAnsibleAdhocCmd
struct has been renamed toAdhocOptions
. - The
Options
attribute inAnsibleInventoryCmd
struct has been renamed toInventoryOptions
. - The
Options
attribute inAnsiblePlaybookCmd
struct 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/transformer
has been moved togithub.com/apenella/go-ansible/v2/pkg/execute/result/transformer
.
- The
Exec
attribute has been removed fromAnsiblePlaybookCmd
andAdhocPlaybookCmd
. - The
github.com/apenella/go-ansible/pkg/options
package has been removed. After theAnsibleConnectionOptions
andAnsiblePrivilegeEscalationOptions
structs are not available anymore. - The
github.com/apenella/go-ansible/pkg/stdoutcallback
package has been removed. - The
Run
method has been removed from theAnsiblePlaybookCmd
andAdhocPlaybookCmd
structs. - The
ShowDuration
attribute in theDefaultExecute
struct has been removed. - The
StdoutCallback
attribute has been removed fromAnsiblePlaybookCmd
andAdhocPlaybookCmd
. - The constants
AnsibleForceColorEnv
andAnsibleHostKeyCheckingEnv
have been removed from thegithub.com/apenella/go-ansible/pkg/options
package. - The functions
AnsibleForceColor
,AnsibleAvoidHostKeyChecking
andAnsibleSetEnv
have been removed from thegithub.com/apenella/go-ansible/pkg/options
package. Use theExecutorWithAnsibleConfigurationSettings
decorator instead defined in thegithub.com/apenella/go-ansible/v2/pkg/execute/configuration
package. - The methods
WithWrite
andwithshowduration
have been removed from theExecutorTimeMeasurement
decorator.
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-ansible
togithub.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
/AnsibleInvetoryCmd
has undergone important changes.- Inversion of responsabilities: The executor is now responsible for executing external commands, while
AnsiblePlaybookCmd
,AnsibleInventoryCmd
andAnsibleAdhocCmd
have 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
,AnsibleInventoryCmd
andAnsibleAdhocCmd
:- The
Run
method. - The
Exec
andStdoutCallback
attributes.
- The
- Attributes Renaming: The
Options
attribute has been renamed toPlaybookOptions
inAnsiblePlaybookCmd
,AdhocOptions
inAnsibleAdhocCmd
andInventoryOptions
inAnsibleInventoryCmd
.
- Inversion of responsabilities: The executor is now responsible for executing external commands, while
- The
Executor
interface has undergone a significant signature change. This change entails the removal of the following argumentsresultsFunc
andoptions
. The current signature is:Execute(ctx context.Context) error
. - The
github.com/apenella/go-ansible/pkg/options
package has been removed. After that deletion, the attributes fromAnsibleConnectionOptions
andAnsiblePrivilegeEscalationOptions
attributes have been moved to thePlaybookOptions
,AdhocOptions
andInventoryOptions
structs. - The
github.com/apenella/go-ansible/pkg/stdoutcallback
package 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/stdoutcallback
that enables the setting of the stdout callback. - The constants
AnsibleForceColorEnv
andAnsibleHostKeyCheckingEnv
have been removed from thegithub.com/apenella/go-ansible/pkg/options
package. - The functions
AnsibleForceColor
,AnsibleAvoidHostKeyChecking
andAnsibleSetEnv
have been removed from thegithub.com/apenella/go-ansible/pkg/options
package. Use theExecutorWithAnsibleConfigurationSettings
decorator instead defined in thegithub.com/apenella/go-ansible/v2/pkg/execute/configuration
package. - The methods
WithWrite
andWithShowduration
have been removed from theExecutorTimeMeasurement
decorator. Instead, a new method namedDuration
has been introduced for obtaining the duration of the execution.
- A new executor
AnsibleAdhocExecute
has been introduced. That executor allows you to create an executor to runansible
commands using the default settings ofDefaultExecute
. This executor is located in thegithub.com/apenella/go-ansible/v2/pkg/execute/adhoc
package. - A new executor
AnsibleInventoryExecute
has been introduced. That executor allows you to create an executor to runansible-inventory
commands using the default settings ofDefaultExecute
. This executor is located in thegithub.com/apenella/go-ansible/v2/pkg/execute/inventory
package. - A new executor
AnsiblePlaybookExecute
has been introduced. That executor allows you to create an executor to runansible-playbook
commands using the default settings ofDefaultExecute
. This executor is located in thegithub.com/apenella/go-ansible/v2/pkg/execute/playbook
package. - A new interface
Commander
has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/execute
package. This interface defines the criteria for a struct to be compliant in generating execution commands. - A new interface
Executabler
has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/execute
package. This interface defines the criteria for a struct to be compliant in executing external commands. - A new interface
ExecutorEnvVarSetter
ingithub.com/apenella/go-ansible/v2/pkg/execute/configuration
that defines the criteria for a struct to be compliant in setting Ansible configuration. - A new interface
ExecutorStdoutCallbackSetter
has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/execute/stdoutcallback
package. 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
ResultsOutputer
has been introduced in thegithub.com/apenella/go-ansible/v2/pkg/execute/result
pacakge. 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/exec
has been introduced. This package serves as a wrapper foros.exec
. - A new package
github.com/apenella/go-ansible/v2/pkg/execute/configuration
that incldues theExecutorWithAnsibleConfigurationSettings
struct, 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/default
has been introduced. This package offers the default component for printing execution results. It supersedes theDefaultStdoutCallbackResults
function that was previously defined in thegithub.com/apenella/go-ansible/v2/pkg/stdoutcallback
package. - A new package
github.com/apenella/go-ansible/v2/pkg/execute/result/json
has been introduced. This package offers the component for printing execution results from the JSON stdout callback. It supersedes theJSONStdoutCallbackResults
function that was previously defined in thegithub.com/apenella/go-ansible/v2/pkg/stdoutcallback
package. - 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/workflow
has 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
AnsibleAdhocCmd
struct has been updated to implement theCommander
interface. - The
AnsibleInventoryCmd
struct has been updated to implement theCommander
interface. - The
AnsiblePlaybookCmd
struct has been updated to implement theCommander
interface. - The
AnsiblePlaybookOptions
andAnsibleAdhocOptions
structs have been updated to include the attributes fromAnsibleConnectionOptions
andAnsiblePrivilegeEscalationOptions
. - The
DefaultExecute
struct has been updated to have a new attribute namedExec
of typeExecutabler
that is responsible for executing external commands. - The
DefaultExecute
struct has been updated to have a new attribute namedOutput
of typeResultsOutputer
that is responsible for printing the execution's output. - The
DefaultExecute
struct has been updated to implement theExecutor
interface. - The
DefaultExecute
struct has been updated to implement theExecutorEnvVarSetter
interface. - The
DefaultExecute
struct has been updated to implement theExecutorStdoutCallbackSetter
interface. - The
Options
attribute inAnsibleAdhocCmd
struct has been renamed toAdhocOptions
. - The
Options
attribute inAnsibleInventoryCmd
struct has been renamed toInventoryOptions
. - The
Options
attribute inAnsiblePlaybookCmd
struct 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/transformer
has been moved togithub.com/apenella/go-ansible/v2/pkg/execute/result/transformer
.
- The
Exec
attribute has been removed fromAnsiblePlaybookCmd
andAdhocPlaybookCmd
. - The
github.com/apenella/go-ansible/pkg/options
package has been removed. After theAnsibleConnectionOptions
andAnsiblePrivilegeEscalationOptions
structs are not available anymore. - The
github.com/apenella/go-ansible/pkg/stdoutcallback
package has been removed. - The
Run
method has been removed from theAnsiblePlaybookCmd
andAdhocPlaybookCmd
structs. - The
ShowDuration
attribute in theDefaultExecute
struct has been removed. - The
StdoutCallback
attribute has been removed fromAnsiblePlaybookCmd
andAdhocPlaybookCmd
. - The constants
AnsibleForceColorEnv
andAnsibleHostKeyCheckingEnv
have been removed from thegithub.com/apenella/go-ansible/pkg/options
package. - The functions
AnsibleForceColor
,AnsibleAvoidHostKeyChecking
andAnsibleSetEnv
have been removed from thegithub.com/apenella/go-ansible/pkg/options
package. Use theExecutorWithAnsibleConfigurationSettings
decorator instead defined in thegithub.com/apenella/go-ansible/v2/pkg/execute/configuration
package. - The methods
WithWrite
andwithshowduration
have been removed from theExecutorTimeMeasurement
decorator.
- 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/vault
package, which enables variable encryption. - Added the
github.com/apenella/go-ansible/pkg/vault/password/text
package for reading encryption passwords as plain text. - Introduced the
github.com/apenella/go-ansible/pkg/vault/password/resolve
package, which helps in resolving an encryption password. - Added the
github.com/apenella/go-ansible/pkg/vault/password/file
package for reading encryption passwords from a file. - Introduced the
github.com/apenella/go-ansible/pkg/vault/password/envvars
package, allowing the reading of encryption passwords from an environment variable. - Added the
github.com/apenella/go-ansible/pkg/vault/encrypt
package, which provides the ability to encrypt strings using thehttps://github.com/sosedoff/ansible-vault-go
package. - Included an example using
embed.FS
.
- On
AnsiblePlaybookJSONResultsPlayTaskHostsItem
, attributesStdout
andStderr
has been changed fromstring
tointerface{}
#109
- On
AnsiblePlaybookJSONResultsPlayTaskHostsItem
, fixUnreachable
attribute type tobool
#103
- Quote
Args
value onAnsibleAdhocCmd
'sString
method #91 - On default executor, set all parent process environment variables to
cmd.Env
when a custom env vars is defined #94 - Fix parsing of long lines in output #101
ExecutorTimeMeasurement
is a decorator defined ongithub.com/apenella/go-ansible/pkg/execute
, that measures the duration of an execution, it receives anExecutor
which is measured the execution time #92- Add
unreachable
state on task play results structAnsiblePlaybookJSONResultsPlayTaskHostsItem
#100
MockExecute
usesgithub.com/stretchr/testify/mock
#92- Examples' name are prefixed by
ansibleplaybook
oransibleadhoc
DefaultExecutor
does not measures the execution duration anymore. Instead of it,ExecutorTimeMeasurement
must be used #92
- New function
WithEnvVar
ongithub.com/apenella/go-ansible/pkg/execute
package that adds environment variables toDefaultExecutor
command.
- Include missing attributes on
AnsiblePlaybookJSONResultsPlayTaskHostsItem
. Those attributes arecmd
,skipped
,skip_reason
,failed
, andfailed_when_result
- New function
ParseJSONResultsStream
on"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
ExtraVarsFile
onAnsiblePlaybookOptions
that allows to use YAML/JSON files to define extra-vars - New attribute
ExtraVarsFile
onAnsibleAdhocOptions
that allows to use YAML/JSON files to define extra-vars
- Include
stdout
andstdout_lines
toAnsiblePlaybookJSONResultsPlayTaskHostsItem
- Include
stderr
andstderr_lines
toAnsiblePlaybookJSONResultsPlayTaskHostsItem
- 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
Msg
type onAnsiblePlaybookJSONResultsPlayTaskHostsItem
fromstring
tointerface{}
- support for stdin on
DefaultExecute
Execute method
- Included
ansible-playbook
version2.10.6
options onAnsiblePlaybookOptions
- Included
github.com/apenella/go-ansible/pkg/adhoc
package to interact toansible
adhoc command - New function type
ExecuteOptions
to provide options to executor instances - New
DefaultExecute
constructorNewDefaultExecute
that 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
output
onresults
package to manage how to write the output lines and that can be used by anyStdoutCallbackResultsFunc
- BREAKING CHANGE:
ansibler
has been restructured and splitted to multiple packages:- Type
AnsiblePlaybookConnectionOptions
is renamed toAnsibleConnectionOptions
and placed togithub.com/apenella/go-ansible/pkg/options
- Type
AnsiblePlaybookPrivilegeEscalationOptions
is renamed toAnsiblePrivilegeEscalationOptions
and 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
AnsiblePlaybookCmd
andAnsiblePlaybookOptions
has 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:
Playbook
attribute onAnsiblePlaybookCmd
has been replaced toPlaybooks
attribut which accept multiple playbooks to be run - BREAKING CHANGE:
Executor
interface has been moved fromansibler
package togithub.com/apenella/go-ansible/pkg/execute
package - BREAKING CHANGE:
Executor
interface is changed toExecute(ctx context.Context, command []string, resultsFunc stdoutcallback.StdoutCallbackResultsFunc, options ...ExecuteOptions) error
- BREAKING CHANGE:
DefaultExecute
has been updated to use options pattern design, and includes a bunch ofWithXXX
methods to set its attributes - BREAKING CHANGE:
StdoutCallbackResultsFunc
signature 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 DefaultStdoutCallbackResults
andJSONStdoutCallbackResults
prepares default transformers for default output an callsoutput
, instead of managing the output by its own
- BREAKING CHANGE: Remove
ExecPrefix
fromAnsiblePlaybookCmd
- BREAKING CHANGE: Remove
CmdRunDir
fromAnsiblePlaybookCmd
- BREAKING CHANGE: Remove
Writer
fromAnsiblePlaybookCmd
- BREAKING CHANGE: Remove
ResultsFunc
fromDefaultExecute
- BREAKING CHANGE: Remove
Prefix
fromDefaultExecute
. Prefix is not manatory any more and could be added using thePrepend
transformer. skipLine
method has been removed. Replaced byIgnoreMessage
transformer
- 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-playbook
output - Manage Json stdout callback results
- DefaultExecutor includes an error managemnt depending on
ansible-playbook
exit 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