Parse calico nodes as json (#5114)
This commit is contained in:
parent
10e0fe86fb
commit
184ac6a4e6
1 changed files with 11 additions and 14 deletions
|
@ -3,27 +3,24 @@
|
||||||
include_tasks: pre.yml
|
include_tasks: pre.yml
|
||||||
|
|
||||||
- name: Calico-rr | Fetch current node object
|
- 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
|
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
|
- name: Calico-rr | Set route reflector cluster ID
|
||||||
shell: >-
|
set_fact:
|
||||||
echo -e '{{ calico_rr_node.stdout }}' |
|
calico_rr_node_patched: >-
|
||||||
sed '/bgp:/a \ \ \ \ routeReflectorClusterID: {{ cluster_id }}'
|
{{ calico_rr_node.stdout | from_json | combine({ 'spec': { 'bgp':
|
||||||
register: calico_rr_node
|
{ 'routeReflectorClusterID': cluster_id }}}, recursive=True) }}
|
||||||
when: '("routeReflectorClusterID: " + cluster_id|string) not in calico_rr_node.stdout_lines'
|
|
||||||
|
|
||||||
- name: Calico-rr | Configure route reflector
|
- name: Calico-rr | Configure route reflector
|
||||||
shell: |-
|
shell: "{{ bin_dir }}/calicoctl.sh replace -f-"
|
||||||
echo -e '{{ calico_rr_node.stdout }}' |
|
args:
|
||||||
{{ bin_dir }}/calicoctl.sh replace -f-
|
stdin: "{{ calico_rr_node_patched | to_json }}"
|
||||||
retries: 4
|
|
||||||
delay: "{{ retry_stagger | random + 3 }}"
|
|
||||||
|
|
||||||
- name: Calico-rr | Set label for route reflector
|
- name: Calico-rr | Set label for route reflector
|
||||||
command: >-
|
command: >-
|
||||||
{{ bin_dir }}/calicoctl.sh label node {{ inventory_hostname }}
|
{{ bin_dir }}/calicoctl.sh label node {{ inventory_hostname }}
|
||||||
'i-am-a-route-reflector=true' --overwrite
|
'i-am-a-route-reflector=true' --overwrite
|
||||||
retries: 4
|
|
||||||
delay: "{{ retry_stagger | random + 3 }}"
|
|
||||||
|
|
Loading…
Reference in a new issue