github.com/jlmeeker/kismatic@v1.10.1-0.20180612190640-57f9005a1f1a/pkg/ansible/event.go (about)

     1  package ansible
     2  
     3  // Event produced by Ansible when running a playbook
     4  type Event interface {
     5  	// Type is the name of the event type
     6  	Type() string
     7  }
     8  
     9  type namedEvent struct {
    10  	Name string
    11  }
    12  
    13  type runnerResult struct {
    14  	// Command is the command that was run
    15  	Command []string `json:"cmd"`
    16  	// Stdout captured when the command was run
    17  	Stdout string
    18  	// Stderr captured when the command was run
    19  	Stderr string
    20  	// Message returned by the runner
    21  	Message string `json:"msg"`
    22  	// Item that corresponds to this result. Available only when event is related
    23  	// to an item
    24  	Item string
    25  	// Number of attempts a task has been retried
    26  	Attempts int
    27  	// Maximum number of retries for a given task
    28  	MaxRetries int `json:"retries"`
    29  }
    30  
    31  type runnerResultEvent struct {
    32  	Host         string
    33  	Result       runnerResult
    34  	IgnoreErrors bool
    35  }
    36  
    37  // PlaybookStartEvent signals the beginning of a playbook
    38  type PlaybookStartEvent struct {
    39  	namedEvent
    40  	Count int
    41  }
    42  
    43  func (e *PlaybookStartEvent) Type() string {
    44  	return "Playbook Start"
    45  }
    46  
    47  // PlaybookEndEvent signals the beginning of a playbook
    48  type PlaybookEndEvent struct {
    49  	namedEvent
    50  }
    51  
    52  func (e *PlaybookEndEvent) Type() string {
    53  	return "Playbook End"
    54  }
    55  
    56  // PlayStartEvent signals the beginning of a play
    57  type PlayStartEvent struct {
    58  	namedEvent
    59  }
    60  
    61  func (e *PlayStartEvent) Type() string {
    62  	return "Play Start"
    63  }
    64  
    65  // TaskStartEvent signals the beginning of a task
    66  type TaskStartEvent struct {
    67  	namedEvent
    68  }
    69  
    70  func (e *TaskStartEvent) Type() string {
    71  	return "Task Start"
    72  }
    73  
    74  // HandlerTaskStartEvent signals the beginning of a handler task
    75  type HandlerTaskStartEvent struct {
    76  	namedEvent
    77  }
    78  
    79  func (e *HandlerTaskStartEvent) Type() string {
    80  	return "Handler Task Start"
    81  }
    82  
    83  // RunnerOKEvent signals the successful completion of a runner
    84  type RunnerOKEvent struct {
    85  	runnerResultEvent
    86  }
    87  
    88  func (e *RunnerOKEvent) Type() string {
    89  	return "Runner OK"
    90  }
    91  
    92  // RunnerFailedEvent signals a failure when executing a runner
    93  type RunnerFailedEvent struct {
    94  	runnerResultEvent
    95  }
    96  
    97  func (e *RunnerFailedEvent) Type() string {
    98  	return "Runner Failed"
    99  }
   100  
   101  // RunnerItemOKEvent signals the successful completion of a runner item
   102  type RunnerItemOKEvent struct {
   103  	runnerResultEvent
   104  }
   105  
   106  func (e *RunnerItemOKEvent) Type() string {
   107  	return "Runner Item OK"
   108  }
   109  
   110  // RunnerItemFailedEvent signals the failure of a task with a specific item
   111  type RunnerItemFailedEvent struct {
   112  	runnerResultEvent
   113  }
   114  
   115  func (e *RunnerItemFailedEvent) Type() string {
   116  	return "Runner Item Failed"
   117  }
   118  
   119  // RunnerItemRetryEvent signals the retry of a runner item
   120  type RunnerItemRetryEvent struct {
   121  	runnerResultEvent
   122  }
   123  
   124  func (e *RunnerItemRetryEvent) Type() string {
   125  	return "Runner Item Retry"
   126  }
   127  
   128  // RunnerSkippedEvent is raised when a runner is skipped
   129  type RunnerSkippedEvent struct {
   130  	runnerResultEvent
   131  }
   132  
   133  func (e *RunnerSkippedEvent) Type() string {
   134  	return "Runner Skipped"
   135  }
   136  
   137  // RunnerUnreachableEvent is raised when the target host is not reachable via SSH
   138  type RunnerUnreachableEvent struct {
   139  	runnerResultEvent
   140  }
   141  
   142  func (e *RunnerUnreachableEvent) Type() string {
   143  	return "Runner Unreachable"
   144  }