<commit_before>---
- name: Calico | Install calicoctl bin
  command: rsync -piu "{{ local_release_dir }}/calico/bin/calicoctl" "{{ bin_dir }}/calicoctl"
  register: calico_copy
  changed_when: false

- name: Calico | install calicoctl
  file: path={{ bin_dir }}/calicoctl mode=0755 state=file

- name: Calico | Create calicoctl symlink (needed by kubelet)
  file:
    src: /usr/local/bin/calicoctl
    dest: /usr/bin/calicoctl
    state: link

- name: Calico | wait for etcd
  wait_for:
    port: 2379
  when: inventory_hostname in groups['kube-master']

- name: Calico | Check if calico network pool has already been configured
  uri:
    url: "http://127.0.0.1:2379/v2/keys/calico/v1/ipam/v4/pool"
    return_content: yes
    status_code: 200,404
  register: calico_conf
  run_once: true

- name: Calico | Configure calico network pool
  shell: calicoctl pool add {{ kube_pods_subnet }}  {%- if cloud_provider is defined and cloud_provider == True -%} --ipip{%- endif -%}
  run_once: true
  when: calico_conf.status == 404

- name: Calico | Get calico configuration from etcd
  uri:
    url: "http://127.0.0.1:2379/v2/keys/calico/v1/ipam/v4/pool"
    return_content: yes
  register: calico_pools
  run_once: true

- name: Calico | Check if calico pool is properly configured
  fail:
    msg: 'Only one network pool must be configured and it must be the subnet {{ kube_pods_subnet }}.
    Please erase calico configuration and run the playbook again ("etcdctl rm --recursive /calico/v1/ipam/v4/pool")'
  when: ( calico_pools.json['node']['nodes'] | length > 1 ) or
        ( not calico_pools.json['node']['nodes'][0]['key'] | search(".*{{ kube_pods_subnet | ipaddr('network') }}.*") )
  run_once: true

- name: Calico | Write calico-node configuration
  template: src=calico/calico.conf.j2 dest=/usr/libexec/kubernetes/kubelet-plugins/net/exec/calico/calico_kubernetes.ini
  notify: restart calico-node

- name: Calico | Write calico-node systemd init file
  template: src=calico/calico-node.service.j2 dest=/etc/systemd/system/calico-node.service
  when: init_system == "systemd"<commit_msg>Change calico condition --ipip<commit_after>---
- name: Calico | Install calicoctl bin
  command: rsync -piu "{{ local_release_dir }}/calico/bin/calicoctl" "{{ bin_dir }}/calicoctl"
  register: calico_copy
  changed_when: false

- name: Calico | install calicoctl
  file: path={{ bin_dir }}/calicoctl mode=0755 state=file

- name: Calico | Create calicoctl symlink (needed by kubelet)
  file:
    src: /usr/local/bin/calicoctl
    dest: /usr/bin/calicoctl
    state: link

- name: Calico | wait for etcd
  wait_for:
    port: 2379
  when: inventory_hostname in groups['kube-master']

- name: Calico | Check if calico network pool has already been configured
  uri:
    url: "http://127.0.0.1:2379/v2/keys/calico/v1/ipam/v4/pool"
    return_content: yes
    status_code: 200,404
  register: calico_conf
  run_once: true

- name: Calico | Configure calico network pool for cloud
  command: "calicoctl pool add {{ kube_pods_subnet }} --ipip"
  run_once: true
  when: calico_conf.status == 404 and cloud_provider is defined and cloud_provider == True

- name: Calico | Configure calico network pool
  command: "calicoctl pool add {{ kube_pods_subnet }}"
  run_once: true
  when: calico_conf.status == 404 and (cloud_provider is not defined or cloud_provider != True)

- name: Calico | Get calico configuration from etcd
  uri:
    url: "http://127.0.0.1:2379/v2/keys/calico/v1/ipam/v4/pool"
    return_content: yes
  register: calico_pools
  run_once: true

- name: Calico | Check if calico pool is properly configured
  fail:
    msg: 'Only one network pool must be configured and it must be the subnet {{ kube_pods_subnet }}.
    Please erase calico configuration and run the playbook again ("etcdctl rm --recursive /calico/v1/ipam/v4/pool")'
  when: ( calico_pools.json['node']['nodes'] | length > 1 ) or
        ( not calico_pools.json['node']['nodes'][0]['key'] | search(".*{{ kube_pods_subnet | ipaddr('network') }}.*") )
  run_once: true

- name: Calico | Write calico-node configuration
  template: src=calico/calico.conf.j2 dest=/usr/libexec/kubernetes/kubelet-plugins/net/exec/calico/calico_kubernetes.ini
  notify: restart calico-node

- name: Calico | Write calico-node systemd init file
  template: src=calico/calico-node.service.j2 dest=/etc/systemd/system/calico-node.service
  when: init_system == "systemd"
{'fraction_non_alphanumeric': 0.12216681776971895, 'fraction_numerical': 0.022892112420670897, 'mean_word_length': 3.8601321585903086, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6703632', 'n_tokens_mistral': 1612, 'n_tokens_neox': 1553, 'n_words': 409}