diff --git a/rundeck/job.go b/rundeck/job.go index 8e4e7d956..40fd08da6 100644 --- a/rundeck/job.go +++ b/rundeck/job.go @@ -67,7 +67,7 @@ type JobDetail struct { CommandSequence *JobCommandSequence `xml:"sequence,omitempty"` Notification *JobNotification `xml:"notification,omitempty"` Timeout string `xml:"timeout,omitempty"` - Retry string `xml:"retry,omitempty"` + Retry *Retry `xml:"retry,omitempty"` NodeFilter *JobNodeFilter `xml:"nodefilters,omitempty"` /* If Dispatch is enabled, nodesSelectedByDefault is always present with true/false. @@ -84,6 +84,11 @@ type Boolean struct { Value bool `xml:",chardata"` } +type Retry struct { + Delay string `xml:"delay,attr"` + Value string `xml:",chardata"` +} + type JobNotification struct { OnFailure *Notification `xml:"onfailure,omitempty"` OnStart *Notification `xml:"onstart,omitempty"` diff --git a/rundeck/resource_job.go b/rundeck/resource_job.go index 4baee9988..a32a24eab 100644 --- a/rundeck/resource_job.go +++ b/rundeck/resource_job.go @@ -62,6 +62,11 @@ func resourceRundeckJob() *schema.Resource { Optional: true, }, + "retry_delay": { + Type: schema.TypeString, + Optional: true, + }, + "max_thread_count": { Type: schema.TypeInt, Optional: true, @@ -601,7 +606,10 @@ func jobFromResourceData(d *schema.ResourceData) (*JobDetail, error) { TimeZone: d.Get("time_zone").(string), LogLevel: d.Get("log_level").(string), AllowConcurrentExecutions: d.Get("allow_concurrent_executions").(bool), - Retry: d.Get("retry").(string), + Retry: &Retry{ + Value: d.Get("retry").(string), + Delay: d.Get("retry_delay").(string), + }, Dispatch: &JobDispatch{ MaxThreadCount: d.Get("max_thread_count").(int), ContinueNextNodeOnError: d.Get("continue_next_node_on_error").(bool), @@ -826,10 +834,14 @@ func jobToResourceData(job *JobDetail, d *schema.ResourceData) error { if err := d.Set("allow_concurrent_executions", job.AllowConcurrentExecutions); err != nil { return err } - if err := d.Set("retry", job.Retry); err != nil { - return err + if job.Retry != nil { + if err := d.Set("retry", job.Retry.Value); err != nil { + return err + } + if err := d.Set("retry_delay", job.Retry.Delay); err != nil { + return err + } } - if job.Dispatch != nil { if err := d.Set("max_thread_count", job.Dispatch.MaxThreadCount); err != nil { return err diff --git a/website/docs/r/job.html.md b/website/docs/r/job.html.md index 7e67d8cbc..faa83dc84 100644 --- a/website/docs/r/job.html.md +++ b/website/docs/r/job.html.md @@ -70,6 +70,10 @@ The following arguments are supported: value reference like "${option.retry}". The default is `0`, meaning that jobs will only run once. +* `retry_delay` - (Optional) The time between the failed execution and the retry. Time in seconds or + specify time units: "120m", "2h", "3d". Use 0 to indicate no delay. Can include option value + references like "${option.delay}". The default is 0. + * `max_thread_count` - (Optional) The maximum number of threads to use to execute this job, which controls on how many nodes the commands can be run simulateneously. Defaults to 1, meaning that the nodes will be visited sequentially.