servicenow.itsm.attachment_upload module -- Upload attachment to the selected table
This module is part of the servicenow.itsm collection (version 2.7.0).
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install servicenow.itsm
.
To use it in a playbook, specify: servicenow.itsm.attachment_upload
.
New in servicenow.itsm 2.2.0
Upload the attachment to the selected table using table name and table sys_id.
Name of the attachment serves as a unique identifier. If an attachment with a certain name already exists, but the content is different, the attachment to be uploaded will overwrite the existing attachment. If an attachment with a certain name already exists and the content is the same, the attachment will not be uploaded.
Parameter
Comments
attachments
list
/ elements=dictionary
added in servicenow.itsm 1.2.0
ServiceNow attachments.
name
string
Name of the file to be uploaded.
Serves as unique identifier.
If not specified, the module will use path 's base name.
path
string
/ required
Path to the file to be uploaded.
type
string
MIME type of the file to be attached.
If not specified, the module will try to guess the file's type from its extension.
instance
dictionary
ServiceNow instance information.
access_token
string
added in servicenow.itsm 2.3.0
Access token obtained via OAuth authentication.
If not set, the value of the SN_ACCESS_TOKEN
environment variable will be used.
api_path
string
added in servicenow.itsm 2.4.0
Change the API endpoint of SNOW instance from default 'api/now'.
Default: "api/now"
client_id
string
ID of the client application used for OAuth authentication.
If not set, the value of the SN_CLIENT_ID
environment variable will be used.
If provided, it requires client_secret .
client_secret
string
Secret associated with client_id . Used for OAuth authentication.
If not set, the value of the SN_CLIENT_SECRET
environment variable will be used.
If provided, it requires client_id .
custom_headers
dictionary
added in servicenow.itsm 2.4.0
A dictionary containing any extra headers which will be passed with the request.
grant_type
string
added in servicenow.itsm 1.1.0
Grant type used for OAuth authentication.
If not set, the value of the SN_GRANT_TYPE
environment variable will be used.
Since version 2.3.0, it no longer has a default value in the argument specifications.
If not set by any means, the default value (that is, password ) will be set internally to preserve backwards compatibility.
Choices:
"password"
"refresh_token"
host
string
/ required
The ServiceNow host name.
If not set, the value of the SN_HOST
environment variable will be used.
password
string
Password used for authentication.
If not set, the value of the SN_PASSWORD
environment variable will be used.
Required when using basic authentication or when grant_type=password .
refresh_token
string
added in servicenow.itsm 1.1.0
Refresh token used for OAuth authentication.
If not set, the value of the SN_REFRESH_TOKEN
environment variable will be used.
Required when grant_type=refresh_token .
timeout
float
Timeout in seconds for the connection with the ServiceNow instance.
If not set, the value of the SN_TIMEOUT
environment variable will be used.
username
string
Username used for authentication.
If not set, the value of the SN_USERNAME
environment variable will be used.
Required when using basic authentication or when grant_type=password .
validate_certs
boolean
added in servicenow.itsm 2.3.0
If host's certificate is validated or not.
Choices:
table_name
string
/ required
Table type to attach the file to.
table_sys_id
string
/ required
Record to attach the file to.
- name : Upload attachment to table
servicenow.itsm.attachment_upload :
instance :
host : https://instance_id.service-now.com
username : user
password : pass
table_name : incident
table_sys_id : 003a3ef24ff1120031577d2ca310c74b
attachments :
- path : path/to/attachment1.txt
name : attachment1
- path : path/to/attachment2.txt
name : attachment2
The following are the fields unique to this module:
Key
Description
records
list
/ elements=dictionary
List of attachments that were uploaded, overwritten or unchanged
Returned: success
Sample: {"average_image_color": "", "chunk_size_bytes": "700000", "compressed": "true", "content_type": "text/plain", "download_link": "https://dev139037.service-now.com/api/now/attachment/f2d5cb9647222110afc6fa37536d4361/file", "file_name": "sample_file2.txt", "hash": "f52a678046a6f06e5fca54b4c535b210f29cbaf1134f2b75197cf47078621902", "image_height": "", "image_width": "", "size_bytes": "210", "size_compressed": "207", "state": "pending", "sys_created_by": "admin", "sys_created_on": "2023-05-04 08:53:07", "sys_id": "f2d5cb9647222110afc6fa37536d4361", "sys_mod_count": "0", "sys_tags": "", "sys_updated_by": "admin", "sys_updated_on": "2023-05-04 08:53:07", "table_name": "incident", "table_sys_id": "7cd58f1647222110afc6fa37536d43ed"}
Polona Mihalič (@PolonaM)