Skip to content

Latest commit

 

History

History
437 lines (383 loc) · 19.7 KB

servicenow.itsm.configuration_item_batch_module.rst

File metadata and controls

437 lines (383 loc) · 19.7 KB

servicenow.itsm.configuration_item_batch module -- Manage ServiceNow configuration items in batch mode

This module is part of the servicenow.itsm collection (version 2.4.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.configuration_item_batch.

New in servicenow.itsm 1.2.0

Synopsis

This module has a corresponding action plugin.

Parameters

Parameter

Comments

dataset

list / elements=dictionary / required

List of dictionaries that will be used as a data source.

Each item in a list represents one CMDB item.

id_column_set

list / elements=string / required

Columns that should be used to identify an existing record that we need to update.

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:

  • false

  • true ← (default)

map

dictionary / required

Transformation instructions on how to convert input data to CMDB items.

Keys represent the CMDB item column names and the values are Jinja expressions that extract the value from the source data.

Data is returned as string because ServiceNow API expect this

sys_class_name

string / required

Table name (configuration item type) that we would like to manipulate.

See Also

Examples

- name: Update CMDB with some data
  servicenow.itsm.configuration_item_batch:
    sys_class_name: cmdb_ci_ec2_instance
    id_column_set: vm_inst_id
    dataset:
      - instance_id: 12345
        public_ip_address: 1.2.3.4
        tags:
          Name: my_name
      - instance_id: 54321
        public_ip_address: 4.3.2.1
        tags:
          Name: other_name
    map:
      vm_inst_id: instance_id
      ip_address: public_ip_address
      name: tags.Name

- name: Identify CMDB item using combination of two columns
  servicenow.itsm.configuration_item_batch:
    sys_class_name: cmdb_ci_server
    id_column_set:
      - name
      - ip_address
    dataset: "{{ input_data }}"
    map:
      name: tags.Name
      ip_address: private_ip_address

Return Values

The following are the fields unique to this module:

Key

Description

records

list / elements=string

A list of configuration item records.

Note that the fields of the returned records depend on the configuration item's sys_class_name.

Returning of values added in version 2.0.0.

Returned: success

Sample: [{"asset": {"link": "https://www.example.com/api/now/table/alm_asset/04a96c0d3790200044e0bfc8bcbe5db3", "value": "04a96c0d3790200044e0bfc8bcbe5db3"}, "asset_tag": "P1000503", "assigned": "2019-11-10 07:00:00", "assigned_to": {"link": "https://www.example.comapi/now/table/sys_user/92826bf03710200044e0bfc8bcbe5dbb", "value": "92826bf03710200044e0bfc8bcbe5dbb"}, "assignment_group": "", "checked_in": "", "checked_out": "", "company": {"link": "https://www.example.com/api/now/table/core_company/81fbfe03ac1d55eb286d832de58ae1fd", "value": "81fbfe03ac1d55eb286d832de58ae1fd"}, "cost": "1799.99", "cost_cc": "USD", "cost_center": {"link": "https://www.example.com/api/now/table/cmn_cost_center/d9d0a971c0a80a641c20b13d99a48576", "value": "d9d0a971c0a80a641c20b13d99a48576"}, "delivery_date": "2019-06-09 08:00:00", "department": {"link": "https://www.example.com/api/now/table/cmn_department/221f79b7c6112284005d646b76ab978c", "value": "221f79b7c6112284005d646b76ab978c"}, "due": "", "due_in": "", "gl_account": "", "install_date": "2019-07-28 07:00:00", "install_status": "1", "invoice_number": "", "justification": "", "lease_id": "", "location": {"link": "https://www.example.com/api/now/table/cmn_location/8226baa4ac1d55eb40eb653c02649519", "value": "8226baa4ac1d55eb40eb653c02649519"}, "managed_by": "", "manufacturer": {"link": "https://www.example.com/api/now/table/core_company/b7e9e843c0a80169009a5a485bb2a2b5", "value": "b7e9e843c0a80169009a5a485bb2a2b5"}, "model_id": {"link": "https://www.example.com/api/now/table/cmdb_model/d501454f1b1310002502fbcd2c071334", "value": "d501454f1b1310002502fbcd2c071334"}, "name": "MacBook Pro 15\"", "order_date": "2019-05-13 08:00:00", "owned_by": "", "po_number": "PO100003", "purchase_date": "2019-05-25", "serial_number": "ABE-486-V17263-DO", "skip_sync": "false", "support_group": "", "supported_by": "", "sys_class_name": "cmdb_ci_computer", "sys_class_path": "/!!/!2/!(", "sys_created_by": "admin", "sys_created_on": "2012-02-18 08:14:21", "sys_domain": {"link": "https://www.example.com/api/now/table/sys_user_group/global", "value": "global"}, "sys_domain_path": "/", "sys_id": "00a96c0d3790200044e0bfc8bcbe5db4", "sys_mod_count": "6", "sys_tags": "", "sys_updated_by": "system", "sys_updated_on": "2022-03-18 03:59:41", "unverified": "false", "vendor": {"link": "https://www.example.com/api/now/table/core_company/b7e9e843c0a80169009a5a485bb2a2b5", "value": "b7e9e843c0a80169009a5a485bb2a2b5"}, "warranty_expiration": "2022-07-27"}]

Authors

  • Manca Bizjak (@mancabizjak)
  • Miha Dolinar (@mdolin)
  • Tadej Borovsak (@tadeboro)