diff --git a/rundeck/resource_job.go b/rundeck/resource_job.go index 99679a44d..50b36fede 100644 --- a/rundeck/resource_job.go +++ b/rundeck/resource_job.go @@ -137,6 +137,11 @@ func resourceRundeckJob() *schema.Resource { Default: true, }, + "nodes_selected_by_default": { + Type: schema.TypeBool, + Optional: true, + }, + "time_zone": { Type: schema.TypeString, Optional: true, @@ -592,6 +597,7 @@ func jobFromResourceData(d *schema.ResourceData) (*JobDetail, error) { ExecutionEnabled: d.Get("execution_enabled").(bool), Timeout: d.Get("timeout").(string), ScheduleEnabled: d.Get("schedule_enabled").(bool), + NodesSelectedByDefault: d.Get("nodes_selected_by_default").(bool), TimeZone: d.Get("time_zone").(string), LogLevel: d.Get("log_level").(string), AllowConcurrentExecutions: d.Get("allow_concurrent_executions").(bool), @@ -808,6 +814,9 @@ func jobToResourceData(job *JobDetail, d *schema.ResourceData) error { if err := d.Set("schedule_enabled", job.ScheduleEnabled); err != nil { return err } + if err := d.Set("nodes_selected_by_default", job.NodesSelectedByDefault); err != nil { + return err + } if err := d.Set("time_zone", job.TimeZone); err != nil { return err } diff --git a/rundeck/resource_job_test.go b/rundeck/resource_job_test.go index 3c14dce1a..27d904d79 100644 --- a/rundeck/resource_job_test.go +++ b/rundeck/resource_job_test.go @@ -29,6 +29,9 @@ func TestAccJob_basic(t *testing.T) { if expected := "Prints Hello World"; job.CommandSequence.Commands[0].Description != expected { return fmt.Errorf("failed to set command description; expected %v, got %v", expected, job.CommandSequence.Commands[0].Description) } + if expected := true; job.NodesSelectedByDefault != expected { + return fmt.Errorf("failed to set node selected by default; expected %v, got %v", expected, job.NodesSelectedByDefault) + } if job.Dispatch.SuccessOnEmptyNodeFilter != true { return fmt.Errorf("failed to set success_on_empty_node_filter; expected true, got %v", job.Dispatch.SuccessOnEmptyNodeFilter) } @@ -188,6 +191,7 @@ resource "rundeck_job" "test" { execution_enabled = true node_filter_query = "example" allow_concurrent_executions = true + nodes_selected_by_default = true success_on_empty_node_filter = true max_thread_count = 1 rank_order = "ascending" @@ -231,6 +235,7 @@ resource "rundeck_job" "test" { execution_enabled = true node_filter_query = "example" allow_concurrent_executions = true + nodes_selected_by_default = false max_thread_count = 1 rank_order = "ascending" schedule = "0 0 12 * * * *" diff --git a/website/docs/r/job.html.md b/website/docs/r/job.html.md index 1fec0f8ee..098ea49d6 100644 --- a/website/docs/r/job.html.md +++ b/website/docs/r/job.html.md @@ -114,6 +114,9 @@ The following arguments are supported: * `node_filter_exclude_precedence`: (Optional, Deprecated) Boolean controlling a deprecated Rundeck feature that controls whether node exclusions take priority over inclusions. +* `nodes_selected_by_default`: (Optional) Boolean controlling whether nodes that match the node_query_filter are + selected by default or not. + * `option`: (Optional) Nested block defining an option a user may set when executing this job. A job may have any number of options. The structure of this nested block is described below.