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.

39 lines
1.3 KiB

  1. ---
  2. # Workaround to retry a block of tasks, ansible doesn't have a direct way to do it,
  3. # you can follow the block loop request in: https://github.com/ansible/ansible/issues/46203
  4. - block:
  5. - name: Set the retry count
  6. set_fact:
  7. retry_count: "{{ 0 if retry_count is undefined else retry_count|int + 1 }}"
  8. - name: Calico-rr | Fetch current node object
  9. command: "{{ bin_dir }}/calicoctl.sh get node {{ inventory_hostname }} -ojson"
  10. changed_when: false
  11. register: calico_rr_node
  12. until: calico_rr_node is succeeded
  13. delay: "{{ retry_stagger | random + 3 }}"
  14. retries: 10
  15. - name: Calico-rr | Set route reflector cluster ID
  16. set_fact:
  17. calico_rr_node_patched: >-
  18. {{ calico_rr_node.stdout | from_json | combine({ 'spec': { 'bgp':
  19. { 'routeReflectorClusterID': cluster_id }}}, recursive=True) }}
  20. - name: Calico-rr | Configure route reflector # noqa 301 305
  21. shell: "{{ bin_dir }}/calicoctl.sh replace -f-"
  22. args:
  23. stdin: "{{ calico_rr_node_patched | to_json }}"
  24. rescue:
  25. - name: Fail if retry limit is reached
  26. fail:
  27. msg: Ended after 10 retries
  28. when: retry_count|int == 10
  29. - name: Retrying node configuration
  30. debug:
  31. msg: "Failed to configure route reflector - Retrying..."
  32. - name: Retry node configuration
  33. include_tasks: update-node.yml