From 90037f3affcb82a857ef17d80140b64cda9d90a1 Mon Sep 17 00:00:00 2001 From: Smaine Kahlouch Date: Sat, 23 Jan 2016 17:20:33 +0100 Subject: [PATCH] use rsync instead of copy --- roles/apps/k8s-kubedns | 2 +- roles/etcd/tasks/install.yml | 13 ++++++------ roles/etcd/tasks/main.yml | 5 +++++ roles/kubernetes/master/tasks/main.yml | 23 ++++++++++------------ roles/kubernetes/node/tasks/install.yml | 7 +++---- roles/kubernetes/node/tasks/main.yml | 5 +++++ roles/kubernetes/preinstall/tasks/main.yml | 3 +++ roles/network_plugin/tasks/calico.yml | 10 ++++++++-- 8 files changed, 42 insertions(+), 26 deletions(-) diff --git a/roles/apps/k8s-kubedns b/roles/apps/k8s-kubedns index b5015aed8..d6df09a89 160000 --- a/roles/apps/k8s-kubedns +++ b/roles/apps/k8s-kubedns @@ -1 +1 @@ -Subproject commit b5015aed8ff5eed9c325911205cfbb23ad0e57be +Subproject commit d6df09a89721d98e2969a8abf29b4eb5e787fca6 diff --git a/roles/etcd/tasks/install.yml b/roles/etcd/tasks/install.yml index 679b98077..56af3b098 100644 --- a/roles/etcd/tasks/install.yml +++ b/roles/etcd/tasks/install.yml @@ -1,8 +1,9 @@ --- -- name: INSTALL | Copy etcd binaries - command: cp -pf "{{ etcd_bin_dir }}/{{ item }}" "{{ bin_dir }}" - with_items: - - etcdctl - - etcd +- name: Install | Copy etcd binary + command: rsync -piu "{{ etcd_bin_dir }}/etcd" "{{ bin_dir }}/etcd" + register: etcd_copy + changed_when: false + +- name: Install | Copy etcdctl binary + command: rsync -piu "{{ etcd_bin_dir }}/etcdctl" "{{ bin_dir }}/etcdctl" changed_when: false - notify: restart etcd diff --git a/roles/etcd/tasks/main.yml b/roles/etcd/tasks/main.yml index fdb17cf51..c5e8b8cb2 100644 --- a/roles/etcd/tasks/main.yml +++ b/roles/etcd/tasks/main.yml @@ -1,3 +1,8 @@ --- - include: install.yml - include: configure.yml + +- name: Restart etcd if binary changed + command: /bin/true + notify: restart etcd + when: etcd_copy.stdout_lines diff --git a/roles/kubernetes/master/tasks/main.yml b/roles/kubernetes/master/tasks/main.yml index d5f2d8ca8..fc70c8eb7 100644 --- a/roles/kubernetes/master/tasks/main.yml +++ b/roles/kubernetes/master/tasks/main.yml @@ -7,12 +7,14 @@ src: kubectl_bash_completion.sh dest: /etc/bash_completion.d/kubectl.sh -- name: Install kubernetes binaries - command: cp -pf "{{ local_release_dir }}/kubernetes/bin/{{ item }}" "{{ bin_dir }}/{{ item }}" +- name: Copy kube-apiserver binary + command: rsync -piu "{{ local_release_dir }}/kubernetes/bin/kube-apiserver" "{{ bin_dir }}/kube-apiserver" + register: kube_apiserver_copy + changed_when: false + +- name: Copy kubectl binary + command: rsync -piu "{{ local_release_dir }}/kubernetes/bin/kubectl" "{{ bin_dir }}/kubectl" changed_when: false - with_items: - - kubectl - - kube-apiserver - name: populate users for basic auth in API lineinfile: @@ -47,15 +49,10 @@ when: init_system == "systemd" notify: restart systemd-kube-apiserver -- name: install | Write kube-apiserver initd script - template: - src: "deb-kube-apiserver.initd.j2" - dest: "/etc/init.d/kube-apiserver" - owner: root - mode: 755 - backup: yes - when: init_system == "sysvinit" and ansible_os_family == "Debian" +- name: Restart apiserver + command: /bin/true notify: restart kube-apiserver + changed_when: is_gentoken_calico|default(false) or kube_apiserver_copy.stdout_lines - name: Allow apiserver to bind on both secure and insecure ports shell: setcap cap_net_bind_service+ep {{ bin_dir }}/kube-apiserver diff --git a/roles/kubernetes/node/tasks/install.yml b/roles/kubernetes/node/tasks/install.yml index b31ad6c6a..3d90fd033 100644 --- a/roles/kubernetes/node/tasks/install.yml +++ b/roles/kubernetes/node/tasks/install.yml @@ -15,16 +15,15 @@ notify: restart kubelet - name: install | Install kubelet binary - command: cp -pf "{{ local_release_dir }}/kubernetes/bin/kubelet" "{{ bin_dir }}/kubelet" + command: rsync -piu "{{ local_release_dir }}/kubernetes/bin/kubelet" "{{ bin_dir }}/kubelet" + register: kubelet_copy changed_when: false - notify: restart kubelet - name: install | Calico-plugin | Directory file: path=/usr/libexec/kubernetes/kubelet-plugins/net/exec/calico/ state=directory when: kube_network_plugin == "calico" - name: install | Calico-plugin | Binary - command: cp -pf "{{ local_release_dir }}/calico/bin/calico" "/usr/libexec/kubernetes/kubelet-plugins/net/exec/calico/calico" + command: rsync -piu "{{ local_release_dir }}/calico/bin/calico" "/usr/libexec/kubernetes/kubelet-plugins/net/exec/calico/calico" when: kube_network_plugin == "calico" changed_when: false - notify: restart kubelet diff --git a/roles/kubernetes/node/tasks/main.yml b/roles/kubernetes/node/tasks/main.yml index e41193585..6ec2f0857 100644 --- a/roles/kubernetes/node/tasks/main.yml +++ b/roles/kubernetes/node/tasks/main.yml @@ -45,6 +45,11 @@ src: manifests/kube-proxy.manifest.j2 dest: "{{ kube_manifest_dir }}/kube-proxy.manifest" +- name: Restart kubelet if binary changed + command: /bin/true + notify: restart kubelet + when: kubelet_copy.stdout_lines + - name: Enable kubelet service: name: kubelet diff --git a/roles/kubernetes/preinstall/tasks/main.yml b/roles/kubernetes/preinstall/tasks/main.yml index a498e6445..91c7eb33f 100644 --- a/roles/kubernetes/preinstall/tasks/main.yml +++ b/roles/kubernetes/preinstall/tasks/main.yml @@ -26,9 +26,12 @@ always_run: True register: init_system_output changed_when: False + tags: always - set_fact: init_system: "{{ init_system_output.stdout }}" + always_run: True + tags: always - name: Install python-apt for Debian distribs shell: apt-get install -y python-apt diff --git a/roles/network_plugin/tasks/calico.yml b/roles/network_plugin/tasks/calico.yml index b1dd11a37..c8eb36282 100644 --- a/roles/network_plugin/tasks/calico.yml +++ b/roles/network_plugin/tasks/calico.yml @@ -1,8 +1,8 @@ --- - name: Calico | Install calicoctl bin - command: cp -pf "{{ local_release_dir }}/calico/bin/calicoctl" "{{ bin_dir }}/calicoctl" + command: rsync -piu "{{ local_release_dir }}/calico/bin/calicoctl" "{{ bin_dir }}/calicoctl" + register: calico_copy changed_when: false - notify: restart calico-node - name: Calico | install calicoctl file: path={{ bin_dir }}/calicoctl mode=0755 state=file @@ -71,6 +71,12 @@ - name: Calico | Enable calico-node service: name=calico-node enabled=yes state=started +- name: Calico | Restart calico if binary changed + service: + name: calico-node + state: restarted + when: calico_copy.stdout_lines + - name: Calico | Disable node mesh shell: calicoctl bgp node-mesh off environment: