main.yml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. ---
  2. - fail:
  3. msg: "openshift_ca_host variable must be defined for this role"
  4. when: openshift_ca_host is not defined
  5. - name: Install the base package for admin tooling
  6. action: >
  7. {{ ansible_pkg_mgr }}
  8. name={{ openshift.common.service_type }}{{ openshift_version }}
  9. state=present
  10. when: not openshift.common.is_containerized | bool
  11. register: install_result
  12. delegate_to: "{{ openshift_ca_host }}"
  13. run_once: true
  14. - name: Reload generated facts
  15. openshift_facts:
  16. when: install_result | changed
  17. delegate_to: "{{ openshift_ca_host }}"
  18. run_once: true
  19. - name: Create openshift_ca_config_dir if it does not exist
  20. file:
  21. path: "{{ openshift_ca_config_dir }}"
  22. state: directory
  23. delegate_to: "{{ openshift_ca_host }}"
  24. run_once: true
  25. - name: Determine if CA must be created
  26. stat:
  27. path: "{{ openshift_ca_config_dir }}/{{ item }}"
  28. register: g_master_ca_stat_result
  29. with_items:
  30. - ca.crt
  31. - ca.key
  32. delegate_to: "{{ openshift_ca_host }}"
  33. run_once: true
  34. - set_fact:
  35. master_ca_missing: "{{ False in (g_master_ca_stat_result.results
  36. | oo_collect(attribute='stat.exists')
  37. | list) }}"
  38. delegate_to: "{{ openshift_ca_host }}"
  39. run_once: true
  40. - name: Create the master certificates if they do not already exist
  41. command: >
  42. {{ openshift.common.admin_binary }} create-master-certs
  43. --hostnames={{ openshift_master_hostnames | join(',') }}
  44. --master={{ openshift.master.api_url }}
  45. --public-master={{ openshift.master.public_api_url }}
  46. --cert-dir={{ openshift_ca_config_dir }}
  47. --overwrite=false
  48. when: hostvars[openshift_ca_host].master_ca_missing | bool
  49. delegate_to: "{{ openshift_ca_host }}"
  50. run_once: true