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.

59 lines
1.5 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
  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. owner: kube
  17. notify:
  18. - reset_kube_router
  19. - name: kube-router | Slurp cni config
  20. slurp:
  21. src: /etc/cni/net.d/10-kuberouter.conflist
  22. register: cni_config_slurp
  23. ignore_errors: true
  24. - name: kube-router | Set cni_config variable
  25. set_fact:
  26. cni_config: "{{ cni_config_slurp.content | b64decode | from_json }}"
  27. when:
  28. - not cni_config_slurp.failed
  29. - name: kube-router | Set host_subnet variable
  30. set_fact:
  31. host_subnet: "{{ cni_config | json_query('plugins[?bridge==`kube-bridge`].ipam.subnet') | first }}"
  32. when:
  33. - cni_config is defined
  34. - cni_config | json_query('plugins[?bridge==`kube-bridge`].ipam.subnet') | length > 0
  35. - name: kube-router | Create cni config
  36. template:
  37. src: cni-conf.json.j2
  38. dest: /etc/cni/net.d/10-kuberouter.conflist
  39. owner: kube
  40. notify:
  41. - reset_kube_router
  42. - name: kube-router | Delete old configuration
  43. file:
  44. path: /etc/cni/net.d/10-kuberouter.conf
  45. state: absent
  46. - name: kube-router | Create manifest
  47. template:
  48. src: kube-router.yml.j2
  49. dest: "{{ kube_config_dir }}/kube-router.yml"
  50. delegate_to: "{{ groups['kube-master'] | first }}"
  51. run_once: true