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.

62 lines
1.6 KiB

  1. ---
  2. - name: kube-router | Create annotations
  3. include: annotate.yml
  4. tags: annotate
  5. - name: kube-router | Create config directory
  6. file:
  7. path: /var/lib/kube-router
  8. state: directory
  9. owner: "{{ kube_owner }}"
  10. recurse: true
  11. mode: 0755
  12. - name: kube-router | Create kubeconfig
  13. template:
  14. src: kubeconfig.yml.j2
  15. dest: /var/lib/kube-router/kubeconfig
  16. mode: 0644
  17. owner: "{{ kube_owner }}"
  18. notify:
  19. - reset_kube_router
  20. - name: kube-router | Slurp cni config
  21. slurp:
  22. src: /etc/cni/net.d/10-kuberouter.conflist
  23. register: cni_config_slurp
  24. ignore_errors: true # noqa ignore-errors
  25. - name: kube-router | Set cni_config variable
  26. set_fact:
  27. cni_config: "{{ cni_config_slurp.content | b64decode | from_json }}"
  28. when:
  29. - not cni_config_slurp.failed
  30. - name: kube-router | Set host_subnet variable
  31. set_fact:
  32. host_subnet: "{{ cni_config | json_query('plugins[?bridge==`kube-bridge`].ipam.subnet') | first }}"
  33. when:
  34. - cni_config is defined
  35. - cni_config | json_query('plugins[?bridge==`kube-bridge`].ipam.subnet') | length > 0
  36. - name: kube-router | Create cni config
  37. template:
  38. src: cni-conf.json.j2
  39. dest: /etc/cni/net.d/10-kuberouter.conflist
  40. mode: 0644
  41. owner: "{{ kube_owner }}"
  42. notify:
  43. - reset_kube_router
  44. - name: kube-router | Delete old configuration
  45. file:
  46. path: /etc/cni/net.d/10-kuberouter.conf
  47. state: absent
  48. - name: kube-router | Create manifest
  49. template:
  50. src: kube-router.yml.j2
  51. dest: "{{ kube_config_dir }}/kube-router.yml"
  52. mode: 0644
  53. delegate_to: "{{ groups['kube_control_plane'] | first }}"
  54. run_once: true