diff --git a/roles/etcd/defaults/main.yml b/roles/etcd/defaults/main.yml index 63f485719eabca35c342722c80e20f6970a6dcf3..e4234179f8b4fb8d253267e418aa1156cfca0ce8 100644 --- a/roles/etcd/defaults/main.yml +++ b/roles/etcd/defaults/main.yml @@ -3,7 +3,7 @@ etcd_version: v3.0.1 etcd_bin_dir: "{{ local_release_dir }}/etcd/etcd-{{ etcd_version }}-linux-amd64/" # Possible values: host, docker -etcd_deployment_type: "host" +etcd_deployment_type: "docker" etcd_image_repo: "quay.io/coreos/etcd" diff --git a/roles/etcd/handlers/main.yml b/roles/etcd/handlers/main.yml index cf0aaa5bf25aa0d878d655b21ff3bc73b7f8355b..cc22b1c7266008bce9d2b56ff3a18050530f8ae1 100644 --- a/roles/etcd/handlers/main.yml +++ b/roles/etcd/handlers/main.yml @@ -3,42 +3,35 @@ command: /bin/true notify: - reload systemd - - start etcd - reload etcd + - wait for etcd up - name: restart etcd-proxy command: /bin/true notify: - reload systemd - - start etcd-proxy - reload etcd-proxy + - wait for etcd up - name: reload systemd command: systemctl daemon-reload when: ansible_service_mgr == "systemd" -- name: start etcd - service: - name: etcd - enabled: yes - state: started - when: is_etcd_master - -- name: start etcd-proxy - service: - name: etcd-proxy - enabled: yes - state: started - when: is_etcd_proxy +- name: wait for etcd up + uri: url=http://localhost:2379/health + register: result + until: result.status == 200 + retries: 10 + delay: 5 - name: reload etcd service: name: etcd - state: "{{ 'restarted' if etcd_deployment_type == 'host' else 'reloaded' }}" + state: restarted when: is_etcd_master - name: reload etcd-proxy service: name: etcd-proxy - state: "{{ 'restarted' if etcd_deployment_type == 'host' else 'reloaded' }}" + state: restarted when: is_etcd_proxy diff --git a/roles/etcd/tasks/main.yml b/roles/etcd/tasks/main.yml index 34d94ab738df0706744d739cde43ce14e7329d0e..f2d31badb4f7ad68912df292daffa9bc08fbbd9d 100644 --- a/roles/etcd/tasks/main.yml +++ b/roles/etcd/tasks/main.yml @@ -5,19 +5,6 @@ - include: configure.yml - include: refresh_config.yml -- name: Restart etcd if binary changed - command: /bin/true - notify: restart etcd - when: etcd_deployment_type == "host" and etcd_copy.stdout_lines and is_etcd_master - -- name: Restart etcd-proxy if binary changed - command: /bin/true - notify: restart etcd-proxy - when: etcd_deployment_type == "host" and etcd_copy.stdout_lines and is_etcd_proxy - -# Reload systemd before starting service -- meta: flush_handlers - - name: Ensure etcd is running service: name: etcd @@ -32,6 +19,19 @@ enabled: yes when: is_etcd_proxy +- name: Restart etcd if binary changed + command: /bin/true + notify: restart etcd + when: etcd_deployment_type == "host" and etcd_copy.stdout_lines and is_etcd_master + +- name: Restart etcd-proxy if binary changed + command: /bin/true + notify: restart etcd-proxy + when: etcd_deployment_type == "host" and etcd_copy.stdout_lines and is_etcd_proxy + +# Reload systemd before starting service +- meta: flush_handlers + # After etcd cluster is assembled, make sure that # initial state of the cluster is in `existing` # state insted of `new`. diff --git a/roles/etcd/templates/etcd-docker.service.j2 b/roles/etcd/templates/etcd-docker.service.j2 index a02e84c2547edc90df6e2e774ce8d90a5550792b..e196c0b594fe1ba5cc558d42bab250c7613e7f03 100644 --- a/roles/etcd/templates/etcd-docker.service.j2 +++ b/roles/etcd/templates/etcd-docker.service.j2 @@ -22,7 +22,7 @@ ExecStartPre=-{{ docker_bin_dir | default("/usr/bin") }}/docker rm -f {{ etcd_me ExecReload={{ docker_bin_dir | default("/usr/bin") }}/docker restart {{ etcd_member_name | default("etcd-proxy") }} ExecStop={{ docker_bin_dir | default("/usr/bin") }}/docker stop {{ etcd_member_name | default("etcd-proxy") }} Restart=always -RestartSec=10s +RestartSec=15s [Install] WantedBy=multi-user.target diff --git a/roles/etcd/templates/etcd-proxy-docker.service.j2 b/roles/etcd/templates/etcd-proxy-docker.service.j2 index 757423bb4fdd9a765f9676fae9693febb26adb4d..98d548ccee96eaec1bab9d21efaddd121164bc2c 100644 --- a/roles/etcd/templates/etcd-proxy-docker.service.j2 +++ b/roles/etcd/templates/etcd-proxy-docker.service.j2 @@ -22,7 +22,7 @@ ExecStartPre=-{{ docker_bin_dir | default("/usr/bin") }}/docker rm -f {{ etcd_pr ExecReload={{ docker_bin_dir | default("/usr/bin") }}/docker restart {{ etcd_proxy_member_name | default("etcd-proxy") }} ExecStop={{ docker_bin_dir | default("/usr/bin") }}/docker stop {{ etcd_proxy_member_name | default("etcd-proxy") }} Restart=always -RestartSec=10s +RestartSec=15s [Install] WantedBy=multi-user.target diff --git a/roles/network_plugin/calico/tasks/main.yml b/roles/network_plugin/calico/tasks/main.yml index 7e732d632ec8594d4cd3db128a904973053d822a..99d97b01b2e4419840749442af922cf6c1d1c667 100644 --- a/roles/network_plugin/calico/tasks/main.yml +++ b/roles/network_plugin/calico/tasks/main.yml @@ -38,8 +38,11 @@ changed_when: false - name: Calico | wait for etcd - wait_for: - port: 2379 + 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