From 6f9148e99478491551d16d7cf97c78d6958c0e5f Mon Sep 17 00:00:00 2001 From: Jean-Christophe Sirot Date: Fri, 8 Jan 2016 10:32:43 +0100 Subject: [PATCH] Fix calico with systemd --- roles/network_plugin/tasks/calico.yml | 4 ++-- roles/network_plugin/templates/calico/calico-node.service.j2 | 4 ++-- roles/network_plugin/templates/calico/calico.conf.j2 | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/roles/network_plugin/tasks/calico.yml b/roles/network_plugin/tasks/calico.yml index 95803daf2..9d12578f8 100644 --- a/roles/network_plugin/tasks/calico.yml +++ b/roles/network_plugin/tasks/calico.yml @@ -39,7 +39,7 @@ fail: msg: 'Only one network pool must be configured and it must be the subnet {{ kube_pods_subnet }}. Please erase calico configuration and run the playbook again ("etcdctl rm --recursive /calico/v1/ipam/v4/pool")' - when: ( calico_pools.json['node']['nodes'] | length > 1 ) or + when: ( calico_pools.json['node']['nodes'] | length > 1 ) or ( not calico_pools.json['node']['nodes'][0]['key'] | search(".*{{ kube_pods_subnet | ipaddr('network') }}.*") ) run_once: true delegate_to: "{{ groups['etcd'][0] }}" @@ -51,7 +51,7 @@ - name: Calico | Write calico-node systemd init file template: src=calico/calico-node.service.j2 dest=/etc/systemd/system/calico-node.service when: init_system == "systemd" - notify: restart calico-node + notify: restart systemd-calico-node - name: Calico | Write calico-node initd script template: src=calico/deb-calico.initd.j2 dest=/etc/init.d/calico-node owner=root mode=755 diff --git a/roles/network_plugin/templates/calico/calico-node.service.j2 b/roles/network_plugin/templates/calico/calico-node.service.j2 index ba594c758..af07e2571 100644 --- a/roles/network_plugin/templates/calico/calico-node.service.j2 +++ b/roles/network_plugin/templates/calico/calico-node.service.j2 @@ -8,9 +8,9 @@ After=docker.service etcd2.service User=root PermissionsStartOnly=true {% if inventory_hostname in groups['kube-node'] and peer_with_router|default(false)%} -ExecStart={{ bin_dir }}/calicoctl node --kubernetes --ip=${DEFAULT_IPV4} --as={{ local_as }} --detach=false +ExecStart={{ bin_dir }}/calicoctl node --kubernetes --ip={{ip | default(ansible_default_ipv4.address) }} --as={{ local_as }} --detach=false {% else %} -ExecStart={{ bin_dir }}/calicoctl node --kubernetes --ip=${DEFAULT_IPV4} --detach=false +ExecStart={{ bin_dir }}/calicoctl node --kubernetes --ip={{ip | default(ansible_default_ipv4.address) }} --detach=false {% endif %} Restart=always Restart=10 diff --git a/roles/network_plugin/templates/calico/calico.conf.j2 b/roles/network_plugin/templates/calico/calico.conf.j2 index ec17f6e37..685c68c18 100644 --- a/roles/network_plugin/templates/calico/calico.conf.j2 +++ b/roles/network_plugin/templates/calico/calico.conf.j2 @@ -1,6 +1,5 @@ [config] CALICO_IPAM=true -DEFAULT_IPV4={{ip | default(ansible_default_ipv4.address) }} # Location of etcd cluster used by Calico. By default, this uses the etcd # instance running on the Kubernetes Master