From 56b92812faaf642e55de07be57d59929736e4e0c Mon Sep 17 00:00:00 2001 From: ant31 <2t.antoine@gmail.com> Date: Mon, 25 Jan 2016 02:01:25 +0100 Subject: [PATCH] Fix systemd reload and calico unit --- roles/docker/tasks/main.yml | 2 ++ roles/etcd/handlers/main.yml | 7 ++++--- roles/etcd/tasks/configure.yml | 8 +------- roles/etcd/tasks/main.yml | 10 ++++++++++ roles/etcd/templates/etcd.service.j2 | 2 +- roles/kubernetes/master/handlers/main.yml | 17 ++++------------- roles/kubernetes/master/tasks/main.yml | 5 ++++- roles/kubernetes/node/handlers/main.yml | 7 ++++--- roles/kubernetes/node/tasks/main.yml | 5 ++++- roles/network_plugin/tasks/calico.yml | 5 ++++- .../templates/calico/calico-node.service.j2 | 2 +- 11 files changed, 39 insertions(+), 31 deletions(-) diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index 08c5f0e25..3d8e29f73 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -47,6 +47,8 @@ with_items: docker_package_info.pkgs when: docker_package_info.pkgs|length > 0 +- meta: flush_handlers + - name: ensure docker service is started and enabled service: name: "{{ item }}" diff --git a/roles/etcd/handlers/main.yml b/roles/etcd/handlers/main.yml index cda751429..22661c087 100644 --- a/roles/etcd/handlers/main.yml +++ b/roles/etcd/handlers/main.yml @@ -1,14 +1,15 @@ --- -- name: restart systemd-etcd +- name: restart etcd command: /bin/true notify: - reload systemd - - restart etcd + - reload etcd - name: reload systemd command: systemctl daemon-reload + when: init_system == "systemd" -- name: restart etcd +- name: reload etcd service: name: etcd state: restarted diff --git a/roles/etcd/tasks/configure.yml b/roles/etcd/tasks/configure.yml index 4b802d919..34a80ed47 100644 --- a/roles/etcd/tasks/configure.yml +++ b/roles/etcd/tasks/configure.yml @@ -7,7 +7,7 @@ when: init_system == "systemd" notify: restart systemd-etcd -- name: Configure | Write calico-node initd script +- name: Configure | Write etcd initd script template: src: deb-etcd.initd.j2 dest: /etc/init.d/etcd @@ -21,9 +21,3 @@ src: etcd.j2 dest: /etc/etcd.env notify: restart etcd - -- name: Configure | Ensure etcd is running - service: - name: etcd - state: started - enabled: yes diff --git a/roles/etcd/tasks/main.yml b/roles/etcd/tasks/main.yml index c5e8b8cb2..b91c9a252 100644 --- a/roles/etcd/tasks/main.yml +++ b/roles/etcd/tasks/main.yml @@ -6,3 +6,13 @@ command: /bin/true notify: restart etcd when: etcd_copy.stdout_lines + +# reload systemd before starting service +- meta: flush_handlers + + +- name: Ensure etcd is running + service: + name: etcd + state: started + enabled: yes diff --git a/roles/etcd/templates/etcd.service.j2 b/roles/etcd/templates/etcd.service.j2 index 876dcaa69..19cc0386e 100644 --- a/roles/etcd/templates/etcd.service.j2 +++ b/roles/etcd/templates/etcd.service.j2 @@ -1,6 +1,6 @@ [Unit] Description=etcd -Conflicts=etcd.service + [Service] User=etcd diff --git a/roles/kubernetes/master/handlers/main.yml b/roles/kubernetes/master/handlers/main.yml index 048c3801f..e5d5f7739 100644 --- a/roles/kubernetes/master/handlers/main.yml +++ b/roles/kubernetes/master/handlers/main.yml @@ -1,25 +1,16 @@ --- -- name: restart systemd-kubelet - command: /bin/true - notify: - - reload systemd - - restart kubelet -- name: restart systemd-kube-apiserver +- name: restart kube-apiserver command: /bin/true notify: - reload systemd - - restart kube-apiserver + - reload kube-apiserver - name: reload systemd command: systemctl daemon-reload + when: init_system == "systemd" -- name: restart kubelet - service: - name: kubelet - state: restarted - -- name: restart kube-apiserver +- name: reload kube-apiserver service: name: kube-apiserver state: restarted diff --git a/roles/kubernetes/master/tasks/main.yml b/roles/kubernetes/master/tasks/main.yml index aec37836f..48cfd5bc0 100644 --- a/roles/kubernetes/master/tasks/main.yml +++ b/roles/kubernetes/master/tasks/main.yml @@ -47,7 +47,7 @@ dest: "/etc/systemd/system/kube-apiserver.service" backup: yes when: init_system == "systemd" - notify: restart systemd-kube-apiserver + notify: restart kube-apiserver - name: install | Write kube-apiserver initd script template: @@ -80,6 +80,9 @@ notify: restart kube-apiserver changed_when: is_gentoken_calico|default(false) +# reload-systemd +- meta: flush_handlers + - name: Enable apiserver service: name: kube-apiserver diff --git a/roles/kubernetes/node/handlers/main.yml b/roles/kubernetes/node/handlers/main.yml index e0b39d599..81d7ca2c7 100644 --- a/roles/kubernetes/node/handlers/main.yml +++ b/roles/kubernetes/node/handlers/main.yml @@ -1,18 +1,19 @@ --- - name: reload systemd command: systemctl daemon-reload + when: init_system == "systemd" -- name: restart systemd-kubelet +- name: restart kubelet command: /bin/true notify: - reload systemd - - restart kubelet + - reload kubelet - name: set is_gentoken_calico fact set_fact: is_gentoken_calico: true -- name: restart kubelet +- name: reload kubelet service: name: kubelet state: restarted diff --git a/roles/kubernetes/node/tasks/main.yml b/roles/kubernetes/node/tasks/main.yml index 6ec2f0857..18d293615 100644 --- a/roles/kubernetes/node/tasks/main.yml +++ b/roles/kubernetes/node/tasks/main.yml @@ -41,7 +41,7 @@ - restart kubelet - name: Write proxy manifest - template: + template: src: manifests/kube-proxy.manifest.j2 dest: "{{ kube_manifest_dir }}/kube-proxy.manifest" @@ -50,6 +50,9 @@ notify: restart kubelet when: kubelet_copy.stdout_lines +# reload-systemd +- meta: flush_handlers + - name: Enable kubelet service: name: kubelet diff --git a/roles/network_plugin/tasks/calico.yml b/roles/network_plugin/tasks/calico.yml index c8eb36282..9bd3f0829 100644 --- a/roles/network_plugin/tasks/calico.yml +++ b/roles/network_plugin/tasks/calico.yml @@ -13,7 +13,8 @@ dest: /usr/bin/calicoctl state: link -- wait_for: +- name: Calico | wait for etcd + wait_for: port: 2379 when: inventory_hostname in groups['kube-master'] @@ -68,6 +69,8 @@ when: init_system == "sysvinit" and ansible_os_family == "RedHat" notify: restart calico-node +- meta: flush_handlers + - name: Calico | Enable calico-node service: name=calico-node enabled=yes state=started diff --git a/roles/network_plugin/templates/calico/calico-node.service.j2 b/roles/network_plugin/templates/calico/calico-node.service.j2 index af07e2571..5ee52305e 100644 --- a/roles/network_plugin/templates/calico/calico-node.service.j2 +++ b/roles/network_plugin/templates/calico/calico-node.service.j2 @@ -2,7 +2,7 @@ Description=Calico per-node agent Documentation=https://github.com/projectcalico/calico-docker Requires=docker.service -After=docker.service etcd2.service +After=docker.service etcd.service [Service] User=root