n3pjk / n3pjk.servicenow / 0.0.26 / module / snow_record Manage records in ServiceNow Authors: Tim Rightnour (@garbled1)n3pjk.servicenow.snow_record (0.0.26) — module
Install with ansible-galaxy collection install n3pjk.servicenow:==0.0.26
collections: - name: n3pjk.servicenow version: 0.0.26
Creates, deletes and updates a single record in ServiceNow.
- name: Grab a user record servicenow.servicenow.snow_record: username: ansible_test password: my_password instance: dev99999 state: present number: 62826bf03710200044e0bfc8bcbe5df1 table: sys_user lookup_field: sys_id
- name: Grab a user record using OAuth servicenow.servicenow.snow_record: username: ansible_test password: my_password client_id: "1234567890abcdef1234567890abcdef" client_secret: "Password1!" instance: dev99999 state: present number: 62826bf03710200044e0bfc8bcbe5df1 table: sys_user lookup_field: sys_id
- name: Create an incident servicenow.servicenow.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: Create an incident using host instead of instance servicenow.servicenow.snow_record: username: ansible_test password: my_password host: dev99999.mycustom.domain.com state: present data: short_description: "This is a test incident opened by Ansible" priority: 2
- name: Delete the record we just made servicenow.servicenow.snow_record: username: admin password: xxxxxxx instance: dev99999 state: absent number: "{{new_incident['record']['number']}}"
- name: Delete a non-existant record servicenow.servicenow.snow_record: username: ansible_test password: my_password instance: dev99999 state: absent number: 9872354 failed_when: false
- name: Update an incident servicenow.servicenow.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 servicenow.servicenow.snow_record: username: ansible_test password: my_password instance: dev99999 state: present number: INC0000055 attachment: README.md tags: attach
auth: choices: - basic - oauth - token - okta default: basic description: - The method used to authenticate with the Service Now instance. - Basic authentication uses user name and password. - OAuth authentication uses a client id and secret in addition to basic authentication. - Token authentication uses an externally obtained bearer token, in addition to OAuth authentication. - Okta authentication is a specific method of obtaining a bearer token. - If the vaule is not specified in the task, the value of environment variable C(SN_AUTH) will be used instead. type: str data: description: - key, value pairs of data to load into the record. See Examples. - Required for C(state:present). type: dict host: description: - The ServiceNow hostname. - This value is FQDN for ServiceNow host. - If the value is not specified in the task, the value of environment variable C(SN_HOST) will be used instead. - Mutually exclusive with C(instance). type: str state: choices: - present - absent description: - If C(present) is supplied with a C(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. - C(absent) will delete a record. required: true type: str table: default: incident description: - Table to query for records. required: false type: str token: description: - Bearer token associated with client id and secret. - Can be used in place of client id and secret for OpenID authentication. required: false type: str number: description: - Record number to update. - Required for C(state:absent). required: false type: str instance: description: - The ServiceNow instance name, without the domain, service-now.com. - If the value is not specified in the task, the value of environment variable C(SN_INSTANCE) will be used instead. required: false type: str password: description: - Password for username. - Required whether using Basic, OAuth or OpenID authentication. - If the value is not specified in the task, the value of environment variable C(SN_PASSWORD) will be used instead. required: false type: str username: description: - Name of user for connection to ServiceNow. - Required whether using Basic, OAuth or OpenID authentication. - If the value is not specified in the task, the value of environment variable C(SN_USERNAME) will be used instead. required: false type: str client_id: description: - Client ID generated by ServiceNow. - Required when using OAuth or OpenID authentication, unless token is specified. required: false type: str attachment: description: - Attach a file to the record. required: false type: str lookup_field: default: number description: - Changes the field that C(number) uses to find records. required: false type: str client_secret: description: - Client Secret associated with client id. - Required when using OAuth or OpenID authentication, unless token is specified. required: false type: str
attached_file: description: Details of the file that was attached via C(attachment) returned: when supported type: dict record: description: Record data from Service Now returned: when supported type: dict