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.

55 lines
1.4 KiB

  1. ---
  2. - name: Weave seed | Set seed if first time
  3. set_fact:
  4. seed: '{% for host in groups["k8s-cluster"] %}{{ hostvars[host]["ansible_default_ipv4"]["macaddress"] }}{% if not loop.last %},{% endif %}{% endfor %}'
  5. when: "weave_seed == 'uninitialized'"
  6. run_once: true
  7. tags:
  8. - confweave
  9. - name: Weave seed | Set seed if not first time
  10. set_fact:
  11. seed: '{{ weave_seed }}'
  12. when: "weave_seed != 'uninitialized'"
  13. run_once: true
  14. tags:
  15. - confweave
  16. - name: Weave seed | Set peers if fist time
  17. set_fact:
  18. peers: '{{ weave_ip_current_cluster }}'
  19. when: "weave_peers == 'uninitialized'"
  20. run_once: true
  21. tags:
  22. - confweave
  23. - name: Weave seed | Set peers if existing peers
  24. set_fact:
  25. peers: '{{ weave_peers }}{% for ip in weave_ip_current_cluster.split(" ") %}{% if ip not in weave_peers.split(" ") %} {{ ip }}{% endif %}{% endfor %}'
  26. when: "weave_peers != 'uninitialized'"
  27. run_once: true
  28. tags:
  29. - confweave
  30. - name: Weave seed | Save seed
  31. lineinfile:
  32. dest: "./inventory/group_vars/k8s-cluster.yml"
  33. state: present
  34. regexp: '^weave_seed:'
  35. line: 'weave_seed: {{ seed }}'
  36. become: no
  37. delegate_to: 127.0.0.1
  38. run_once: true
  39. tags:
  40. - confweave
  41. - name: Weave seed | Save peers
  42. lineinfile:
  43. dest: "./inventory/group_vars/k8s-cluster.yml"
  44. state: present
  45. regexp: '^weave_peers:'
  46. line: 'weave_peers: {{ peers }}'
  47. become: no
  48. delegate_to: 127.0.0.1
  49. run_once: true
  50. tags:
  51. - confweave