-
Notifications
You must be signed in to change notification settings - Fork 54
/
snow_service_request.yml
executable file
·70 lines (67 loc) · 2.28 KB
/
snow_service_request.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
- name: Update ticket on Service Now
hosts: all
gather_facts: no
connection: local
become: no
tasks:
# - name: create servicenow request if not provided
# snow_record:
# state: present
# table: sc_request
# username: "{{ sn_username }}"
# password: "{{ sn_password }}"
# instance: "{{ sn_instance }}"
# data:
# work_notes: "Ansible Automation - Music store app version: {{ app_version }} deployment started"
# state: 1
# delegate_to: localhost
# register: snow_request
# when: (snow_request_id | default('')) | length == 0
#
# - debug:
# msg: "{{ snow_request }}"
#
# - name: create servicenow request item
# snow_record:
# state: present
# table: sc_req_item
# username: "{{ sn_username }}"
# password: "{{ sn_password }}"
# instance: "{{ sn_instance }}"
# data:
# work_notes: "Ansible Automation - Music store app version: {{ app_version }} deployment started"
# state: 1
# delegate_to: localhost
# register: snow_request_item
# when: (snow_request_id | default('')) | length > 0
#
# - name: set snow_request_id if not provided
# set_fact:
# snow_request_id: "{{ snow_request.record.sys_id }}"
# when: (snow_request_id | default('')) | length == 0
- name: close servicenow request
snow_record:
state: present
table: sc_request
username: "{{ sn_username }}"
password: "{{ sn_password }}"
instance: "{{ sn_instance }}"
number: "{{ snow_request_id }}"
data:
work_notes: "Ansible Automation - Music store app version: {{ app_version }} deployed"
state: 3
delegate_to: localhost
when: (snow_request_id | default('')) | length > 0
- name: close servicenow request item
snow_record:
state: present
table: sc_req_item
username: "{{ sn_username }}"
password: "{{ sn_password }}"
instance: "{{ sn_instance }}"
number: "RITM{{ snow_request_id.split('REQ')[1] }}"
data:
work_notes: "Ansible Automation - Music store app version: {{ app_version }} deployed"
state: 3
delegate_to: localhost
when: (snow_request_id | default('')) | length > 0