Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove roles for simple commands #287

Merged
merged 10 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ JOB_CARD }}
//HZSPRINT EXEC PGM=HZSPRNT,TIME=1440,REGION=0M,PARMDD=SYSIN
//SYSIN DD *,DLM='@@'
CHECK({{ hc_check }})
CHECK(IBMRACF,RACF_CERTIFICATE_EXPIRATION)
,EXCEPTIONS
@@
//SYSOUT DD SYSOUT=A,DCB=(LRECL=256)
Expand Down
5 changes: 5 additions & 0 deletions ibm_concert/cert_renewal/inventories/host_vars/zos_host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ ZOAU: "path_to_zoau"
# variable`ansible_python_interpreter`
################################################################################
ansible_python_interpreter: "{{ PYZ }}/bin/python3"

# varibles for templates
JOB_CARD: |-
//HZSPRINT JOB ,
// MSGCLASS=H,MSGLEVEL=(1,1),CLASS=A
69 changes: 32 additions & 37 deletions ibm_concert/cert_renewal/renew_cert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,17 @@
register: playbook_tmp_dir

- block:
- ansible.builtin.include_role:
name: issue_operator_cmd
vars:
task_description: 'Run Health Checker'
command: "F HZSPROC,RUN,CHECK=(IBMRACF,RACF_CERTIFICATE_EXPIRATION)"

- ansible.builtin.include_role:
name: print_hc_buffer
vars:
hc_check: 'IBMRACF,RACF_CERTIFICATE_EXPIRATION'
- name: Run Health Checker
ibm.ibm_zos_core.zos_operator:
cmd: "F HZSPROC,RUN,CHECK=(IBMRACF,RACF_CERTIFICATE_EXPIRATION)"
register: zos_operator_output

- name: Get expiring certs report for IBMRACF,RACF_CERTIFICATE_EXPIRATION
ibm.ibm_zos_core.zos_job_submit:
src: '{{ playbook_dir }}/HZSPRINT.J2'
location: local
use_template: true
register: hc_job_output

- name: Search for {{cert_label}} in report
ansible.builtin.set_fact:
Expand Down Expand Up @@ -159,45 +160,39 @@
- ansible.builtin.debug:
var: cert_args

- ansible.builtin.include_role:
name: issue_tso_cmd
vars:
task_description: 'Back up current certificate'
command:
- name: Back up current certificate
ibm.ibm_zos_core.zos_tso_command:
commands:
- RACDCERT EXPORT(LABEL('{{cert_label}}')) DSN('{{ ansible_user }}.CERT.{{cert_type}}.BACKUP.{{today}}') {{cert_type}}
- RACDCERT CHECKCERT('{{ ansible_user }}.CERT.{{cert_type}}.BACKUP.{{today}}')
when: not cert_type == 'USER'

- ansible.builtin.include_role:

name: issue_tso_cmd
vars:
task_description: 'Back up current certificate'
command:
register: tso_cmd_output

- name: Back up current certificate
ibm.ibm_zos_core.zos_tso_command:
commands:
- RACDCERT EXPORT(LABEL('{{cert_label}}')) ID({{owner_id}}) DSN('{{ ansible_user }}.CERT.{{cert_type}}.BACKUP.{{today}}')
- RACDCERT CHECKCERT('{{ ansible_user }}.CERT.{{cert_type}}.BACKUP.{{today}}') ID({{owner_id}})
when: cert_type == 'USER'
register: tso_cmd_output

- ansible.builtin.set_fact:
random_str: "{{lookup('community.general.random_string', length=3, special=false)}}"

- ansible.builtin.include_role:
name: issue_tso_cmd
vars:
task_description: 'Rekey and Generate new cert request for {{cert_type}}'
command:
- name: Rekey and Generate new cert request for {{cert_type}}
ibm.ibm_zos_core.zos_tso_command:
commands:
- RACDCERT {{cert_type}} REKEY(LABEL('{{cert_label}}')) WITHLABEL('{{cert_label[:-3]}}{{random_str}}') NOTAFTER(DATE({{expiry_date}}))
- RACDCERT {{cert_type}} ROLLOVER(LABEL('{{cert_label}}')) NEWLABEL('{{cert_label[:-3]}}{{random_str}}')
- RACDCERT {{cert_type}} LIST(LABEL('{{cert_label[:-3]}}{{random_str}}'))
- RACDCERT {{cert_type}} DELETE(LABEL('{{ cert_label }}'))
- RACDCERT {{cert_type}} ALTER(LABEL('{{ cert_label[:-3]}}{{random_str}}')) NEWLABEL('{{ cert_label }}')
when: cert_type == 'CERTAUTH'
register: tso_cmd_output

- ansible.builtin.include_role:
name: issue_tso_cmd
vars:
task_description: 'Rekey and Generate new cert request for {{cert_type}}'
command:
- name: Rekey and Generate new cert request for {{cert_type}}
ibm.ibm_zos_core.zos_tso_command:
commands:
- RACDCERT {{cert_type}} REKEY(LABEL('{{cert_label}}')) WITHLABEL('{{cert_label[:-3]}}{{random_str}}') NOTAFTER(DATE({{expiry_date}}))
- RACDCERT {{cert_type}} GENREQ (LABEL('{{cert_label[:-3]}}{{random_str}}')) DSN('{{ ansible_user }}.CSR.{{cert_type}}.{{today}}')
- RACDCERT {{cert_type}} GENCERT('{{ ansible_user }}.CSR.{{cert_type}}.{{today}}') SIGNWITH({{sign_with}} LABEL('{{cert_args.cert_signer}}')) NOTAFTER(DATE({{expiry_date}}))
Expand All @@ -206,12 +201,11 @@
- RACDCERT {{cert_type}} DELETE(LABEL('{{ cert_label }}'))
- RACDCERT {{cert_type}} ALTER(LABEL('{{ cert_label[:-3]}}{{random_str}}')) NEWLABEL('{{ cert_label }}')
when: cert_type == 'SITE'
register: tso_cmd_output

- ansible.builtin.include_role:
name: issue_tso_cmd
vars:
task_description: 'Rekey and Generate new cert request for {{cert_type}}'
command:
- name: Rekey and Generate new cert request for {{cert_type}}
ibm.ibm_zos_core.zos_tso_command:
commands:
- RACDCERT ID({{owner_id}}) REKEY(LABEL('{{cert_label}}')) WITHLABEL('{{cert_label[:-3]}}{{random_str}}') NOTAFTER(DATE({{expiry_date}}))
- RACDCERT ID({{owner_id}}) GENREQ (LABEL('{{cert_label[:-3]}}{{random_str}}')) DSN('{{ ansible_user }}.CSR.{{cert_type}}.{{today}}')
- RACDCERT ID({{owner_id}}) GENCERT('{{ ansible_user }}.CSR.{{cert_type}}.{{today}}') SIGNWITH({{sign_with}} LABEL('{{cert_args.cert_signer}}')) NOTAFTER(DATE({{expiry_date}}))
Expand All @@ -220,6 +214,7 @@
- RACDCERT ID({{owner_id}}) DELETE(LABEL('{{cert_label}}'))
- RACDCERT ID({{owner_id}}) ALTER(LABEL('{{ cert_label[:-3]}}{{random_str}}')) NEWLABEL('{{ cert_label }}')
when: cert_type == 'USER'
register: tso_cmd_output

- name: Save new expiration date
ansible.builtin.set_fact:
Expand Down
53 changes: 0 additions & 53 deletions ibm_concert/cert_renewal/roles/issue_operator_cmd/README.md

This file was deleted.

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions ibm_concert/cert_renewal/roles/issue_operator_cmd/meta/main.yml

This file was deleted.

14 changes: 0 additions & 14 deletions ibm_concert/cert_renewal/roles/issue_operator_cmd/tasks/main.yml

This file was deleted.

This file was deleted.

53 changes: 0 additions & 53 deletions ibm_concert/cert_renewal/roles/issue_tso_cmd/README.md

This file was deleted.

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions ibm_concert/cert_renewal/roles/issue_tso_cmd/meta/main.yml

This file was deleted.

14 changes: 0 additions & 14 deletions ibm_concert/cert_renewal/roles/issue_tso_cmd/tasks/main.yml

This file was deleted.

4 changes: 0 additions & 4 deletions ibm_concert/cert_renewal/roles/issue_tso_cmd/vars/main.yml

This file was deleted.

48 changes: 0 additions & 48 deletions ibm_concert/cert_renewal/roles/print_hc_buffer/README.md

This file was deleted.

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions ibm_concert/cert_renewal/roles/print_hc_buffer/meta/main.yml

This file was deleted.

Loading
Loading