Ansible Playbook Syntax for a ServiceNow ITSM Collection - Need Help

**Hi. New to Ansible and the ServiceNow ITSM. The question is simple. My playbook fails. It is supposed to use this Help Desk + Automation collection. That webpage has examples. But they do not have any information about my trial ServiceNow instance (usually a Help Desk hostname, a username and a password). I have those three, but when I try to insert them inside the playbooks servicenow.itsm.change_request_task module, I immdeiately get this error ““missing required arguments: host found in instance””. So, it doesnt like it. Yet, if you refer to the README of the ITSM collection , it clearly states it needs the “host” and other data to conenct. But I just have no idea WHERE to insert the three instance parameters into this playbook so it creates a change request in my trial ServiceNow instance. Thx.*.

---
- name: Sample playbook
  hosts: localhost
  gather_facts: true

  tasks:

  - name: Create a change task
    servicenow.itsm.change_request_task:
      host: https://dev336605.service-now.com
      username: redacted
      password: redacted
      configuration_item: Rogue Squadron Launcher
      change_request_number: CHG0000001
      type: planning
      state: open
      assigned_to: fred.luddy
      assignment_group: robot.embedded
      short_description: Implement collision avoidance
      description: "Implement collision avoidance based on the newly installed TOF sensor arrays."
      on_hold: true
      hold_reason: "Waiting for a report from the hardware team"
      planned_start_date: 2025-04-30 08:00:00
      planned_end_date: 2025-05-21 16:00:00
      other:
        approval: approved

Output:

<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/ansible_admin/.ansible/tmp/ansible-tmp-1746023277.5948503-202571-238420869672502/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "assigned_to": "fred.luddy",
            "assignment_group": "robot.embedded",
            "assignment_group_id": null,
            "change_request_id": null,
            "change_request_number": "CHG0000001",
            "change_request_task_mapping": null,
            "close_code": null,
            "close_notes": null,
            "configuration_item": "Rogue Squadron Launcher",
            "configuration_item_id": null,
            "description": "Implement collision avoidance based on the newly installed TOF sensor arrays.",
            "hold_reason": "Waiting for a report from the hardware team",
            "host": "https://dev336605.service-now.com",
            "instance": {
                "access_token": null,
                "api_path": "api/now",
                "client_id": null,
                "client_secret": null,
                "custom_headers": null,
                "grant_type": null,
                "host": null,
                "password": null,
                "refresh_token": null,
                "timeout": null,
                "username": null,
                "validate_certs": true
            },
            "number": null,
            "on_hold": true,
            "other": {
                "approval": "approved"
            },
            "password": "xFWb%1a*c6UO",
            "planned_end_date": "2021-07-21T16:00:00",
            "planned_start_date": "2021-07-15T08:00:00",
            "short_description": "Implement collision avoidance",
            "state": "open",
            "sys_id": null,
            "type": "planning",
            "username": "aes.creator"
        }
    },
    "msg": "missing required arguments: host found in instance"
}

PLAY RECAP **********************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

Your real password is visible in the output you provided. You need to change your password now that you’ve exposed it to the internet.

The ITSM module for SNOW requires you to provide an “instance” that contains the host, username, and a few other parameters. It should resemble

- name: "Create task“
  servicenow.itsm.change_request_task:
    instance:
      host: ""
      grant_type: "password"
      username: ""
      password: ""

The documentation lacks this in the examples but it does list the parameter: servicenow.itsm/docs/servicenow.itsm.change_request_task_module.rst at main · ansible-collections/servicenow.itsm · GitHub

Thanks @mcen1 , let me try that. The uncrackable-super-double-secret password “password” isnt real. I just replaced the real password with that word - it had no bearing. Much appreciated your looking out after my interests as well, much obliged.
Symian.

Thanks, but that didnt help. I dont know what to do. I emailed every single of the 27 ITSM ServiceNow + Ansible Github page contributors mentioned here. I can list this as a defect of documentation (since there is no clear example that uses the instance data along wit the tasks below).

---
- name: Sample playbook
  hosts: localhost
  gather_facts: true

  tasks:

  - name: Create a change task
    servicenow.itsm.change_request_task:
      instance:
        host: https://dev336605.service-now.com
        username: redacted
        password: redacted
        configuration_item: Rogue Squadron Launcher
        change_request_number: CHG0000001
        type: planning
        state: open
        assigned_to: fred.luddy
        assignment_group: robot.embedded
        short_description: Implement collision avoidance
        description: "Implement collision avoidance based on the newly installed TOF sensor arrays."
        on_hold: true
        hold_reason: "Waiting for a report from the hardware team"
        planned_start_date: 2021-07-15 08:00:00
        planned_end_date: 2021-07-21 16:00:00
        other:
          approval: approved
#    register: result

ends with this:

PLAYBOOK: service_now_create_ticket002.yml **************************************************************************************************
1 plays in ./playbooks/service_now_create_ticket002.yml

PLAY [Sample playbook] **********************************************************************************************************************

TASK [Gathering Facts] **********************************************************************************************************************
task path: /etc/ansible/playbooks/service_now_create_ticket002.yml:2
ok: [localhost]

TASK [Create a change task] *****************************************************************************************************************
task path: /etc/ansible/playbooks/service_now_create_ticket002.yml:8
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (servicenow.itsm.change_request_task) module: instance.assigned_to, instance.assignment_group, instance.change_request_number, instance.configuration_item, instance.description, instance.hold_reason, instance.on_hold, instance.other, instance.planned_end_date, instance.planned_start_date, instance.short_description, instance.state, instance.type. Supported parameters include: access_token, api_path, client_id, client_secret, custom_headers, grant_type, host, password, refresh_token, timeout, username, validate_certs."}

PLAY RECAP **********************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

Per the docs, the task should probably be more along the lines of:

- name: Create a change task
    servicenow.itsm.change_request_task:
      instance:
        host: https://dev336605.service-now.com
        username: redacted
        password: redacted
      configuration_item: Rogue Squadron Launcher
      change_request_number: CHG0000001
      type: planning
      state: open
      assigned_to: fred.luddy
      assignment_group: robot.embedded
      short_description: Implement collision avoidance
      description: "Implement collision avoidance based on the newly installed TOF sensor arrays."
      on_hold: true
      hold_reason: "Waiting for a report from the hardware team"
      planned_start_date: 2021-07-15 08:00:00
      planned_end_date: 2021-07-21 16:00:00
      other:
        approval: approved

Only a few attributes fall under “instance”.

1 Like

@binbashroot Many thanks. that indeed resolved the issue. Have an amazing weekend. Symian. :smiley: