Skip to content

Commit

Permalink
use block for kdd tasks + remove supernumerary kdd manifest apply in …
Browse files Browse the repository at this point in the history
…start "Start Calico resources"
  • Loading branch information
mirwan committed Mar 15, 2021
1 parent a4556af commit 8355a44
Showing 1 changed file with 24 additions and 37 deletions.
61 changes: 24 additions & 37 deletions roles/network_plugin/calico/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,47 +110,35 @@
- calico_pool_cidr_ipv6 is defined
- enable_dual_stack_networks

- name: Calico | Remove unwanted annotations and creationTimestamp keys from metadata in Calico manifests
# noqa 303 - sed avoids using nested loop
shell: >-
sed -E -i
-e '/^\s{2,4}creationTimestamp: null$/d'
-e '/^\s{2,4}annotations:/{:1;/\(devel\)$/!{N;b 1}; /.*/d}'
{{ local_release_dir }}/calico-{{ calico_version }}-kdd-crds/*.yaml
when:
- inventory_hostname in groups['kube-master']
- calico_datastore == 'kdd'
- calico_version is version('v3.17.0', '<')
- block:
- name: Calico | Remove unwanted annotations and creationTimestamp keys from metadata in Calico manifests
# noqa 303 - sed avoids using nested loop
shell: >-
sed -E -i
-e '/^\s{2,4}creationTimestamp: null$/d'
-e '/^\s{2,4}annotations:/{:1;/\(devel\)$/!{N;b 1}; /.*/d}'
{{ local_release_dir }}/calico-{{ calico_version }}-kdd-crds/*.yaml
when:
- calico_version is version('v3.17.0', '<')

- name: Calico | Create calico manifests for kdd
assemble:
src: "{{ local_release_dir }}/calico-{{ calico_version }}-kdd-crds"
dest: "{{ kube_config_dir }}/{{ item.file }}"
regexp: ".*\\.yaml"
remote_src: true
with_items:
- {name: calico, file: kdd-crds.yml, type: kdd}
register: calico_node_kdd_manifest
- name: Calico | Create calico manifests for kdd
assemble:
src: "{{ local_release_dir }}/calico-{{ calico_version }}-kdd-crds"
dest: "{{ kube_config_dir }}/kdd-crds.yml"
regexp: ".*\\.yaml"
remote_src: true

- name: Calico | Create Calico Kubernetes datastore resources
kube:
kubectl: "{{ bin_dir }}/kubectl"
filename: "{{ kube_config_dir }}/kdd-crds.yml"
state: "latest"
when:
- inventory_hostname == groups['kube-master'][0]
when:
- inventory_hostname in groups['kube-master']
- calico_datastore == "kdd"

- name: Calico | Create Calico Kubernetes datastore resources
kube:
name: "{{ item.item.name }}"
namespace: "kube-system"
kubectl: "{{ bin_dir }}/kubectl"
resource: "{{ item.item.type }}"
filename: "{{ kube_config_dir }}/{{ item.item.file }}"
state: "latest"
with_items:
- "{{ calico_node_kdd_manifest.results }}"
when:
- inventory_hostname == groups['kube-master'][0]
- not item is skipped
loop_control:
label: "{{ item.item.file }}"

- name: Calico | Configure calico network pool
command:
cmd: "{{ bin_dir }}/calicoctl.sh apply -f -"
Expand Down Expand Up @@ -341,7 +329,6 @@
state: "latest"
with_items:
- "{{ calico_node_manifests.results }}"
- "{{ calico_node_kdd_manifest.results }}"
- "{{ calico_node_typha_manifest.results }}"
when:
- inventory_hostname == groups['kube-master'][0]
Expand Down

0 comments on commit 8355a44

Please sign in to comment.