json

package
v2.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2025 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// PrefixTokenSeparator is and string printed between prefix and ansible output
	PrefixTokenSeparator = "\u2500\u2500"
)

Variables

This section is empty.

Functions

func WithJSONLEventTransformers added in v2.2.0

func WithJSONLEventTransformers(trans ...transformer.TransformerFunc) result.OptionsFunc

WithJSONLEventTransformers sets a transformers list to JSONLEventStdoutCallbackResults

func WithTransformers

func WithTransformers(trans ...transformer.TransformerFunc) result.OptionsFunc

WithTransformers sets a transformers list to DefaultResults

Types

type AnsiblePlaybookJSONLEventResults added in v2.2.0

type AnsiblePlaybookJSONLEventResults struct {
	Event     string `json:"_event"`
	Timestamp string `json:"_timestamp"`

	CustomStats       interface{}                                             `json:"custom_stats"`
	GlobalCustomStats interface{}                                             `json:"global_custom_stats"`
	Hosts             map[string]*AnsiblePlaybookJSONResultsPlayTaskHostsItem `json:"hosts,omitempty"`
	Play              *AnsiblePlaybookJSONResultsPlaysPlay                    `json:"play,omitempty"`
	Stats             map[string]*AnsiblePlaybookJSONResultsStats             `json:"stats"`
	Task              *AnsiblePlaybookJSONResultsPlayTaskItem                 `json:"task,omitempty"`
	Tasks             []AnsiblePlaybookJSONResultsPlayTask                    `json:"tasks,omitempty"`
}

AnsiblePlaybookJSONLEventResults represents the structure of the JSON lines generated by an Ansible playbook execution using the ansible.posix.jsonl callback plugin

func (AnsiblePlaybookJSONLEventResults) String added in v2.2.0

String returns a string representation of AnsiblePlaybookJSONLEventResults

type AnsiblePlaybookJSONResults

type AnsiblePlaybookJSONResults struct {
	Playbook          string                                      `json:"-"`
	CustomStats       interface{}                                 `json:"custom_stats"`
	GlobalCustomStats interface{}                                 `json:"global_custom_stats"`
	Plays             []AnsiblePlaybookJSONResultsPlay            `json:"plays"`
	Stats             map[string]*AnsiblePlaybookJSONResultsStats `json:"stats"`
}

AnsiblePlaybookJSONResults represents the structure of the JSON generated by an Ansible playbook execution using the JSON callback plugin

func JSONParse

func JSONParse(data []byte) (*AnsiblePlaybookJSONResults, error)

JSONParse return an AnsiblePlaybookJSONResults from a JSON data

func ParseJSONResultsStream

func ParseJSONResultsStream(stream io.Reader) (*AnsiblePlaybookJSONResults, error)

ParseJSONResultsStream parse the ansible' JSON stdout callback and return an AnsiblePlaybookJSONResults

func (*AnsiblePlaybookJSONResults) CheckStats

func (r *AnsiblePlaybookJSONResults) CheckStats() error

CheckStats return error when is found a failure or unreachable host

func (*AnsiblePlaybookJSONResults) String

func (r *AnsiblePlaybookJSONResults) String() string

String return a string representation of the AnsiblePlaybookJSONResults

type AnsiblePlaybookJSONResultsPlay

type AnsiblePlaybookJSONResultsPlay struct {
	Play  *AnsiblePlaybookJSONResultsPlaysPlay `json:"play"`
	Tasks []AnsiblePlaybookJSONResultsPlayTask `json:"tasks"`
}

AnsiblePlaybookJSONResultsPlay represents the structure of the JSON generated by an Ansible playbook execution using the JSON callback plugin

https://github.com/ansible-collections/ansible.posix/blob/main/plugins/callback/json.py#L80

{
	'play': {
		'name': play.get_name(),
		'id': to_text(play._uuid),
		'path': to_text(play.get_path()),
		'duration': {
			'start': current_time()
		}
	},
	'tasks': []
}

type AnsiblePlaybookJSONResultsPlayDuration

type AnsiblePlaybookJSONResultsPlayDuration struct {
	Start string `json:"start"`
	End   string `json:"end"`
}

AnsiblePlaybookJSONResultsPlayDuration represents the structure of the JSON generated by an Ansible playbook execution using the JSON callback plugin

func (*AnsiblePlaybookJSONResultsPlayDuration) String added in v2.2.0

String return a string representation of the AnsiblePlaybookJSONResultsPlayDuration

type AnsiblePlaybookJSONResultsPlayTask

type AnsiblePlaybookJSONResultsPlayTask struct {
	Hosts map[string]*AnsiblePlaybookJSONResultsPlayTaskHostsItem `json:"hosts"`
	Task  *AnsiblePlaybookJSONResultsPlayTaskItem                 `json:"task"`
}

AnsiblePlaybookJSONResultsPlayTask represents the structure of the JSON generated by an Ansible playbook execution using the JSON callback plugin.

For more details, see: https://github.com/ansible-collections/ansible.posix/blob/main/plugins/callback/json.py#L94

{
	'task': {
		'name': task.get_name(),
		'id': to_text(task._uuid),
		'path': to_text(task.get_path()),
		'duration': {
			'start': current_time()
		}
	},

	'hosts': {}
}

type AnsiblePlaybookJSONResultsPlayTaskHostsItem

type AnsiblePlaybookJSONResultsPlayTaskHostsItem struct {
	Action           string                 `json:"action"`
	Changed          bool                   `json:"changed"`
	Msg              interface{}            `json:"msg"`
	AnsibleFacts     map[string]interface{} `json:"ansible_facts"`
	Stdout           interface{}            `json:"stdout"`
	StdoutLines      []interface{}          `json:"stdout_lines"`
	Stderr           interface{}            `json:"stderr"`
	StderrLines      []interface{}          `json:"stderr_lines"`
	Cmd              interface{}            `json:"cmd"`
	Failed           bool                   `json:"failed"`
	FailedWhenResult bool                   `json:"failed_when_result"`
	Skipped          bool                   `json:"skipped"`
	SkipReason       string                 `json:"skip_reason"`
	Unreachable      bool                   `json:"unreachable"`
}

AnsiblePlaybookJSONResultsPlayTaskHostsItem represents the structure of the JSON generated by an Ansible playbook execution using the JSON callback plugin

type AnsiblePlaybookJSONResultsPlayTaskItem

type AnsiblePlaybookJSONResultsPlayTaskItem struct {
	Duration *AnsiblePlaybookJSONResultsPlayTaskItemDuration `json:"duration"`
	Id       string                                          `json:"id"`
	Name     string                                          `json:"name"`
	Path     string                                          `json:"path"`
}

AnsiblePlaybookJSONResultsPlayTaskItem represents the structure of the JSON generated by an Ansible playbook execution using the JSON callback plugin

type AnsiblePlaybookJSONResultsPlayTaskItemDuration

type AnsiblePlaybookJSONResultsPlayTaskItemDuration struct {
	Start string `json:"start"`
	End   string `json:"end"`
}

AnsiblePlaybookJSONResultsPlayTaskItemDuration represents the structure of the JSON generated by an Ansible playbook execution using the JSON callback plugin

func (*AnsiblePlaybookJSONResultsPlayTaskItemDuration) String added in v2.2.0

String return a string representation of the AnsiblePlaybookJSONResultsPlayTaskItem

type AnsiblePlaybookJSONResultsPlaysPlay

type AnsiblePlaybookJSONResultsPlaysPlay struct {
	Duration *AnsiblePlaybookJSONResultsPlayDuration `json:"duration"`
	Id       string                                  `json:"id"`
	Name     string                                  `json:"name"`
	Path     string                                  `json:"path"`
}

AnsiblePlaybookJSONResultsPlaysPlay represents the structure of the JSON generated by an Ansible playbook execution using the JSON callback plugin

type AnsiblePlaybookJSONResultsStats

type AnsiblePlaybookJSONResultsStats struct {
	Changed     int `json:"changed"`
	Failures    int `json:"failures"`
	Ignored     int `json:"ignored"`
	Ok          int `json:"ok"`
	Rescued     int `json:"rescued"`
	Skipped     int `json:"skipped"`
	Unreachable int `json:"unreachable"`
}

AnsiblePlaybookJSONResultsStats represents the structure of the JSON generated by an Ansible playbook execution using the JSON callback plugin

func (*AnsiblePlaybookJSONResultsStats) String

String return a string representation of the AnsiblePlaybookJSONResultsStats

type JSONLEventStdoutCallbackResults added in v2.2.0

type JSONLEventStdoutCallbackResults struct {
	// contains filtered or unexported fields
}

JSONLEventStdoutCallbackResults handles the ansible.posix.jsonl callback plugin output

func NewJSONLEventStdoutCallbackResults added in v2.2.0

func NewJSONLEventStdoutCallbackResults(options ...result.OptionsFunc) *JSONLEventStdoutCallbackResults

NewJSONLEventStdoutCallbackResults creates a new JSONLEventStdoutCallbackResults instance

func (*JSONLEventStdoutCallbackResults) Options added in v2.2.0

func (r *JSONLEventStdoutCallbackResults) Options(options ...result.OptionsFunc)

Options executes the options functions received as a parameters to set the JSONLEventStdoutCallbackResults attributes

func (*JSONLEventStdoutCallbackResults) Print added in v2.2.0

func (r *JSONLEventStdoutCallbackResults) Print(ctx context.Context, reader io.Reader, writer io.Writer, options ...result.OptionsFunc) error

Print handles the ansible.posix.jsonl callback plugin output

type JSONStdoutCallbackResults

type JSONStdoutCallbackResults struct {
	// contains filtered or unexported fields
}

func NewJSONStdoutCallbackResults

func NewJSONStdoutCallbackResults(options ...result.OptionsFunc) *JSONStdoutCallbackResults

func (*JSONStdoutCallbackResults) Options

func (r *JSONStdoutCallbackResults) Options(options ...result.OptionsFunc)

Options executes the options functions received as a parameters to set the DefaultResults attributes

func (*JSONStdoutCallbackResults) Print

func (r *JSONStdoutCallbackResults) Print(ctx context.Context, reader io.Reader, writer io.Writer, options ...result.OptionsFunc) error

Print method manges the ansible' JSON stdout callback and print the result stats

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL