2015-10-03 20:19:50 +00:00
|
|
|
---
|
2015-10-15 07:40:02 +00:00
|
|
|
- name: Calico | Install calicoctl bin
|
2016-01-23 17:26:07 +00:00
|
|
|
command: rsync -piu "{{ local_release_dir }}/calico/bin/calicoctl" "{{ bin_dir }}/calicoctl"
|
|
|
|
register: calico_copy
|
2016-01-22 15:37:07 +00:00
|
|
|
changed_when: false
|
2015-10-03 20:19:50 +00:00
|
|
|
|
2016-01-04 13:58:27 +00:00
|
|
|
- name: Calico | install calicoctl
|
|
|
|
file: path={{ bin_dir }}/calicoctl mode=0755 state=file
|
|
|
|
|
2015-10-15 07:40:02 +00:00
|
|
|
- name: Calico | Create calicoctl symlink (needed by kubelet)
|
2015-12-20 15:51:14 +00:00
|
|
|
file:
|
|
|
|
src: /usr/local/bin/calicoctl
|
|
|
|
dest: /usr/bin/calicoctl
|
|
|
|
state: link
|
2015-10-03 20:19:50 +00:00
|
|
|
|
2016-01-25 01:01:25 +00:00
|
|
|
- name: Calico | wait for etcd
|
|
|
|
wait_for:
|
2016-01-09 09:45:50 +00:00
|
|
|
port: 2379
|
|
|
|
when: inventory_hostname in groups['kube-master']
|
|
|
|
|
2015-12-20 15:51:14 +00:00
|
|
|
- name: Calico | Check if calico network pool has already been configured
|
|
|
|
uri:
|
|
|
|
url: "http://127.0.0.1:2379/v2/keys/calico/v1/ipam/v4/pool"
|
|
|
|
return_content: yes
|
|
|
|
status_code: 200,404
|
|
|
|
register: calico_conf
|
|
|
|
run_once: true
|
|
|
|
delegate_to: "{{ groups['etcd'][0] }}"
|
|
|
|
|
|
|
|
- name: Calico | Configure calico network pool
|
2015-12-11 10:42:25 +00:00
|
|
|
shell: calicoctl pool add {{ kube_pods_subnet }}
|
|
|
|
run_once: true
|
2015-12-20 15:51:14 +00:00
|
|
|
when: calico_conf.status == 404
|
|
|
|
delegate_to: "{{ groups['etcd'][0] }}"
|
|
|
|
|
|
|
|
- name: Calico | Get calico configuration from etcd
|
|
|
|
uri:
|
|
|
|
url: "http://127.0.0.1:2379/v2/keys/calico/v1/ipam/v4/pool"
|
|
|
|
return_content: yes
|
|
|
|
register: calico_pools
|
|
|
|
run_once: true
|
|
|
|
delegate_to: "{{ groups['etcd'][0] }}"
|
|
|
|
|
|
|
|
- name: Calico | Check if calico pool is properly configured
|
|
|
|
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")'
|
2016-01-04 13:58:27 +00:00
|
|
|
when: ( calico_pools.json['node']['nodes'] | length > 1 ) or
|
2015-12-20 15:51:14 +00:00
|
|
|
( not calico_pools.json['node']['nodes'][0]['key'] | search(".*{{ kube_pods_subnet | ipaddr('network') }}.*") )
|
|
|
|
run_once: true
|
2015-12-18 09:16:03 +00:00
|
|
|
delegate_to: "{{ groups['etcd'][0] }}"
|
2015-12-11 10:42:25 +00:00
|
|
|
|
2016-01-04 13:24:29 +00:00
|
|
|
- name: Calico | Write calico-node configuration
|
|
|
|
template: src=calico/calico.conf.j2 dest=/usr/libexec/kubernetes/kubelet-plugins/net/exec/calico/calico_kubernetes.ini
|
|
|
|
notify: restart calico-node
|
|
|
|
|
2015-10-15 07:40:02 +00:00
|
|
|
- name: Calico | Write calico-node systemd init file
|
2015-10-03 20:19:50 +00:00
|
|
|
template: src=calico/calico-node.service.j2 dest=/etc/systemd/system/calico-node.service
|
2016-01-04 13:24:29 +00:00
|
|
|
when: init_system == "systemd"
|
2016-01-25 20:09:42 +00:00
|
|
|
notify: restart calico-node
|
2016-01-04 13:24:29 +00:00
|
|
|
|
|
|
|
- name: Calico | Write calico-node initd script
|
|
|
|
template: src=calico/deb-calico.initd.j2 dest=/etc/init.d/calico-node owner=root mode=755
|
|
|
|
when: init_system == "sysvinit" and ansible_os_family == "Debian"
|
|
|
|
notify: restart calico-node
|
2015-10-03 20:19:50 +00:00
|
|
|
|
2016-01-04 13:24:29 +00:00
|
|
|
- name: Calico | Write calico-node initd script
|
|
|
|
template: src=calico/rh-calico.initd.j2 dest=/etc/init.d/calico-node owner=root mode=755
|
|
|
|
when: init_system == "sysvinit" and ansible_os_family == "RedHat"
|
|
|
|
notify: restart calico-node
|
2015-11-20 13:04:13 +00:00
|
|
|
|
2016-01-25 01:01:25 +00:00
|
|
|
- meta: flush_handlers
|
|
|
|
|
2015-10-15 07:40:02 +00:00
|
|
|
- name: Calico | Enable calico-node
|
2015-10-03 20:19:50 +00:00
|
|
|
service: name=calico-node enabled=yes state=started
|
2016-01-09 09:45:50 +00:00
|
|
|
|
2016-01-23 17:26:07 +00:00
|
|
|
- name: Calico | Restart calico if binary changed
|
|
|
|
service:
|
|
|
|
name: calico-node
|
|
|
|
state: restarted
|
|
|
|
when: calico_copy.stdout_lines
|
|
|
|
|
2016-01-09 09:45:50 +00:00
|
|
|
- name: Calico | Disable node mesh
|
|
|
|
shell: calicoctl bgp node-mesh off
|
|
|
|
environment:
|
|
|
|
ETCD_AUTHORITY: "{{ groups['etcd'][0] }}:2379"
|
|
|
|
when: peer_with_router|default(false) and inventory_hostname in groups['kube-node']
|
|
|
|
|
|
|
|
- name: Calico | Configure peering with router(s)
|
|
|
|
shell: calicoctl node bgp peer add {{ item.router_id }} as {{ item.as }}
|
|
|
|
environment:
|
|
|
|
ETCD_AUTHORITY: "{{ groups['etcd'][0] }}:2379"
|
|
|
|
with_items: peers
|
|
|
|
when: peer_with_router|default(false) and inventory_hostname in groups['kube-node']
|