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.

56 lines
3.0 KiB

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