You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
3.3 KiB

  1. ---
  2. - set_fact:
  3. kube_apiserver_count: "{{ groups['kube-master'] | length }}"
  4. - set_fact:
  5. kube_apiserver_address: "{{ ip | default(ansible_default_ipv4['address']) }}"
  6. - set_fact:
  7. kube_apiserver_access_address: "{{ access_ip | default(kube_apiserver_address) }}"
  8. - set_fact:
  9. is_kube_master: "{{ inventory_hostname in groups['kube-master'] }}"
  10. - set_fact:
  11. first_kube_master: "{{ hostvars[groups['kube-master'][0]]['access_ip'] | default(hostvars[groups['kube-master'][0]]['ip'] | default(hostvars[groups['kube-master'][0]]['ansible_default_ipv4']['address'])) }}"
  12. - set_fact:
  13. loadbalancer_apiserver_localhost: false
  14. when: loadbalancer_apiserver is defined
  15. - set_fact:
  16. kube_apiserver_endpoint: |-
  17. {% if not is_kube_master and loadbalancer_apiserver_localhost|default(false) -%}
  18. https://localhost:{{ nginx_kube_apiserver_port|default(kube_apiserver_port) }}
  19. {%- elif is_kube_master -%}
  20. http://127.0.0.1:{{ kube_apiserver_insecure_port }}
  21. {%- else -%}
  22. {%- if loadbalancer_apiserver is defined and loadbalancer_apiserver.port is defined -%}
  23. https://{{ apiserver_loadbalancer_domain_name|default('lb-apiserver.kubernetes.local') }}:{{ loadbalancer_apiserver.port|default(kube_apiserver_port) }}
  24. {%- else -%}
  25. https://{{ first_kube_master }}:{{ kube_apiserver_port }}
  26. {%- endif -%}
  27. {%- endif %}
  28. - set_fact:
  29. etcd_address: "{{ ip | default(ansible_default_ipv4['address']) }}"
  30. - set_fact:
  31. etcd_access_address: "{{ access_ip | default(etcd_address) }}"
  32. - set_fact:
  33. etcd_peer_url: "https://{{ etcd_access_address }}:2380"
  34. - set_fact:
  35. etcd_client_url: "https://{{ etcd_access_address }}:2379"
  36. - set_fact:
  37. etcd_authority: "127.0.0.1:2379"
  38. - set_fact:
  39. etcd_endpoint: "https://{{ etcd_authority }}"
  40. - set_fact:
  41. etcd_access_addresses: |-
  42. {% for item in groups['etcd'] -%}
  43. https://{{ hostvars[item]['access_ip'] | default(hostvars[item]['ip'] | default(hostvars[item]['ansible_default_ipv4']['address'])) }}:2379{% if not loop.last %},{% endif %}
  44. {%- endfor %}
  45. - set_fact:
  46. etcd_access_endpoint: "{% if etcd_multiaccess|default(true) %}{{ etcd_access_addresses }}{% else %}{{ etcd_endpoint }}{% endif %}"
  47. - set_fact:
  48. etcd_member_name: |-
  49. {% for host in groups['etcd'] %}
  50. {% if inventory_hostname == host %}{{"etcd"+loop.index|string }}{% endif %}
  51. {% endfor %}
  52. - set_fact:
  53. etcd_peer_addresses: |-
  54. {% for item in groups['etcd'] -%}
  55. {{ "etcd"+loop.index|string }}=https://{{ hostvars[item].access_ip | default(hostvars[item].ip | default(hostvars[item].ansible_default_ipv4['address'])) }}:2380{% if not loop.last %},{% endif %}
  56. {%- endfor %}
  57. - set_fact:
  58. is_etcd_master: "{{ inventory_hostname in groups['etcd'] }}"
  59. - set_fact:
  60. etcd_after_v3: etcd_version | version_compare("v3.0.0", ">=")
  61. - set_fact:
  62. etcd_container_bin_dir: "{% if etcd_after_v3 %}/usr/local/bin/{% else %}/{% endif %}"
  63. - set_fact:
  64. peer_with_calico_rr: "{{ 'calico-rr' in groups and groups['calico-rr']|length > 0 }}"
  65. - name: check if atomic host
  66. stat:
  67. path: /run/ostree-booted
  68. register: ostree
  69. - set_fact:
  70. is_atomic: "{{ ostree.stat.exists }}"
  71. - set_fact:
  72. kube_cert_group: "kube"
  73. when: is_atomic
  74. - include: set_resolv_facts.yml
  75. tags: [bootstrap-os, resolvconf, facts]