#jinja2: trim_blocks:False {%- macro cluster_hosts() -%} {%- for host in groups['k8s_etcd'] -%} https://{{hostvars[host]['ansible_' + k8s_interface].ipv4.address}}:{{etcd_client_port}}{% if not loop.last %},{% endif %} {%- endfor -%} {%- endmacro -%} {%- set x=k8s_apiserver_settings.__setitem__('etcd-servers',cluster_hosts()) -%} [Unit] Description=Kubernetes API Server Documentation=https://github.com/GoogleCloudPlatform/kubernetes [Service] ExecStart={{k8s_bin_dir}}/kube-apiserver \ {%- for setting in k8s_apiserver_settings|sort %} --{{setting}}={{k8s_apiserver_settings[setting]}} {% if not loop.last %}\{% endif %} {%- endfor %} Restart=on-failure RestartSec=5 [Install] WantedBy=multi-user.target