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.api
.
New in servicenow.itsm 2.0.0
- Create, delete or update a ServiceNow record from the given resource.
- For more information, refer to the ServiceNow REST Table API documentation at https://docs.servicenow.com/bundle/tokyo-application-development/page/integrate/inbound-rest/concept/c_RESTAPI.html.
This module has a corresponding action plugin.
-
Manage ServiceNow GET requests.
- name: Create a record in table incident with specified short_description (which is read from data)
servicenow.itsm.api:
resource: incident
action: post
data:
short_description: my-incident
register: result
- name: Create a record in table incident with column values set in template, located in Ansible controller file system
servicenow.itsm.api:
resource: incident
action: post
template: '/testing/deployment.j2'
register: result
- name: Update a record with given sys_id in table incident with template, located in Ansible controller file system
servicenow.itsm.api:
resource: incident
action: patch
sys_id: 46b66a40a9fe198101f243dfbc79033d
template: '/testing/deployment.j2'
register: result
- name: Update column short_description (specified in data) in table incident of a record with given sys_id
servicenow.itsm.api:
resource: incident
action: patch
sys_id: 46b66a40a9fe198101f243dfbc79033d
data:
short_description: my-incident-updated
register: result
- name: Delete the resource the table incident with given sys_id
servicenow.itsm.api:
resource: incident
action: delete
sys_id: 46b66a40a9fe198101f243dfbc79033d
register: result
- name: Create a record in the table sc_req_item and set short_description's value to demo-description2
servicenow.itsm.api:
resource: sc_req_item
action: post
data:
short_description: demo-description2
register: result
- name: Create a record in the table sc_req_item and set short_description's value to demo-description2
servicenow.itsm.api:
resource: sc_req_item
action: post
data:
short_description: demo-description2
register: result
- name: create user (object with encrypted fields)
servicenow.itsm.api:
resource: sys_user
action: post
query_params:
sysparm_input_display_value: true
data:
user_name: "demo_username"
user_password: "demo_password"
first_name: "first_name"
last_name: Demouser
department: IT
email: "demo_username@example.com"
title: Demo user
register: user
- name: Create a record in sc_req_item with column values set in template, located in Ansible controller file system
servicenow.itsm.api:
resource: sc_req_item
action: post
template: '/testing/deployment.j2'
register: result
- name: Delete a record by sys_id from table sc_req_item
servicenow.itsm.api:
resource: sc_req_item
action: delete
sys_id: b82adae197201110949235dfe153afec
register: result
- name: Create a record in cmdb service using api_path
servicenow.itsm.api:
api_path: api/now/cmdb/instance/cmdb_ci_linux_server
action: post
data:
attributes:
name: "linux99"
firewall_status: "intranet"
source: "ServiceNow"
The following are the fields unique to this module:
- Tjaž Eržen (@tjazsch)
- Jure Medvešek (@juremedvesek)