Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use combine to set calico-rr cluster id reliably #5114

Merged
merged 1 commit into from
Aug 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions roles/network_plugin/calico/rr/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,24 @@
include_tasks: pre.yml

- name: Calico-rr | Fetch current node object
command: "{{ bin_dir }}/calicoctl.sh get node {{ inventory_hostname }} -oyaml"
command: "{{ bin_dir }}/calicoctl.sh get node {{ inventory_hostname }} -ojson"
register: calico_rr_node
until: calico_rr_node is succeeded
delay: "{{ retry_stagger | random + 3 }}"
retries: 10

# FIXME(mattymo): Use jsonpatch when ansible/ansible#52931 is merged
- name: Calico-rr | Set route reflector cluster ID
shell: >-
echo -e '{{ calico_rr_node.stdout }}' |
sed '/bgp:/a \ \ \ \ routeReflectorClusterID: {{ cluster_id }}'
register: calico_rr_node
when: '("routeReflectorClusterID: " + cluster_id|string) not in calico_rr_node.stdout_lines'
set_fact:
calico_rr_node_patched: >-
{{ calico_rr_node.stdout | from_json | combine({ 'spec': { 'bgp':
{ 'routeReflectorClusterID': cluster_id }}}, recursive=True) }}

- name: Calico-rr | Configure route reflector
shell: |-
echo -e '{{ calico_rr_node.stdout }}' |
{{ bin_dir }}/calicoctl.sh replace -f-
retries: 4
delay: "{{ retry_stagger | random + 3 }}"
shell: "{{ bin_dir }}/calicoctl.sh replace -f-"
args:
stdin: "{{ calico_rr_node_patched | to_json }}"

- name: Calico-rr | Set label for route reflector
command: >-
{{ bin_dir }}/calicoctl.sh label node {{ inventory_hostname }}
'i-am-a-route-reflector=true' --overwrite
retries: 4
delay: "{{ retry_stagger | random + 3 }}"