diff --git a/rundeck/job.go b/rundeck/job.go index bf7e50436..202376ee2 100644 --- a/rundeck/job.go +++ b/rundeck/job.go @@ -297,14 +297,18 @@ type JobCommandScriptInterpreter struct { // JobCommandJobRef is a reference to another job that will run as one of the commands of a job. type JobCommandJobRef struct { - XMLName xml.Name `xml:"jobref"` - Name string `xml:"name,attr"` - GroupName string `xml:"group,attr"` - Project string `xml:"project,attr"` - RunForEachNode bool `xml:"nodeStep,attr"` - Dispatch *JobDispatch `xml:"dispatch,omitempty"` - NodeFilter *JobNodeFilter `xml:"nodefilters,omitempty"` - Arguments JobCommandJobRefArguments `xml:"arg"` + XMLName xml.Name `xml:"jobref"` + Name string `xml:"name,attr"` + GroupName string `xml:"group,attr"` + Project string `xml:"project,attr"` + RunForEachNode bool `xml:"nodeStep,attr"` + Dispatch *JobDispatch `xml:"dispatch,omitempty"` + NodeFilter *JobNodeFilter `xml:"nodefilters,omitempty"` + Arguments JobCommandJobRefArguments `xml:"arg"` + ChildNodes bool `xml:"childNodes,attr"` + FailOnDisable bool `xml:"failOnDisable,attr"` + IgnoreNotifications bool `xml:"ignoreNotifications,attr"` + ImportOptions bool `xml:"importOptions,attr"` } // JobCommandJobRefArguments is a string representing the arguments in a JobCommandJobRef. diff --git a/rundeck/resource_job.go b/rundeck/resource_job.go index 04d8147f5..2716b7cc3 100644 --- a/rundeck/resource_job.go +++ b/rundeck/resource_job.go @@ -521,6 +521,22 @@ func resourceRundeckJobCommandJob() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "child_nodes": { + Type: schema.TypeBool, + Optional: true, + }, + "fail_on_disable": { + Type: schema.TypeBool, + Optional: true, + }, + "ignore_notifications": { + Type: schema.TypeBool, + Optional: true, + }, + "import_options": { + Type: schema.TypeBool, + Optional: true, + }, "node_filters": { Type: schema.TypeList, Optional: true, @@ -1255,11 +1271,15 @@ func jobCommandJobRefFromResourceData(key string, commandMap map[string]interfac } jobRefMap := jobRefsI[0].(map[string]interface{}) jobRef := &JobCommandJobRef{ - Name: jobRefMap["name"].(string), - GroupName: jobRefMap["group_name"].(string), - Project: jobRefMap["project_name"].(string), - RunForEachNode: jobRefMap["run_for_each_node"].(bool), - Arguments: JobCommandJobRefArguments(jobRefMap["args"].(string)), + Name: jobRefMap["name"].(string), + GroupName: jobRefMap["group_name"].(string), + Project: jobRefMap["project_name"].(string), + RunForEachNode: jobRefMap["run_for_each_node"].(bool), + Arguments: JobCommandJobRefArguments(jobRefMap["args"].(string)), + ChildNodes: jobRefMap["child_nodes"].(bool), + FailOnDisable: jobRefMap["fail_on_disable"].(bool), + ImportOptions: jobRefMap["import_options"].(bool), + IgnoreNotifications: jobRefMap["ignore_notifications"].(bool), } nodeFiltersI := jobRefMap["node_filters"].([]interface{}) if len(nodeFiltersI) > 1 { @@ -1355,10 +1375,14 @@ func commandToResourceData(command *JobCommand) (map[string]interface{}, error) if command.Job != nil { jobRefConfigI := map[string]interface{}{ - "name": command.Job.Name, - "group_name": command.Job.GroupName, - "run_for_each_node": command.Job.RunForEachNode, - "args": command.Job.Arguments, + "name": command.Job.Name, + "group_name": command.Job.GroupName, + "run_for_each_node": command.Job.RunForEachNode, + "args": command.Job.Arguments, + "child_nodes": command.Job.ChildNodes, + "fail_on_disable": command.Job.FailOnDisable, + "import_options": command.Job.ImportOptions, + "ignore_notifications": command.Job.IgnoreNotifications, } if command.Job.NodeFilter != nil { nodeFilterConfigI := map[string]interface{}{ diff --git a/rundeck/resource_job_test.go b/rundeck/resource_job_test.go index 7437741e1..01f112e02 100644 --- a/rundeck/resource_job_test.go +++ b/rundeck/resource_job_test.go @@ -70,6 +70,30 @@ func TestAccJob_cmd_nodefilter(t *testing.T) { }) } +func TestAccJob_cmd_referred_job(t *testing.T) { + var job JobDetail + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccJobCheckDestroy(&job), + Steps: []resource.TestStep{ + { + Config: testAccJobConfig_cmd_referred_job, + Check: resource.ComposeTestCheckFunc( + testAccJobCheckExists("rundeck_job.target_test_job", &job), + func(s *terraform.State) error { + if expected := "target_references_job"; job.Name != expected { + return fmt.Errorf("wrong name; expected %v, got %v", expected, job.Name) + } + return nil + }, + ), + }, + }, + }) +} + func TestOchestrator_high_low(t *testing.T) { var job JobDetail @@ -420,6 +444,63 @@ resource "rundeck_job" "test" { } ` +const testAccJobConfig_cmd_referred_job = ` +resource "rundeck_project" "source_test" { + name = "source_project" + description = "Source project for referred job acceptance tests" + + resource_model_source { + type = "file" + config = { + format = "resourcexml" + file = "/tmp/terraform-acc-tests.xml" + } + } +} +resource "rundeck_project" "target_test" { + name = "target_project" + description = "Target project for job acceptance tests" + + resource_model_source { + type = "file" + config = { + format = "resourcexml" + file = "/tmp/terraform-acc-tests.xml" + } + } +} +resource "rundeck_job" "source_test_job" { + project_name = "${rundeck_project.source_test.name}" + name = "source_test_job" + description = "A basic job" + execution_enabled = true + option { + name = "foo" + default_value = "bar" + } +} +resource "rundeck_job" "target_test_job" { + project_name = "${rundeck_project.target_test.name}" + name = "target_references_job" + description = "A job referencing another job" + execution_enabled = true + option { + name = "foo" + default_value = "bar" + command { + job { + name = "${rundeck_job.source_test_job.name}" + group_name = "${rundeck_project.target_test.name}" + run_for_each_node = true + child_nodes = true + fail_on_disable = true + ignore_notifications = true + import_options = true + } + } +} +` + const testAccJobConfig_noNodeFilterQuery = ` resource "rundeck_project" "test" { name = "terraform-acc-test-job-node-filter"