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.

73 lines
2.5 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. ---
  2. - name: Calico | Install calicoctl bin
  3. copy:
  4. src: "{{ local_release_dir }}/calico/bin/calicoctl"
  5. dest: "{{ bin_dir }}"
  6. mode: 0755
  7. notify: restart calico-node
  8. - name: Calico | Create calicoctl symlink (needed by kubelet)
  9. file:
  10. src: /usr/local/bin/calicoctl
  11. dest: /usr/bin/calicoctl
  12. state: link
  13. - name: Calico | Check if calico network pool has already been configured
  14. uri:
  15. url: "http://127.0.0.1:2379/v2/keys/calico/v1/ipam/v4/pool"
  16. return_content: yes
  17. status_code: 200,404
  18. register: calico_conf
  19. run_once: true
  20. delegate_to: "{{ groups['etcd'][0] }}"
  21. - name: Calico | Configure calico network pool
  22. shell: calicoctl pool add {{ kube_pods_subnet }}
  23. run_once: true
  24. when: calico_conf.status == 404
  25. delegate_to: "{{ groups['etcd'][0] }}"
  26. - name: Calico | Get calico configuration from etcd
  27. uri:
  28. url: "http://127.0.0.1:2379/v2/keys/calico/v1/ipam/v4/pool"
  29. return_content: yes
  30. register: calico_pools
  31. run_once: true
  32. delegate_to: "{{ groups['etcd'][0] }}"
  33. - name: Calico | Check if calico pool is properly configured
  34. fail:
  35. msg: 'Only one network pool must be configured and it must be the subnet {{ kube_pods_subnet }}.
  36. Please erase calico configuration and run the playbook again ("etcdctl rm --recursive /calico/v1/ipam/v4/pool")'
  37. when: ( calico_pools.json['node']['nodes'] | length > 1 ) or
  38. ( not calico_pools.json['node']['nodes'][0]['key'] | search(".*{{ kube_pods_subnet | ipaddr('network') }}.*") )
  39. run_once: true
  40. delegate_to: "{{ groups['etcd'][0] }}"
  41. - name: Calico | Write calico-node systemd init file
  42. template: src=calico/calico-node.service.j2 dest=/etc/systemd/system/calico-node.service
  43. register: newservice
  44. notify:
  45. - reload systemd
  46. - restart calico-node
  47. - name: Calico | daemon-reload
  48. command: systemctl daemon-reload
  49. when: newservice|changed
  50. changed_when: False
  51. - name: Calico | Enable calico-node
  52. service: name=calico-node enabled=yes state=started
  53. - name: Calico | Disable node mesh
  54. shell: calicoctl bgp node-mesh off
  55. environment:
  56. ETCD_AUTHORITY: "{{ groups['etcd'][0] }}:2379"
  57. when: peer_with_router|default(false) and inventory_hostname in groups['kube-node']
  58. - name: Calico | Configure peering with router(s)
  59. shell: calicoctl node bgp peer add {{ item.router_id }} as {{ item.as }}
  60. environment:
  61. ETCD_AUTHORITY: "{{ groups['etcd'][0] }}:2379"
  62. with_items: peers
  63. when: peer_with_router|default(false) and inventory_hostname in groups['kube-node']