I'm trying to enumerate my eth0
address (set to default, because I read somewhere that eth0 is not always available..). In my template I attempt calling it from the group like so...
[Unit]
Description=Kubernetes Kube Proxy
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
[Service]
ExecStart=/usr/bin/kube-proxy \
--master=https://{{ groups[controller][0]['ansible_default_ipv4']['address'] }}:6443 \
--kubeconfig=/var/lib/kubelet/kubeconfig \
--proxy-mode=iptables \
--v=2
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
This seem like it should be available as when I dump with -debug var=groups
I get....
[18.234.92.196] => {
"groups": {
......
"controller": [
"54.86.253.135",
"52.205.43.24",
"54.210.213.10"
],
"controller.0": [
"54.86.253.135"
],
"controller.1": [
"52.205.43.24"
],
"controller.2": [
"54.210.213.10"
],
......
"name_controller-0": [
"54.86.253.135"
],
"name_controller-1": [
"52.205.43.24"
],
"name_controller-2": [
"54.210.213.10"
],
......
}
}
Weirdly when I try debugging with var=groups[controller]
I get ...
TASK [worker : debug] *******************************************************************************************************************************************
ok: [34.207.172.100] => {
"groups[controller]": "VARIABLE IS NOT DEFINED!: 'controller' is undefined"
}
.....
TASK [worker : Add Kubelet configuration] ***********************************************************************************************************************
fatal: [34.207.172.100]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'controller' is undefined"}
What am I missing here?