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.

89 lines
3.2 KiB

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. synchronize:
  4. src: "{{ local_release_dir }}/calico/bin/calicoctl"
  5. dest: "{{ bin_dir }}/calicoctl"
  6. archive: no
  7. times: yes
  8. delegate_to: "{{ groups['downloader'][0] }}"
  9. notify: restart calico-node
  10. - name: Calico | install calicoctl
  11. file: path={{ bin_dir }}/calicoctl mode=0755 state=file
  12. - name: Calico | Create calicoctl symlink (needed by kubelet)
  13. file:
  14. src: /usr/local/bin/calicoctl
  15. dest: /usr/bin/calicoctl
  16. state: link
  17. - wait_for:
  18. port: 2379
  19. when: inventory_hostname in groups['kube-master']
  20. - name: Calico | Check if calico network pool has already been configured
  21. uri:
  22. url: "http://127.0.0.1:2379/v2/keys/calico/v1/ipam/v4/pool"
  23. return_content: yes
  24. status_code: 200,404
  25. register: calico_conf
  26. run_once: true
  27. delegate_to: "{{ groups['etcd'][0] }}"
  28. - name: Calico | Configure calico network pool
  29. shell: calicoctl pool add {{ kube_pods_subnet }}
  30. run_once: true
  31. when: calico_conf.status == 404
  32. delegate_to: "{{ groups['etcd'][0] }}"
  33. - name: Calico | Get calico configuration from etcd
  34. uri:
  35. url: "http://127.0.0.1:2379/v2/keys/calico/v1/ipam/v4/pool"
  36. return_content: yes
  37. register: calico_pools
  38. run_once: true
  39. delegate_to: "{{ groups['etcd'][0] }}"
  40. - name: Calico | Check if calico pool is properly configured
  41. fail:
  42. msg: 'Only one network pool must be configured and it must be the subnet {{ kube_pods_subnet }}.
  43. Please erase calico configuration and run the playbook again ("etcdctl rm --recursive /calico/v1/ipam/v4/pool")'
  44. when: ( calico_pools.json['node']['nodes'] | length > 1 ) or
  45. ( not calico_pools.json['node']['nodes'][0]['key'] | search(".*{{ kube_pods_subnet | ipaddr('network') }}.*") )
  46. run_once: true
  47. delegate_to: "{{ groups['etcd'][0] }}"
  48. - name: Calico | Write calico-node configuration
  49. template: src=calico/calico.conf.j2 dest=/usr/libexec/kubernetes/kubelet-plugins/net/exec/calico/calico_kubernetes.ini
  50. notify: restart calico-node
  51. - name: Calico | Write calico-node systemd init file
  52. template: src=calico/calico-node.service.j2 dest=/etc/systemd/system/calico-node.service
  53. when: init_system == "systemd"
  54. notify: restart systemd-calico-node
  55. - name: Calico | Write calico-node initd script
  56. template: src=calico/deb-calico.initd.j2 dest=/etc/init.d/calico-node owner=root mode=755
  57. when: init_system == "sysvinit" and ansible_os_family == "Debian"
  58. notify: restart calico-node
  59. - name: Calico | Write calico-node initd script
  60. template: src=calico/rh-calico.initd.j2 dest=/etc/init.d/calico-node owner=root mode=755
  61. when: init_system == "sysvinit" and ansible_os_family == "RedHat"
  62. notify: restart calico-node
  63. - name: Calico | Enable calico-node
  64. service: name=calico-node enabled=yes state=started
  65. - name: Calico | Disable node mesh
  66. shell: calicoctl bgp node-mesh off
  67. environment:
  68. ETCD_AUTHORITY: "{{ groups['etcd'][0] }}:2379"
  69. when: peer_with_router|default(false) and inventory_hostname in groups['kube-node']
  70. - name: Calico | Configure peering with router(s)
  71. shell: calicoctl node bgp peer add {{ item.router_id }} as {{ item.as }}
  72. environment:
  73. ETCD_AUTHORITY: "{{ groups['etcd'][0] }}:2379"
  74. with_items: peers
  75. when: peer_with_router|default(false) and inventory_hostname in groups['kube-node']