Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
fdevans committed Oct 7, 2023
2 parents 6a2b3c2 + 1b99ecc commit 71b19b4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
7 changes: 6 additions & 1 deletion rundeck/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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"`
Expand Down
20 changes: 16 additions & 4 deletions rundeck/resource_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/job.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 71b19b4

Please sign in to comment.