Create a Credential for a Job Template
post
/api/v2/job_templates/{id}/credentials/
Make a POST request to this resource with the following credential fields to create a new credential associated with this job template.
name
: Name of this credential. (string, required)description
: Optional description of this credential. (string, default=""
)organization
: (id, default=None
)-
credential_type
: Specify the type of credential you want to create. Refer to the Ansible Tower documentation for details on each type. (id, required) -
inputs
: Enter inputs using either JSON or YAML syntax. Refer to the Ansible Tower documentation for example syntax. (json, default={}
)
Add Credentials for a Job Template:
Make a POST request to this resource with only an id
field to associate an
existing credential with this job template.
Remove Credentials from this Job Template:
Make a POST request to this resource with id
and disassociate
fields to
remove the credential from this job template
without deleting the credential.
Request
Supported Media Types
- application/json
Path Parameters
Root Schema : schema
Example:
{
"credential_type":1,
"inputs":{
"password":"secret",
"username":"bob"
},
"name":"First Cred"
}
Response
Supported Media Types
- application/json
201 Response
Example Response (application/json)
{
"cloud":false,
"created":"2018-02-01T08:00:00.000000Z",
"credential_type":1,
"description":"",
"id":2,
"inputs":{
"password":"$encrypted$",
"username":"bob"
},
"kind":"ssh",
"kubernetes":false,
"managed_by_tower":false,
"modified":"2018-02-01T08:00:00.000000Z",
"name":"First Cred",
"organization":null,
"related":{
"access_list":"/api/v2/credentials/2/access_list/",
"activity_stream":"/api/v2/credentials/2/activity_stream/",
"copy":"/api/v2/credentials/2/copy/",
"credential_type":"/api/v2/credential_types/1/",
"input_sources":"/api/v2/credentials/2/input_sources/",
"object_roles":"/api/v2/credentials/2/object_roles/",
"owner_teams":"/api/v2/credentials/2/owner_teams/",
"owner_users":"/api/v2/credentials/2/owner_users/"
},
"summary_fields":{
"credential_type":{
"description":"",
"id":1,
"name":"Machine"
},
"object_roles":{
"admin_role":{
"description":"Can manage all aspects of the credential",
"id":30,
"name":"Admin"
},
"read_role":{
"description":"May view settings for the credential",
"id":32,
"name":"Read"
},
"use_role":{
"description":"Can use the credential in a job template",
"id":31,
"name":"Use"
}
},
"owners":[
],
"user_capabilities":{
"copy":true,
"delete":true,
"edit":true,
"use":true
}
},
"type":"credential",
"url":"/api/v2/credentials/2/"
}
400 Response
Example Response (application/json)
{
"error":"Cannot assign a Credential of kind `insights`."
}