<commit_before>---
- name: Calico | Set docker daemon options
  template:
    src: docker
    dest: "/etc/default/docker"
    owner: root
    group: root
    mode: 0644
  notify:
    - restart docker
  when: ansible_os_family != "CoreOS"

- meta: flush_handlers

- name: Calico | Install calicoctl container script
  template:
    src: calicoctl-container.j2
    dest: "{{ bin_dir }}/calicoctl"
    mode: 0755
    owner: root
    group: root
  changed_when: false
  notify: restart calico-node

- name: Calico | Determine hyperkube cni to use depending of the version of kube
  set_fact:
    use_hyperkube_cni: >
      {%- if kube_version | version_compare('v1.3.4','>=') -%}
        true
      {%- elif kube_version | version_compare('v1.3.4','<') -%}
        false
      {%- else -%}
        {{ ErrorCannotRecognizeVersion }}
      {%- endif -%}

- name: Calico | Install calico cni bin
  command: rsync -piu "{{ local_release_dir }}/calico/bin/calico" "/opt/cni/bin/calico"
  changed_when: false
  when: not use_hyperkube_cni

- name: Calico | Install calico-ipam cni bin
  command: rsync -piu "{{ local_release_dir }}/calico/bin/calico" "/opt/cni/bin/calico-ipam"
  changed_when: false
  when: not use_hyperkube_cni

- name: Calico | Copy cni plugins from hyperkube
  command: "/usr/bin/docker run --rm -v /opt/cni/bin:/cnibindir {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }} /bin/cp -r /opt/cni/bin/. /cnibindir/"
  register: cni_task_result
  until: cni_task_result.rc == 0
  retries: 4
  delay: "{{ 20 | random + 3 }}"
  changed_when: false
  when: use_hyperkube_cni

- name: Calico | wait for etcd
  uri: url=http://localhost:2379/health
  register: result
  until: result.status == 200
  retries: 10
  delay: 5
  when: inventory_hostname in groups['kube-master']

- name: Calico | Check if calico network pool has already been configured
  uri:
    url: "{{ etcd_endpoint }}/v2/keys/calico/v1/ipam/v4/pool"
    return_content: yes
    status_code: 200,404
  register: calico_conf
  run_once: true<commit_msg>Fix logic handling for use_hyperkube_cni<commit_after>---
- name: Calico | Set docker daemon options
  template:
    src: docker
    dest: "/etc/default/docker"
    owner: root
    group: root
    mode: 0644
  notify:
    - restart docker
  when: ansible_os_family != "CoreOS"

- meta: flush_handlers

- name: Calico | Install calicoctl container script
  template:
    src: calicoctl-container.j2
    dest: "{{ bin_dir }}/calicoctl"
    mode: 0755
    owner: root
    group: root
  changed_when: false
  notify: restart calico-node

- name: Calico | Determine hyperkube cni to use depending of the version of kube
  set_fact:
    use_hyperkube_cni: >
      {%- if kube_version | version_compare('v1.3.4','>=') -%}
        true
      {%- elif kube_version | version_compare('v1.3.4','<') -%}
        false
      {%- else -%}
        {{ ErrorCannotRecognizeVersion }}
      {%- endif -%}

- name: Calico | Install calico cni bin
  command: rsync -piu "{{ local_release_dir }}/calico/bin/calico" "/opt/cni/bin/calico"
  changed_when: false
  when: use_hyperkube_cni|bool == false

- name: Calico | Install calico-ipam cni bin
  command: rsync -piu "{{ local_release_dir }}/calico/bin/calico" "/opt/cni/bin/calico-ipam"
  changed_when: false
  when: use_hyperkube_cni|bool == false

- name: Calico | Copy cni plugins from hyperkube
  command: "/usr/bin/docker run --rm -v /opt/cni/bin:/cnibindir {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }} /bin/cp -r /opt/cni/bin/. /cnibindir/"
  register: cni_task_result
  until: cni_task_result.rc == 0
  retries: 4
  delay: "{{ 20 | random + 3 }}"
  changed_when: false
  when: use_hyperkube_cni

- name: Calico | wait for etcd
  uri: url=http://localhost:2379/health
  register: result
  until: result.status == 200
  retries: 10
  delay: 5
  when: inventory_hostname in groups['kube-master']

- name: Calico | Check if calico network pool has already been configured
  uri:
    url: "{{ etcd_endpoint }}/v2/keys/calico/v1/ipam/v4/pool"
    return_content: yes
    status_code: 200,404
  register: calico_conf
  run_once: true
{'fraction_non_alphanumeric': 0.12454212454212454, 'fraction_numerical': 0.01904761904761905, 'mean_word_length': 3.1753312945973495, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '240951', 'n_tokens_mistral': 1558, 'n_tokens_neox': 1485, 'n_words': 375}