---
- name: Check cert expirys on host
  openshift_cert_expiry:
    warning_days: "{{ openshift_certificate_expiry_warning_days|int }}"
    config_base: "{{ openshift_certificate_expiry_config_base }}"
    show_all: "{{ openshift_certificate_expiry_show_all|bool }}"
  register: check_results

- name: Generate expiration report HTML
  run_once: yes
  template:
    src: cert-expiry-table.html.j2
    dest: "{{ openshift_certificate_expiry_html_report_path }}"
  delegate_to: localhost
  when: openshift_certificate_expiry_generate_html_report|bool

- name: Generate the result JSON string
  run_once: yes
  set_fact:
    # oo_cert_expiry_results_to_json is a custom filter in role lib_utils
    json_result_string: "{{ hostvars|oo_cert_expiry_results_to_json(play_hosts) }}"
  when: openshift_certificate_expiry_save_json_results|bool

- name: Generate results JSON file
  run_once: yes
  template:
    src: save_json_results.j2
    dest: "{{ openshift_certificate_expiry_json_results_path }}"
  delegate_to: localhost
  when: openshift_certificate_expiry_save_json_results|bool
