main.yml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. ---
  2. - name: Detecting Operating System
  3. stat:
  4. path: /run/ostree-booted
  5. register: ostree_booted
  6. # Locally setup containerized facts for now
  7. - set_fact:
  8. l_is_atomic: "{{ ostree_booted.stat.exists }}"
  9. - set_fact:
  10. l_is_containerized: "{{ (l_is_atomic | bool) or (containerized | default(false) | bool) }}"
  11. l_is_openvswitch_system_container: "{{ (use_openvswitch_system_container | default(use_system_containers) | bool) }}"
  12. l_is_node_system_container: "{{ (use_node_system_container | default(use_system_containers) | bool) }}"
  13. l_is_master_system_container: "{{ (use_master_system_container | default(use_system_containers) | bool) }}"
  14. l_is_etcd_system_container: "{{ (use_etcd_system_container | default(use_system_containers) | bool) }}"
  15. - set_fact:
  16. l_any_system_container: "{{ l_is_etcd_system_container or l_is_openvswitch_system_container or l_is_node_system_container or l_is_master_system_container }}"
  17. - set_fact:
  18. l_etcd_runtime: "{{ 'runc' if l_is_etcd_system_container else 'docker' if l_is_containerized else 'host' }}"
  19. - name: Validate python version
  20. fail:
  21. msg: |
  22. openshift-ansible requires Python 3 for {{ ansible_distribution }};
  23. For information on enabling Python 3 with Ansible, see https://docs.ansible.com/ansible/python_3_support.html
  24. when:
  25. - ansible_distribution == 'Fedora'
  26. - ansible_python['version']['major'] != 3
  27. - r_openshift_facts_ran is not defined
  28. - name: Validate python version
  29. fail:
  30. msg: "openshift-ansible requires Python 2 for {{ ansible_distribution }}"
  31. when:
  32. - ansible_distribution != 'Fedora'
  33. - ansible_python['version']['major'] != 2
  34. - r_openshift_facts_ran is not defined
  35. # Fail as early as possible if Atomic and old version of Docker
  36. - block:
  37. # See https://access.redhat.com/articles/2317361
  38. # and https://github.com/ansible/ansible/issues/15892
  39. # NOTE: the "'s can not be removed at this level else the docker command will fail
  40. # NOTE: When ansible >2.2.1.x is used this can be updated per
  41. # https://github.com/openshift/openshift-ansible/pull/3475#discussion_r103525121
  42. - name: Determine Atomic Host Docker Version
  43. shell: 'CURLY="{"; docker version --format "$CURLY{json .Server.Version}}"'
  44. register: l_atomic_docker_version
  45. - assert:
  46. msg: Installation on Atomic Host requires Docker 1.12 or later. Please upgrade and restart the Atomic Host.
  47. that:
  48. - l_atomic_docker_version.stdout | replace('"', '') | version_compare('1.12','>=')
  49. when:
  50. - l_is_atomic | bool
  51. - r_openshift_facts_ran is not defined
  52. - name: Load variables
  53. include_vars: "{{ item }}"
  54. with_first_found:
  55. - "{{ ansible_distribution }}.yml"
  56. - "default.yml"
  57. - name: Ensure various deps are installed
  58. package: name={{ item }} state=present
  59. with_items: "{{ required_packages }}"
  60. when:
  61. - not l_is_atomic | bool
  62. - r_openshift_facts_ran is not defined
  63. - name: Ensure various deps for running system containers are installed
  64. package: name={{ item }} state=present
  65. with_items: "{{ required_system_containers_packages }}"
  66. when:
  67. - not l_is_atomic | bool
  68. - l_any_system_container | bool
  69. - r_openshift_facts_ran is not defined
  70. - name: Gather Cluster facts and set is_containerized if needed
  71. openshift_facts:
  72. role: common
  73. local_facts:
  74. debug_level: "{{ openshift_debug_level | default(2) }}"
  75. deployment_type: "{{ openshift_deployment_type }}"
  76. deployment_subtype: "{{ openshift_deployment_subtype | default(None) }}"
  77. cluster_id: "{{ openshift_cluster_id | default('default') }}"
  78. hostname: "{{ openshift_hostname | default(None) }}"
  79. ip: "{{ openshift_ip | default(None) }}"
  80. is_containerized: "{{ l_is_containerized | default(None) }}"
  81. is_openvswitch_system_container: "{{ l_is_openvswitch_system_container | default(false) }}"
  82. is_node_system_container: "{{ l_is_node_system_container | default(false) }}"
  83. is_master_system_container: "{{ l_is_master_system_container | default(false) }}"
  84. is_etcd_system_container: "{{ l_is_etcd_system_container | default(false) }}"
  85. etcd_runtime: "{{ l_etcd_runtime }}"
  86. system_images_registry: "{{ system_images_registry | default('') }}"
  87. public_hostname: "{{ openshift_public_hostname | default(None) }}"
  88. public_ip: "{{ openshift_public_ip | default(None) }}"
  89. portal_net: "{{ openshift_portal_net | default(openshift_master_portal_net) | default(None) }}"
  90. http_proxy: "{{ openshift_http_proxy | default(None) }}"
  91. https_proxy: "{{ openshift_https_proxy | default(None) }}"
  92. no_proxy: "{{ openshift_no_proxy | default(None) }}"
  93. generate_no_proxy_hosts: "{{ openshift_generate_no_proxy_hosts | default(True) }}"
  94. no_proxy_internal_hostnames: "{{ openshift_no_proxy_internal_hostnames | default(None) }}"
  95. sdn_network_plugin_name: "{{ os_sdn_network_plugin_name | default(None) }}"
  96. use_openshift_sdn: "{{ openshift_use_openshift_sdn | default(None) }}"
  97. - name: Set repoquery command
  98. set_fact:
  99. repoquery_cmd: "{{ 'dnf repoquery --latest-limit 1 -d 0' if ansible_pkg_mgr == 'dnf' else 'repoquery --plugins' }}"
  100. - name: Register that this already ran
  101. set_fact:
  102. r_openshift_facts_ran: True