v2.0.0-rc.2
github-actions
released this
01 Mar 14:02
·
76 commits
to master
since this release
Release notes
v2.0.0-rc.2
Version 2.0.0 of go-ansible introduces several disruptive changes. Read the upgrade guide carefully before proceeding with the upgrade.
BREAKING CHANGES
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.
Added
- 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
.
Changed
- 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
.
Removed
- 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.