On this page
snow_record - Create/Delete/Update records in ServiceNow
New in version 2.5.
Synopsis
- Creates/Deletes/Updates a single record in ServiceNow
Requirements
The below requirements are needed on the host that executes this module.
- python pysnow (pysnow)
Parameters
Parameter | Choices/Defaults | Comments |
---|---|---|
attachment |
Attach a file to the record
|
|
data |
key, value pairs of data to load into the record. See Examples. Required for state:present
|
|
instance
required
|
The service now instance name
|
|
lookup_field | Default:
"number"
|
Changes the field that number uses to find records
|
number |
Record number to update. Required for state:absent
|
|
password
required
|
Password for username
|
|
state
required
|
|
If present is supplied with a number argument, the module will attempt to update the record with the supplied data. If no such record exists, a new one will be created. absent will delete a record.
|
table | Default:
"incident"
|
Table to query for records
|
username
required
|
User to connect to ServiceNow as
|
Examples
- name: Grab a user record
snow_record:
username: ansible_test
password: my_password
instance: dev99999
state: present
number: 62826bf03710200044e0bfc8bcbe5df1
table: sys_user
lookup_field: sys_id
- name: Create an incident
snow_record:
username: ansible_test
password: my_password
instance: dev99999
state: present
data:
short_description: "This is a test incident opened by Ansible"
severity: 3
priority: 2
register: new_incident
- name: Delete the record we just made
snow_record:
username: admin
password: xxxxxxx
instance: dev99999
state: absent
number: "{{new_incident['record']['number']}}"
- name: Delete a non-existant record
snow_record:
username: ansible_test
password: my_password
instance: dev99999
state: absent
number: 9872354
failed_when: false
- name: Update an incident
snow_record:
username: ansible_test
password: my_password
instance: dev99999
state: present
number: INC0000055
data:
work_notes : "Been working all day on this thing."
- name: Attach a file to an incident
snow_record:
username: ansible_test
password: my_password
instance: dev99999
state: present
number: INC0000055
attachment: README.md
tags: attach
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
attached_file
dict
|
when supported |
Details of the file that was attached via attachment
|
record
dict
|
when supported |
Record data from Service Now
|
Status
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
Maintenance
This module is flagged as community which means that it is maintained by the Ansible Community. See Module Maintenance & Support for more info.
For a list of other modules that are also maintained by the Ansible Community, see here.
Author
- Tim Rightnour (@garbled1)
Hint
If you notice any issues in this documentation you can edit this document to improve it.
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.6/modules/snow_record_module.html