manage undefined vars for loadbalancing

This commit is contained in:
Smaine Kahlouch 2015-12-15 16:51:55 +01:00
parent 43afd42f59
commit c91a3183d3
3 changed files with 4 additions and 2 deletions

View file

@ -14,7 +14,7 @@
regexp: ".*{{ apiserver_loadbalancer_domain_name }}$"
line: "{{ loadbalancer_apiserver.address }} lb-apiserver.kubernetes.local"
state: present
when: loadbalancer_apiserver is defined
when: loadbalancer_apiserver is defined and apiserver_loadbalancer_domain_name is defined
- name: clean hosts file
lineinfile:

View file

@ -15,7 +15,7 @@ spec:
{% if inventory_hostname in groups['kube-master'] %}
- --master=http://127.0.0.1:8080
{% else %}
{% if loadbalancer_apiserver.address is defined | default('') %}
{% if loadbalancer_apiserver is defined and apiserver_loadbalancer_domain_name is defined %}
- --master=https://{{ apiserver_loadbalancer_domain_name }}:{{ loadbalancer_apiserver.port }}
{% else %}
- --master=https://{{ groups['kube-master'][0] }}:{{ kube_apiserver_port }}

View file

@ -10,7 +10,9 @@ subjectAltName = @alt_names
DNS.1 = kubernetes
DNS.2 = kubernetes.default
DNS.3 = kubernetes.default.svc.{{ dns_domain }}
{% if loadbalancer_apiserver is defined and apiserver_loadbalancer_domain_name is defined %}
DNS.4 = {{ apiserver_loadbalancer_domain_name }}
{% endif %}
{% for host in groups['kube-master'] %}
IP.{{ loop.index }} = {{ hostvars[host]['ip'] | default(hostvars[host]['ansible_default_ipv4']['address']) }}
{% endfor %}