facts.yml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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 host facts
  7. hosts: oo_all_hosts
  8. tasks:
  9. - name: load openshift_facts module
  10. include_role:
  11. name: openshift_facts
  12. static: yes
  13. # TODO: Should this role be refactored into health_checks??
  14. - name: Run openshift_sanitize_inventory to set variables
  15. include_role:
  16. name: openshift_sanitize_inventory
  17. - name: Detecting Operating System from ostree_booted
  18. stat:
  19. path: /run/ostree-booted
  20. register: ostree_booted
  21. # Locally setup containerized facts for now
  22. - name: initialize_facts set fact l_is_atomic
  23. set_fact:
  24. l_is_atomic: "{{ ostree_booted.stat.exists }}"
  25. - name: initialize_facts set fact for containerized and l_is_*_system_container
  26. set_fact:
  27. l_is_containerized: "{{ (l_is_atomic | bool) or (containerized | default(false) | bool) }}"
  28. l_is_openvswitch_system_container: "{{ (openshift_use_openvswitch_system_container | default(openshift_use_system_containers | default(false)) | bool) }}"
  29. l_is_master_system_container: "{{ (openshift_use_master_system_container | default(openshift_use_system_containers | default(false)) | bool) }}"
  30. l_is_etcd_system_container: "{{ (openshift_use_etcd_system_container | default(openshift_use_system_containers | default(false)) | bool) }}"
  31. - name: initialize_facts set fact for l_etcd_runtime
  32. set_fact:
  33. l_etcd_runtime: "{{ 'runc' if l_is_etcd_system_container else 'docker' if l_is_containerized else 'host' }}"
  34. # TODO: Should this be moved into health checks??
  35. # Seems as though any check that happens with a corresponding fail should move into health_checks
  36. - name: Validate python version - ans_dist is fedora and python is v3
  37. fail:
  38. msg: |
  39. openshift-ansible requires Python 3 for {{ ansible_distribution }};
  40. For information on enabling Python 3 with Ansible, see https://docs.ansible.com/ansible/python_3_support.html
  41. when:
  42. - ansible_distribution == 'Fedora'
  43. - ansible_python['version']['major'] != 3
  44. # TODO: Should this be moved into health checks??
  45. # Seems as though any check that happens with a corresponding fail should move into health_checks
  46. - name: Validate python version - ans_dist not Fedora and python must be v2
  47. fail:
  48. msg: "openshift-ansible requires Python 2 for {{ ansible_distribution }}"
  49. when:
  50. - ansible_distribution != 'Fedora'
  51. - ansible_python['version']['major'] != 2
  52. # TODO: Should this be moved into health checks??
  53. # Seems as though any check that happens with a corresponding fail should move into health_checks
  54. # Fail as early as possible if Atomic and old version of Docker
  55. - when:
  56. - l_is_atomic | bool
  57. block:
  58. # See https://access.redhat.com/articles/2317361
  59. # and https://github.com/ansible/ansible/issues/15892
  60. # NOTE: the "'s can not be removed at this level else the docker command will fail
  61. # NOTE: When ansible >2.2.1.x is used this can be updated per
  62. # https://github.com/openshift/openshift-ansible/pull/3475#discussion_r103525121
  63. - name: Determine Atomic Host Docker Version
  64. shell: 'CURLY="{"; docker version --format "$CURLY{json .Server.Version}}"'
  65. register: l_atomic_docker_version
  66. - name: assert atomic host docker version is 1.12 or later
  67. assert:
  68. that:
  69. - l_atomic_docker_version.stdout | replace('"', '') | version_compare('1.12','>=')
  70. msg: Installation on Atomic Host requires Docker 1.12 or later. Please upgrade and restart the Atomic Host.
  71. - when:
  72. - not l_is_atomic | bool
  73. block:
  74. - name: Ensure openshift-ansible installer package deps are installed
  75. package:
  76. name: "{{ item }}"
  77. state: present
  78. with_items:
  79. - iproute
  80. - "{{ 'python3-dbus' if ansible_distribution == 'Fedora' else 'dbus-python' }}"
  81. - "{{ 'python3-PyYAML' if ansible_distribution == 'Fedora' else 'PyYAML' }}"
  82. - yum-utils
  83. - name: Ensure various deps for running system containers are installed
  84. package:
  85. name: "{{ item }}"
  86. state: present
  87. with_items:
  88. - atomic
  89. - ostree
  90. - runc
  91. when:
  92. - >
  93. (openshift_use_system_containers | default(False)) | bool
  94. or (openshift_use_etcd_system_container | default(False)) | bool
  95. or (openshift_use_openvswitch_system_container | default(False)) | bool
  96. or (openshift_use_node_system_container | default(False)) | bool
  97. or (openshift_use_master_system_container | default(False)) | bool
  98. - name: Default system_images_registry to a enterprise registry
  99. set_fact:
  100. system_images_registry: "registry.access.redhat.com"
  101. when:
  102. - system_images_registry is not defined
  103. - openshift_deployment_type == "openshift-enterprise"
  104. - name: Default system_images_registry to community registry
  105. set_fact:
  106. system_images_registry: "docker.io"
  107. when:
  108. - system_images_registry is not defined
  109. - openshift_deployment_type == "origin"
  110. - name: Gather Cluster facts and set is_containerized if needed
  111. openshift_facts:
  112. role: common
  113. local_facts:
  114. deployment_type: "{{ openshift_deployment_type }}"
  115. deployment_subtype: "{{ openshift_deployment_subtype | default(None) }}"
  116. cli_image: "{{ osm_image | default(None) }}"
  117. hostname: "{{ openshift_hostname | default(None) }}"
  118. ip: "{{ openshift_ip | default(None) }}"
  119. is_containerized: "{{ l_is_containerized | default(None) }}"
  120. is_openvswitch_system_container: "{{ l_is_openvswitch_system_container | default(false) }}"
  121. is_master_system_container: "{{ l_is_master_system_container | default(false) }}"
  122. is_etcd_system_container: "{{ l_is_etcd_system_container | default(false) }}"
  123. etcd_runtime: "{{ l_etcd_runtime }}"
  124. system_images_registry: "{{ system_images_registry }}"
  125. public_hostname: "{{ openshift_public_hostname | default(None) }}"
  126. public_ip: "{{ openshift_public_ip | default(None) }}"
  127. portal_net: "{{ openshift_portal_net | default(openshift_master_portal_net) | default(None) }}"
  128. http_proxy: "{{ openshift_http_proxy | default(None) }}"
  129. https_proxy: "{{ openshift_https_proxy | default(None) }}"
  130. no_proxy: "{{ openshift_no_proxy | default(None) }}"
  131. generate_no_proxy_hosts: "{{ openshift_generate_no_proxy_hosts | default(True) }}"
  132. - name: Set fact of no_proxy_internal_hostnames
  133. openshift_facts:
  134. role: common
  135. local_facts:
  136. no_proxy_internal_hostnames: "{{ hostvars | oo_select_keys(groups['oo_nodes_to_config']
  137. | union(groups['oo_masters_to_config'])
  138. | union(groups['oo_etcd_to_config'] | default([])))
  139. | oo_collect('openshift.common.hostname') | default([]) | join (',')
  140. }}"
  141. when:
  142. - openshift_http_proxy is defined or openshift_https_proxy is defined
  143. - openshift_generate_no_proxy_hosts | default(True) | bool
  144. - name: initialize_facts set_fact repoquery command
  145. set_fact:
  146. repoquery_cmd: "{{ 'dnf repoquery --latest-limit 1 -d 0' if ansible_pkg_mgr == 'dnf' else 'repoquery --plugins' }}"
  147. - name: initialize_facts set_fact on openshift_docker_hosted_registry_network
  148. set_fact:
  149. openshift_docker_hosted_registry_network: "{{ '' if 'oo_first_master' not in groups else hostvars[groups.oo_first_master.0].openshift.common.portal_net }}"