2015-10-03 20:19:50 +00:00
|
|
|
---
|
2016-01-30 15:04:47 +00:00
|
|
|
- name: Calico | Set docker daemon options
|
|
|
|
template:
|
|
|
|
src: docker
|
|
|
|
dest: "/etc/default/docker"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
notify:
|
|
|
|
- restart docker
|
2016-02-19 17:48:53 +00:00
|
|
|
when: ansible_os_family != "CoreOS"
|
2016-01-30 15:04:47 +00:00
|
|
|
|
|
|
|
- name: Calico | Write docker.service systemd file
|
|
|
|
template:
|
|
|
|
src: systemd-docker.service
|
|
|
|
dest: /lib/systemd/system/docker.service
|
|
|
|
notify: restart docker
|
2016-02-19 17:48:53 +00:00
|
|
|
when: ansible_service_mgr == "systemd" and ansible_os_family != "CoreOS"
|
2016-01-30 15:04:47 +00:00
|
|
|
|
|
|
|
- meta: flush_handlers
|
|
|
|
|
2016-07-04 15:16:18 +00:00
|
|
|
- name: Calico | Install calicoctl container script
|
|
|
|
template:
|
|
|
|
src: calicoctl-container.j2
|
|
|
|
dest: "{{ bin_dir }}/calicoctl"
|
|
|
|
mode: 0755
|
|
|
|
owner: root
|
|
|
|
group: root
|
2016-01-22 15:37:07 +00:00
|
|
|
changed_when: false
|
2016-07-04 15:16:18 +00:00
|
|
|
notify: restart calico-node
|
2015-10-03 20:19:50 +00:00
|
|
|
|
2016-01-30 15:04:47 +00:00
|
|
|
- name: Calico | Install calico cni bin
|
|
|
|
command: rsync -piu "{{ local_release_dir }}/calico/bin/calico" "/opt/cni/bin/calico"
|
|
|
|
changed_when: false
|
|
|
|
|
|
|
|
- name: Calico | Install calico-ipam cni bin
|
|
|
|
command: rsync -piu "{{ local_release_dir }}/calico/bin/calico" "/opt/cni/bin/calico-ipam"
|
|
|
|
changed_when: false
|
|
|
|
|
2016-01-25 01:01:25 +00:00
|
|
|
- name: Calico | wait for etcd
|
2016-07-19 13:45:37 +00:00
|
|
|
uri: url=http://localhost:2379/health
|
|
|
|
register: result
|
|
|
|
until: result.status == 200
|
|
|
|
retries: 10
|
|
|
|
delay: 5
|
2016-01-09 09:45:50 +00:00
|
|
|
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:
|
2016-07-11 14:05:05 +00:00
|
|
|
url: "{{ etcd_endpoint }}/v2/keys/calico/v1/ipam/v4/pool"
|
2015-12-20 15:51:14 +00:00
|
|
|
return_content: yes
|
|
|
|
status_code: 200,404
|
|
|
|
register: calico_conf
|
|
|
|
run_once: true
|
|
|
|
|
2016-02-21 11:42:23 +00:00
|
|
|
- name: Calico | Configure calico network pool
|
|
|
|
command: "{{ bin_dir }}/calicoctl pool add {{ kube_pods_subnet }}"
|
|
|
|
run_once: true
|
2016-03-23 16:27:06 +00:00
|
|
|
when: calico_conf.status == 404 and cloud_provider is not defined
|
2016-02-21 11:42:23 +00:00
|
|
|
and not nat_outgoing|default(false) or
|
|
|
|
(nat_outgoing|default(false) and peer_with_router|default(false))
|
|
|
|
|
2016-01-29 13:07:21 +00:00
|
|
|
- name: Calico | Configure calico network pool for cloud
|
2016-02-19 17:48:53 +00:00
|
|
|
command: "{{ bin_dir }}/calicoctl pool add {{ kube_pods_subnet }} --ipip --nat-outgoing"
|
2016-01-29 13:07:21 +00:00
|
|
|
run_once: true
|
2016-03-23 16:27:06 +00:00
|
|
|
when: calico_conf.status == 404 and cloud_provider is defined
|
2016-01-29 13:07:21 +00:00
|
|
|
|
2016-02-21 11:42:23 +00:00
|
|
|
- name: Calico | Configure calico network pool with nat outgoing
|
|
|
|
command: "{{ bin_dir}}/calicoctl pool add {{ kube_pods_subnet }} --nat-outgoing"
|
2015-12-11 10:42:25 +00:00
|
|
|
run_once: true
|
2016-03-23 16:27:06 +00:00
|
|
|
when: calico_conf.status == 404 and cloud_provider is not defined
|
2016-02-21 11:42:23 +00:00
|
|
|
and nat_outgoing|default(false) and not peer_with_router|default(false)
|
2015-12-20 15:51:14 +00:00
|
|
|
|
|
|
|
- name: Calico | Get calico configuration from etcd
|
|
|
|
uri:
|
2016-07-11 14:05:05 +00:00
|
|
|
url: "{{ etcd_endpoint }}/v2/keys/calico/v1/ipam/v4/pool"
|
2015-12-20 15:51:14 +00:00
|
|
|
return_content: yes
|
|
|
|
register: calico_pools
|
|
|
|
run_once: true
|
|
|
|
|
|
|
|
- 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-11 10:42:25 +00:00
|
|
|
|
2016-02-01 14:53:23 +00:00
|
|
|
- name: Calico | Write /etc/network-environment
|
2016-01-30 15:04:47 +00:00
|
|
|
template: src=network-environment.j2 dest=/etc/network-environment
|
2016-02-13 10:17:20 +00:00
|
|
|
when: ansible_service_mgr in ["sysvinit","upstart"]
|
2016-02-01 14:53:23 +00:00
|
|
|
|
2015-10-15 07:40:02 +00:00
|
|
|
- name: Calico | Write calico-node systemd init file
|
2016-01-30 15:04:47 +00:00
|
|
|
template: src=calico-node.service.j2 dest=/etc/systemd/system/calico-node.service
|
2016-02-13 10:17:20 +00:00
|
|
|
when: ansible_service_mgr == "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
|
2016-01-30 15:04:47 +00:00
|
|
|
template: src=deb-calico.initd.j2 dest=/etc/init.d/calico-node owner=root mode=0755
|
2016-02-13 10:17:20 +00:00
|
|
|
when: ansible_service_mgr in ["sysvinit","upstart"] and ansible_os_family == "Debian"
|
2016-01-04 13:24:29 +00:00
|
|
|
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
|
2016-01-30 15:04:47 +00:00
|
|
|
template: src=rh-calico.initd.j2 dest=/etc/init.d/calico-node owner=root mode=0755
|
2016-02-13 10:17:20 +00:00
|
|
|
when: ansible_service_mgr in ["sysvinit","upstart"] and ansible_os_family == "RedHat"
|
2016-01-04 13:24:29 +00:00
|
|
|
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
|
2016-01-30 15:04:47 +00:00
|
|
|
service:
|
|
|
|
name: calico-node
|
|
|
|
state: started
|
|
|
|
enabled: yes
|
2016-01-09 09:45:50 +00:00
|
|
|
|
|
|
|
- name: Calico | Disable node mesh
|
2016-02-19 17:48:53 +00:00
|
|
|
shell: "{{ bin_dir }}/calicoctl bgp node-mesh off"
|
2016-01-09 09:45:50 +00:00
|
|
|
when: peer_with_router|default(false) and inventory_hostname in groups['kube-node']
|
|
|
|
|
|
|
|
- name: Calico | Configure peering with router(s)
|
2016-02-19 17:48:53 +00:00
|
|
|
shell: "{{ bin_dir }}/calicoctl node bgp peer add {{ item.router_id }} as {{ item.as }}"
|
2016-01-09 09:45:50 +00:00
|
|
|
with_items: peers
|
|
|
|
when: peer_with_router|default(false) and inventory_hostname in groups['kube-node']
|
2016-07-04 15:16:18 +00:00
|
|
|
|