main.yml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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: ansible_distribution == 'Fedora' and ansible_python['version']['major'] != 3
  25. - name: Validate python version
  26. fail:
  27. msg: "openshift-ansible requires Python 2 for {{ ansible_distribution }}"
  28. when: ansible_distribution != 'Fedora' and ansible_python['version']['major'] != 2
  29. # Fail as early as possible if Atomic and old version of Docker
  30. - block:
  31. # See https://access.redhat.com/articles/2317361
  32. # and https://github.com/ansible/ansible/issues/15892
  33. # NOTE: the "'s can not be removed at this level else the docker command will fail
  34. # NOTE: When ansible >2.2.1.x is used this can be updated per
  35. # https://github.com/openshift/openshift-ansible/pull/3475#discussion_r103525121
  36. - name: Determine Atomic Host Docker Version
  37. shell: 'CURLY="{"; docker version --format "$CURLY{json .Server.Version}}"'
  38. register: l_atomic_docker_version
  39. - assert:
  40. msg: Installation on Atomic Host requires Docker 1.12 or later. Please upgrade and restart the Atomic Host.
  41. that:
  42. - l_atomic_docker_version.stdout | replace('"', '') | version_compare('1.12','>=')
  43. when: l_is_atomic | bool
  44. - name: Load variables
  45. include_vars: "{{ item }}"
  46. with_first_found:
  47. - "{{ ansible_distribution }}.yml"
  48. - "default.yml"
  49. - name: Ensure various deps are installed
  50. package: name={{ item }} state=present
  51. with_items: "{{ required_packages }}"
  52. when: not l_is_atomic | bool
  53. - name: Ensure various deps for running system containers are installed
  54. package: name={{ item }} state=present
  55. with_items: "{{ required_system_containers_packages }}"
  56. when:
  57. - not l_is_atomic | bool
  58. - l_any_system_container | bool
  59. - name: Gather Cluster facts and set is_containerized if needed
  60. openshift_facts:
  61. role: common
  62. local_facts:
  63. debug_level: "{{ openshift_debug_level | default(2) }}"
  64. deployment_type: "{{ openshift_deployment_type }}"
  65. deployment_subtype: "{{ openshift_deployment_subtype | default(None) }}"
  66. cluster_id: "{{ openshift_cluster_id | default('default') }}"
  67. hostname: "{{ openshift_hostname | default(None) }}"
  68. ip: "{{ openshift_ip | default(None) }}"
  69. is_containerized: "{{ l_is_containerized | default(None) }}"
  70. is_openvswitch_system_container: "{{ l_is_openvswitch_system_container | default(false) }}"
  71. is_node_system_container: "{{ l_is_node_system_container | default(false) }}"
  72. is_master_system_container: "{{ l_is_master_system_container | default(false) }}"
  73. is_etcd_system_container: "{{ l_is_etcd_system_container | default(false) }}"
  74. etcd_runtime: "{{ l_etcd_runtime }}"
  75. system_images_registry: "{{ system_images_registry | default('') }}"
  76. public_hostname: "{{ openshift_public_hostname | default(None) }}"
  77. public_ip: "{{ openshift_public_ip | default(None) }}"
  78. portal_net: "{{ openshift_portal_net | default(openshift_master_portal_net) | default(None) }}"
  79. http_proxy: "{{ openshift_http_proxy | default(None) }}"
  80. https_proxy: "{{ openshift_https_proxy | default(None) }}"
  81. no_proxy: "{{ openshift_no_proxy | default(None) }}"
  82. generate_no_proxy_hosts: "{{ openshift_generate_no_proxy_hosts | default(True) }}"
  83. no_proxy_internal_hostnames: "{{ openshift_no_proxy_internal_hostnames | default(None) }}"
  84. sdn_network_plugin_name: "{{ os_sdn_network_plugin_name | default(None) }}"
  85. use_openshift_sdn: "{{ openshift_use_openshift_sdn | default(None) }}"
  86. - name: Set repoquery command
  87. set_fact:
  88. repoquery_cmd: "{{ 'dnf repoquery --latest-limit 1 -d 0' if ansible_pkg_mgr == 'dnf' else 'repoquery --plugins' }}"