basic_facts.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. ---
  2. - name: Ensure that all non-node hosts are accessible
  3. hosts: oo_masters_to_config:oo_etcd_to_config:oo_lb_to_config:oo_nfs_to_config
  4. any_errors_fatal: true
  5. tasks:
  6. - name: Initialize basic host facts
  7. # l_init_fact_hosts is passed in via play during control-plane-only
  8. # upgrades and scale-up plays; otherwise oo_all_hosts is used.
  9. hosts: "{{ l_init_fact_hosts | default('oo_all_hosts') }}"
  10. tasks:
  11. - name: Detect OS Variant from /etc/os-release
  12. fail:
  13. msg: Atomic Host installations are no longer supported
  14. when: lookup('ini', 'VARIANT_ID type=properties file=/etc/os-release') == 'atomic.host'
  15. # TODO(michaelgugino) remove this line once CI is updated.
  16. - name: set openshift_deployment_type if unset
  17. set_fact:
  18. openshift_deployment_type: "{{ deployment_type }}"
  19. openshift_is_atomic: False
  20. when:
  21. - openshift_deployment_type is undefined
  22. - deployment_type is defined
  23. - name: Read API URL from infra config
  24. hosts: "{{ l_init_fact_hosts | default('nodes') }}"
  25. tasks:
  26. - name: Read cluster config
  27. k8s_facts:
  28. kubeconfig: "{{ kubeconfig_path }}"
  29. kind: Infrastructure
  30. name: cluster
  31. register: clustercfg
  32. when: kubeconfig_path is defined
  33. until:
  34. - clustercfg.resources is defined
  35. - clustercfg.resources | length > 0
  36. - clustercfg.resources[0].status is defined
  37. - clustercfg.resources[0].status.apiServerURL is defined
  38. retries: 36
  39. delay: 5
  40. delegate_to: localhost
  41. - name: Set fact openshift_api_prefix
  42. set_fact:
  43. openshift_api_prefix: "{{ clustercfg.resources[0].status.apiServerURL.split(':')[0:-1] | join(':') }}"
  44. - name: Set worker openshift_bootstrap_endpoint if not already defined
  45. hosts: "{{ l_init_fact_hosts | default('nodes') }}:!masters:!bootstrap"
  46. tasks:
  47. - set_fact:
  48. openshift_bootstrap_endpoint: "{{ openshift_api_prefix }}:22623/config/worker"
  49. when:
  50. - kubeconfig_path is defined
  51. - openshift_bootstrap_endpoint is not defined
  52. - name: Set master openshift_bootstrap_endpoint if not already defined
  53. hosts: "{{ l_init_fact_hosts | default('nodes') }}:&masters"
  54. tasks:
  55. - set_fact:
  56. openshift_bootstrap_endpoint: "{{ openshift_api_prefix }}:22623/config/master"
  57. when:
  58. - kubeconfig_path is defined
  59. - openshift_bootstrap_endpoint is not defined
  60. - name: Read in openshift-install
  61. hosts: "{{ l_init_fact_hosts | default('nodes') }}"
  62. tasks:
  63. - slurp:
  64. src: "{{ openshift_install_config_path }}"
  65. register: openshift_install_config_reg
  66. delegate_to: localhost
  67. when: openshift_install_config_path is defined
  68. - name: 'set openshift_install_config if path is defined'
  69. set_fact:
  70. openshift_install_config: "{{ openshift_install_config_reg['content'] | b64decode | from_yaml }}"
  71. when: openshift_install_config_path is defined
  72. - name: Set worker openshift_bootstrap_endpoint if not already defined
  73. hosts: "{{ l_init_fact_hosts | default('nodes') }}:!masters:!bootstrap"
  74. tasks:
  75. - set_fact:
  76. openshift_bootstrap_endpoint: "https://api.{{ openshift_install_config['metadata']['name'] }}.{{ openshift_install_config['baseDomain'] }}:22623/config/worker"
  77. when:
  78. - openshift_install_config_path is defined
  79. - openshift_bootstrap_endpoint is not defined
  80. - name: Set master openshift_bootstrap_endpoint if not already defined
  81. hosts: "{{ l_init_fact_hosts | default('nodes') }}:&masters"
  82. tasks:
  83. - set_fact:
  84. openshift_bootstrap_endpoint: "https://api.{{ openshift_install_config['metadata']['name'] }}.{{ openshift_install_config['baseDomain'] }}:22623/config/master"
  85. when:
  86. - openshift_install_config_path is defined
  87. - openshift_bootstrap_endpoint is not defined