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.
- 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