main.yml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. ---
  2. - name: Ensure python dateutil library is present
  3. package:
  4. name: "{{ 'python3-dateutil' if ansible_distribution == 'Fedora' else 'python-dateutil' }}"
  5. state: present
  6. - name: Check cert expirys on host
  7. openshift_cert_expiry:
  8. warning_days: "{{ openshift_certificate_expiry_warning_days|int }}"
  9. config_base: "{{ openshift_certificate_expiry_config_base }}"
  10. show_all: "{{ openshift_certificate_expiry_show_all|bool }}"
  11. register: check_results
  12. - name: Generate expiration report HTML
  13. run_once: yes
  14. template:
  15. src: cert-expiry-table.html.j2
  16. dest: "{{ openshift_certificate_expiry_html_report_path }}"
  17. delegate_to: localhost
  18. when: >
  19. openshift_certificate_expiry_generate_html_report | bool
  20. or (openshift_certificate_expiry_fail_on_warn | bool and
  21. check_results.warn_certs | bool)
  22. - name: Generate results JSON file
  23. run_once: yes
  24. template:
  25. src: save_json_results.j2
  26. dest: "{{ openshift_certificate_expiry_json_results_path }}"
  27. delegate_to: localhost
  28. when: >
  29. openshift_certificate_expiry_save_json_results | bool
  30. or (openshift_certificate_expiry_fail_on_warn | bool and
  31. check_results.warn_certs | bool)
  32. vars:
  33. json_result_string: "{{ hostvars|oo_cert_expiry_results_to_json(play_hosts) }}"
  34. - name: Fail when certs are near or already expired
  35. fail:
  36. msg: >
  37. Cluster certificates found to be expired or within
  38. {{ openshift_certificate_expiry_warning_days|int }} days of expiring.
  39. You may view the report at {{ openshift_certificate_expiry_html_report_path }}
  40. or {{ openshift_certificate_expiry_json_results_path }}.
  41. when:
  42. - openshift_certificate_expiry_fail_on_warn | bool
  43. - check_results.warn_certs | bool