2017-08-24 09:09:52 +00:00
|
|
|
---
|
2017-09-04 08:29:40 +00:00
|
|
|
- name: Set cert dir
|
|
|
|
set_fact:
|
2016-12-30 12:47:12 +00:00
|
|
|
calico_cert_dir: "{{ canal_cert_dir }}"
|
|
|
|
when: kube_network_plugin == 'canal'
|
2017-10-05 07:43:04 +00:00
|
|
|
tags:
|
|
|
|
- facts
|
|
|
|
- canal
|
2016-12-30 12:47:12 +00:00
|
|
|
|
2017-09-04 08:29:40 +00:00
|
|
|
- name: Get calico-policy-controller version if running
|
|
|
|
shell: "{{ bin_dir }}/kubectl -n {{ system_namespace }} get rs calico-policy-controller -o=jsonpath='{$.spec.template.spec.containers[:1].image}' | cut -d':' -f2"
|
|
|
|
register: existing_calico_policy_version
|
|
|
|
run_once: true
|
2017-10-25 20:19:40 +00:00
|
|
|
changed_when: false
|
2017-09-04 08:29:40 +00:00
|
|
|
failed_when: false
|
|
|
|
|
|
|
|
# FIXME(mattymo): This should not be necessary
|
|
|
|
- name: Delete calico-policy-controller if an old one is installed
|
|
|
|
kube:
|
|
|
|
name: calico-policy-controller
|
|
|
|
kubectl: "{{bin_dir}}/kubectl"
|
|
|
|
resource: rs
|
|
|
|
namespace: "{{ system_namespace }}"
|
|
|
|
state: absent
|
|
|
|
run_once: true
|
|
|
|
when:
|
|
|
|
- not "NotFound" in existing_calico_policy_version.stderr
|
|
|
|
- existing_calico_policy_version.stdout | version_compare('v0.7.0', '<')
|
|
|
|
|
|
|
|
- name: Create calico-policy-controller manifests
|
2017-02-17 21:22:34 +00:00
|
|
|
template:
|
2017-09-04 08:29:40 +00:00
|
|
|
src: "{{item.file}}.j2"
|
|
|
|
dest: "{{kube_config_dir}}/{{item.file}}"
|
|
|
|
with_items:
|
|
|
|
- {name: calico-policy-controller, file: calico-policy-controller.yml, type: rs}
|
|
|
|
- {name: calico-policy-controller, file: calico-policy-sa.yml, type: sa}
|
|
|
|
- {name: calico-policy-controller, file: calico-policy-cr.yml, type: clusterrole}
|
|
|
|
- {name: calico-policy-controller, file: calico-policy-crb.yml, type: clusterrolebinding}
|
|
|
|
register: calico_policy_manifests
|
|
|
|
when:
|
|
|
|
- rbac_enabled or item.type not in rbac_resources
|
2016-10-10 14:09:50 +00:00
|
|
|
|
|
|
|
- name: Start of Calico policy controller
|
|
|
|
kube:
|
2017-09-04 08:29:40 +00:00
|
|
|
name: "{{item.item.name}}"
|
|
|
|
namespace: "{{ system_namespace }}"
|
2016-10-10 14:09:50 +00:00
|
|
|
kubectl: "{{bin_dir}}/kubectl"
|
2017-09-04 08:29:40 +00:00
|
|
|
resource: "{{item.item.type}}"
|
|
|
|
filename: "{{kube_config_dir}}/{{item.item.file}}"
|
2017-09-05 05:23:12 +00:00
|
|
|
state: "latest"
|
2017-09-04 08:29:40 +00:00
|
|
|
with_items: "{{ calico_policy_manifests.results }}"
|
2017-09-05 05:23:12 +00:00
|
|
|
when: inventory_hostname == groups['kube-master'][0] and not item|skipped
|