-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathhealth_checker_security.yml
121 lines (106 loc) · 5.38 KB
/
health_checker_security.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
###############################################################################
# © Copyright IBM Corporation 2020, 2021
###############################################################################
- name: Setup Health Checker security.
hosts: zos_host
gather_facts: false
environment: "{{ environment_vars }}"
vars:
user_id: "{{ user_id | default('IBMUSER') }}"
tasks:
- name: Get sysname.
ansible.builtin.command:
cmd: "sysvar SYSNAME"
changed_when: false
register: sysname
- name: Start Health Check
ibm.ibm_zos_core.zos_operator:
cmd: "S HZSPROC"
- name: Print sysname.
ansible.builtin.debug:
var: sysname.stdout
- name: Check if HZS.<sysname>.*.*.MESSAGES is already defined in RACF. Define it if not.
block:
- name: Check if HZS.<sysname>.*.*.MESSAGES profile is already defined in RACF.
ibm.ibm_zos_core.zos_tso_command:
commands: "RLIST XFACILIT HZS.{{ sysname.stdout }}.*.*.MESSAGES"
register: messages_check
changed_when: false
rescue:
- name: Define HZS.<sysname>.*.*.MESSAGES profile in RACF.
ibm.ibm_zos_core.zos_tso_command:
commands: "RDEFINE XFACILIT HZS.{{ sysname.stdout }}.*.*.MESSAGES UACC(NONE)"
when: messages_check.output[0].rc == 4
notify: Setropts refresh
- name: Check if HZS.<sysname>.*.*.RUN is already defined in RACF. Define it if not.
block:
- name: Check if HZS.<sysname>.*.*.RUN profile is already defined in RACF.
ibm.ibm_zos_core.zos_tso_command:
commands: "RLIST XFACILIT HZS.{{ sysname.stdout }}.*.*.RUN"
register: run_check
changed_when: false
rescue:
- name: Define HZS.<sysname>.*.*.RUN profile in RACF.
ibm.ibm_zos_core.zos_tso_command:
commands: "RDEFINE XFACILIT HZS.{{ sysname.stdout }}.*.*.RUN UACC(NONE)"
when: run_check.output[0].rc == 4
notify: Setropts refresh
- name: Check if HZS.<sysname>.*.*.QUERY is already defined in RACF. Define it if not.
block:
- name: Check if HZS.<sysname>.*.*.QUERY profile is already defined in RACF.
ibm.ibm_zos_core.zos_tso_command:
commands: "RLIST XFACILIT HZS.{{ sysname.stdout }}.*.*.QUERY"
register: query_check
changed_when: false
rescue:
- name: Define HZS.<sysname>.*.*.QUERY profile in RACF.
ibm.ibm_zos_core.zos_tso_command:
commands: "RDEFINE XFACILIT HZS.{{ sysname.stdout }}.*.*.QUERY UACC(NONE)"
when: query_check.output[0].rc == 4
notify: Setropts refresh
- name: Check if the given user has correct permissions, set them correctly if they don't.
block:
- name: 'Search for existing permissions for the given user. Fail out to rescue if not set correctly.'
ibm.ibm_zos_core.zos_tso_command:
commands: "SEARCH USER({{ user_id }}) CLASS(XFACILIT)"
register: search_perms
changed_when: false
failed_when:
- search_perms.output[0].content | regex_search('HZS\\.' + sysname.stdout + '\\.\\*\\.\\*\\.MESSAGES') is none
- search_perms.output[0].content | regex_search('HZS\\.' + sysname.stdout + '\\.\\*\\.\\*\\.RUN') is none
- search_perms.output[0].content | regex_search('HZS\\.' + sysname.stdout + '\\.\\*\\.\\*\\.QUERY') is none
rescue:
- name: Print the given user's current permissions.
ansible.builtin.debug:
msg: "{{ search_perms.output[0].content }}"
- name: 'Permit read access for HZS.<sysname>.*.*.MESSAGES to {{ user_id }}.'
ibm.ibm_zos_core.zos_tso_command:
commands: "PERMIT HZS.{{ sysname.stdout }}.*.*.MESSAGES CLASS(XFACILIT) ID({{ user_id }}) ACCESS(READ)"
when: search_perms.output[0].content | regex_search('HZS\\.' + sysname.stdout + '\\.\\*\\.\\*\\.MESSAGES') is none
notify: Setropts refresh
- name: 'Permit update access for HZS.<sysname>.*.*.RUN to {{ user_id }}.'
ibm.ibm_zos_core.zos_tso_command:
commands: "PERMIT HZS.{{ sysname.stdout }}.*.*.RUN CLASS(XFACILIT) ID({{ user_id }}) ACCESS(UPDATE)"
when: search_perms.output[0].content | regex_search('HZS\\.' + sysname.stdout + '\\.\\*\\.\\*\\.RUN') is none
notify: Setropts refresh
- name: 'Permit read access for HZS.<sysname>.*.*.QUERY to {{ user_id }}.'
ibm.ibm_zos_core.zos_tso_command:
commands: "PERMIT HZS.{{ sysname.stdout }}.*.*.QUERY CLASS(XFACILIT) ID({{ user_id }}) ACCESS(READ)"
when: search_perms.output[0].content | regex_search('HZS\\.' + sysname.stdout + '\\.\\*\\.\\*\\.QUERY') is none
notify: Setropts refresh
handlers:
- name: Setropts refresh
block:
- name: Setropts refresh
ibm.ibm_zos_core.zos_tso_command:
commands:
- "SETROPTS CLASSACT(XFACILIT)"
- "SETROPTS RACLIST(XFACILIT) REFRESH"
- name: Search again for permissions for the given user.
ibm.ibm_zos_core.zos_tso_command:
commands: "SEARCH USER({{ user_id }}) CLASS(XFACILIT)"
register: search_perms
changed_when: false
- name: Print the given user's permissions afterwards for visual confirmation.
ansible.builtin.debug:
msg: "{{ search_perms.output[0].content }}"