main.yml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. ---
  2. - include_tasks: certs.yml
  3. - name: Calico Master | oc adm policy add-scc-to-user privileged system:serviceaccount:kube-system:calico-node
  4. oc_adm_policy_user:
  5. user: system:serviceaccount:kube-system:calico-node
  6. resource_kind: scc
  7. resource_name: privileged
  8. state: present
  9. - name: Calico Master | oc adm policy add-scc-to-user privileged system:serviceaccount:kube-system:calico-kube-controllers
  10. oc_adm_policy_user:
  11. user: system:serviceaccount:kube-system:calico-kube-controllers
  12. resource_kind: scc
  13. resource_name: privileged
  14. state: present
  15. - name: Calico Master | oc adm policy add-scc-to-user privileged system:serviceaccount:kube-system:calico-upgrade-job
  16. oc_adm_policy_user:
  17. user: system:serviceaccount:kube-system:calico-upgrade-job
  18. resource_kind: scc
  19. resource_name: privileged
  20. state: present
  21. - name: Set default selector for kube-system
  22. command: >
  23. {{ openshift_client_binary }}
  24. --config={{ openshift.common.config_base }}/master/admin.kubeconfig
  25. annotate ns kube-system openshift.io/node-selector="" --overwrite
  26. - name: Calico Master | Create temp directory
  27. command: mktemp -d /tmp/openshift-ansible-XXXXXXX
  28. register: mktemp
  29. changed_when: False
  30. - name: Calico Master | Parse node version
  31. set_fact:
  32. node_version: "{{ calico_node_image | regex_replace('^.*node:v?(.*)$', '\\1') }}"
  33. - name: Calico Master | Write Calico v2
  34. template:
  35. dest: "{{ mktemp.stdout }}/calico.yml"
  36. src: calico.yml.j2
  37. when: node_version | regex_search('^[0-9]\.[0-9]\.[0-9]') and node_version < '3.0.0'
  38. - name: Calico Master | Write Calico v3
  39. template:
  40. dest: "{{ mktemp.stdout }}/calico.yml"
  41. src: calicov3.yml.j2
  42. when: (node_version | regex_search('^[0-9]\.[0-9]\.[0-9]') and node_version >= '3.0.0') or node_version == 'master'
  43. - name: Calico Master | Launch Calico
  44. command: >
  45. {{ openshift_client_binary }} apply
  46. -f {{ mktemp.stdout }}/calico.yml
  47. --config={{ openshift.common.config_base }}/master/admin.kubeconfig
  48. register: calico_create_output
  49. failed_when: "calico_create_output.rc != 0"
  50. changed_when: "('created' in calico_create_output.stdout) or ('configured' in calico_create_output.stdout)"
  51. - name: Calico Master | Delete temp directory
  52. file:
  53. name: "{{ mktemp.stdout }}"
  54. state: absent
  55. changed_when: False