Create a Job Template

post

/api/v2/job_templates/

Make a POST request to this resource with the following job template fields to create a new job template:

  • name: Name of this job template. (string, required)
  • description: Optional description of this job template. (string, default="")
  • job_type: (choice)
    • run: Run (default)
    • check: Check
  • inventory: (id, default=``)
  • project: (id, default=``)
  • playbook: (string, default="")
  • scm_branch: Branch to use in job run. Project default used if blank. Only allowed if project allow_override field is set to true. (string, default="")
  • forks: (integer, default=0)
  • limit: (string, default="")
  • verbosity: (choice)
    • 0: 0 (Normal) (default)
    • 1: 1 (Verbose)
    • 2: 2 (More Verbose)
    • 3: 3 (Debug)
    • 4: 4 (Connection Debug)
    • 5: 5 (WinRM Debug)
  • extra_vars: (json, default=``)
  • job_tags: (string, default="")
  • force_handlers: (boolean, default=False)
  • skip_tags: (string, default="")
  • start_at_task: (string, default="")
  • timeout: The amount of time (in seconds) to run before the task is canceled. (integer, default=0)
  • use_fact_cache: If enabled, the service will act as an Ansible Fact Cache Plugin; persisting facts at the end of a playbook run to the database and caching facts for use by Ansible. (boolean, default=False)

  • execution_environment: The container image to be used for execution. (id, default=``)

  • host_config_key: (string, default="")
  • ask_scm_branch_on_launch: (boolean, default=False)
  • ask_diff_mode_on_launch: (boolean, default=False)
  • ask_variables_on_launch: (boolean, default=False)
  • ask_limit_on_launch: (boolean, default=False)
  • ask_tags_on_launch: (boolean, default=False)
  • ask_skip_tags_on_launch: (boolean, default=False)
  • ask_job_type_on_launch: (boolean, default=False)
  • ask_verbosity_on_launch: (boolean, default=False)
  • ask_inventory_on_launch: (boolean, default=False)
  • ask_credential_on_launch: (boolean, default=False)
  • survey_enabled: (boolean, default=False)
  • become_enabled: (boolean, default=False)
  • diff_mode: If enabled, textual changes made to any templated files on the host are shown in the standard output (boolean, default=False)
  • allow_simultaneous: (boolean, default=False)

  • job_slice_count: The number of jobs to slice into at runtime. Will cause the Job Template to launch a workflow if value is greater than 1. (integer, default=1)

  • webhook_service: Service that webhook requests will be accepted from (choice)
    • "": ---------
    • github: GitHub
    • gitlab: GitLab
  • webhook_credential: Personal Access Token for posting back the status to the service API (id, default=``)

Request

Supported Media Types
Body ()
Root Schema : schema
Example:
{
    "ask_inventory_on_launch":true,
    "name":"foobar",
    "organization":"2",
    "playbook":"helloworld.yml",
    "project":"1"
}
Back to Top

Response

Supported Media Types

201 Response

Body
Example Response (application/json)
{
    "allow_simultaneous":false,
    "ask_credential_on_launch":false,
    "ask_diff_mode_on_launch":false,
    "ask_inventory_on_launch":true,
    "ask_job_type_on_launch":false,
    "ask_limit_on_launch":false,
    "ask_scm_branch_on_launch":false,
    "ask_skip_tags_on_launch":false,
    "ask_tags_on_launch":false,
    "ask_variables_on_launch":false,
    "ask_verbosity_on_launch":false,
    "become_enabled":false,
    "created":"2018-02-01T08:00:00.000000Z",
    "custom_virtualenv":null,
    "description":"",
    "diff_mode":false,
    "execution_environment":null,
    "extra_vars":"",
    "force_handlers":false,
    "forks":"0",
    "host_config_key":"",
    "id":"3",
    "inventory":null,
    "job_slice_count":"1",
    "job_tags":"",
    "job_type":"run",
    "last_job_failed":false,
    "last_job_run":null,
    "limit":"",
    "modified":"2018-02-01T08:00:00.000000Z",
    "name":"foobar",
    "next_job_run":null,
    "organization":"1",
    "playbook":"helloworld.yml",
    "project":"1",
    "related":{
        "access_list":"/api/v2/job_templates/3/access_list/",
        "activity_stream":"/api/v2/job_templates/3/activity_stream/",
        "copy":"/api/v2/job_templates/3/copy/",
        "credentials":"/api/v2/job_templates/3/credentials/",
        "instance_groups":"/api/v2/job_templates/3/instance_groups/",
        "jobs":"/api/v2/job_templates/3/jobs/",
        "labels":"/api/v2/job_templates/3/labels/",
        "launch":"/api/v2/job_templates/3/launch/",
        "notification_templates_error":"/api/v2/job_templates/3/notification_templates_error/",
        "notification_templates_started":"/api/v2/job_templates/3/notification_templates_started/",
        "notification_templates_success":"/api/v2/job_templates/3/notification_templates_success/",
        "object_roles":"/api/v2/job_templates/3/object_roles/",
        "organization":"/api/v2/organizations/1/",
        "project":"/api/v2/projects/1/",
        "schedules":"/api/v2/job_templates/3/schedules/",
        "slice_workflow_jobs":"/api/v2/job_templates/3/slice_workflow_jobs/",
        "survey_spec":"/api/v2/job_templates/3/survey_spec/",
        "webhook_key":"/api/v2/job_templates/3/webhook_key/",
        "webhook_receiver":""
    },
    "scm_branch":"",
    "skip_tags":"",
    "start_at_task":"",
    "status":"never updated",
    "summary_fields":{
        "credentials":[
        ],
        "labels":{
            "count":"0",
            "results":[
            ]
        },
        "object_roles":{
            "admin_role":{
                "description":"Can manage all aspects of the job template",
                "id":"36",
                "name":"Admin"
            },
            "execute_role":{
                "description":"May run the job template",
                "id":"37",
                "name":"Execute"
            },
            "read_role":{
                "description":"May view settings for the job template",
                "id":"38",
                "name":"Read"
            }
        },
        "organization":{
            "description":"test-org-desc",
            "id":"1",
            "name":"test-org"
        },
        "project":{
            "allow_override":false,
            "description":"test-proj-desc",
            "id":"1",
            "name":"test-proj",
            "scm_type":"git",
            "status":"never updated"
        },
        "recent_jobs":[
        ],
        "user_capabilities":{
            "copy":true,
            "delete":true,
            "edit":true,
            "schedule":true,
            "start":true
        }
    },
    "survey_enabled":false,
    "timeout":"0",
    "type":"job_template",
    "url":"/api/v2/job_templates/3/",
    "use_fact_cache":false,
    "verbosity":"0",
    "webhook_credential":null,
    "webhook_service":""
}

400 Response

Body
Example Response (application/json)
{
    "ask_scm_branch_on_launch":[
        "Project does not allow overriding branch."
    ]
}

403 Response

Body
Example Response (application/json)
{
    "detail":"You do not have permission to perform this action."
}
Back to Top