Closed markatdxb closed 2 months ago
@tupyy - can you pls check above comment - is that some sort of hack of your repo ? i havent even tried to download the file
@markatdxb Please take a look at intergration tests. https://github.com/ansible-collections/servicenow.itsm/tree/main/tests/integration/targets/itsm_incident_with_mapping/tasks
@markatdxb Please take a look at intergration tests.
@tupyy - can you pls check above comment - is that some sort of hack of your repo ? i havent even tried to download the file
I don't know what it is and there's no way that I download something like that. @seeronline If you have a solution please paste the diff. don't use zip.
@
@markatdxb Please take a look at intergration tests.
@tupyy - can you pls check above comment - is that some sort of hack of your repo ? i havent even tried to download the file
I don't know what it is and there's no way that I download something like that. @seeronline If you have a solution please paste the diff. don't use zip.
seems that some sort of a bot - looking at the seeronline user. you might want to report it to github owners
@markatdxb Please take a look at intergration tests. https://github.com/ansible-collections/servicenow.itsm/tree/main/tests/integration/targets/itsm_incident_with_mapping/tasks
so i correctly understand that integration test file
may code should look like this ?
- name: SNOW - Close incident
servicenow.itsm.incident:
instance:
host: https://{{ snow_instance }}.service-now.com
username: "{{ user }}"
password: "{{ password }}"
sys_id: "{{ sn_rec_sys_id }}"
state: closed
close_notes: Incident is closed as all Content library templates are consistent in all sites
incident_mapping:
close_code:
solved_unknown: Solved (Permanently)
yes
ok tested that with following code - still getting error
- name: SNOW - Close incident
servicenow.itsm.incident:
instance:
host: https://{{ snow_instance }}.service-now.com
username: "{{ user }}"
password: "{{ password }}"
sys_id: "{{ snow_find.record[0].sys_id }}"
state: closed
close_notes: Incident is closed as all Content library templates are consistent in all sites
incident_mapping:
close_code:
solved_unknown: Solved (Permanently)
"msg": "Missing required parameters close_code",
"invocation": {
"module_args": {
"instance": {
"host": "https://server.service-now.com",
"username": "user",
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"api_path": "api/now",
"validate_certs": true,
"grant_type": null,
"client_id": null,
"client_secret": null,
"custom_headers": null,
"refresh_token": null,
"access_token": null,
"timeout": null
},
"sys_id": "012345678901234567890123456789",
"state": "closed",
"close_notes": "Incident is closed as all Content library templates are consistent in all sites",
"incident_mapping": {
"close_code": {
"solved_unknown": "Solved (Permanently)"
},
"state": null,
"hold_reason": null,
"impact": null,
"urgency": null
},
"number": null,
"attachments": null,
"hold_reason": null,
"caller": null,
"short_description": null,
"description": null,
"impact": null,
"urgency": null,
"close_code": null,
"other": null
}
},
"warnings": [
"Encountered unknown value while mapping field close_code."
],
It seems we do have a bug in there. It will need more investigation but you're right. it does not work as intended. But there's a workaround for you:
- name: register
servicenow.itsm.api:
instance:
host: "{{ sn_host }}"
username: "{{ sn_username }}"
password: "{{ sn_password }}"
resource: sys_choice
action: post
data:
name: incident
element: close_code
value: solved_unknown
label: Solved Unknown
After that you can use close the incident as usual:
- name: Close it
servicenow.itsm.incident:
instance:
host: "{{ sn_host }}"
username: "{{ sn_username }}"
password: "{{ sn_password }}"
sys_id: "{{ result.records[0].sys_id }}"
state: closed
close_code: Solved Unknown
close_notes: "close notes"
@markatdxb Hello. After a better look at the code, you need to specify the close_code
in your task. The module will pick up the right value from the mapping that you provided.
- name: SNOW - Close incident
servicenow.itsm.incident:
instance:
host: https://{{ snow_instance }}.service-now.com
username: "{{ user }}"
password: "{{ password }}"
sys_id: "{{ snow_find.record[0].sys_id }}"
state: closed
close_notes: Incident is closed as all Content library templates are consistent in all sites
close_code: solved_unknown
incident_mapping:
close_code:
solved_unknown: Solved (Permanently)
On the other hand, if you don't add the choices to SNow as I've shown above, the close_code will be ignored by ServiceNow.
I'm closing this one because it's not a bug
SUMMARY
Incident_mapping, close_code is in dictionary format, when set, the playbook is failing. There is no example to follow up the correct formatting
ISSUE TYPE
COMPONENT NAME
incident
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE
EXPECTED RESULTS
close the incident
ACTUAL RESULTS