You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.7 KiB

  1. ---
  2. - name: Delete old certificates
  3. # noqa 302 - rm is ok here for now
  4. shell: "rm /etc/ssl/etcd/ssl/*{{ item }}* /etc/kubernetes/ssl/etcd/*{{ item }}*"
  5. with_items: "{{ old_etcds.split(',') }}"
  6. register: delete_old_cerificates
  7. ignore_errors: true
  8. when: old_etcds is defined
  9. - name: Fail if unable to delete old certificates
  10. fail:
  11. msg: "Unable to delete old certificates for: {{ item.item }}"
  12. loop: "{{ delete_old_cerificates.results }}"
  13. changed_when: false
  14. when:
  15. - old_etcds is defined
  16. - "item.rc != 0 and not 'No such file or directory' in item.stderr"
  17. - name: Get etcd cluster members
  18. shell: "{{ bin_dir }}/etcdctl member list"
  19. register: member_list
  20. changed_when: false
  21. check_mode: no
  22. environment:
  23. - ETCDCTL_API: 3
  24. - ETCDCTL_CA_FILE: /etc/ssl/etcd/ssl/ca.pem
  25. - ETCDCTL_CERT: "/etc/ssl/etcd/ssl/admin-{{ inventory_hostname }}.pem"
  26. - ETCDCTL_KEY: "/etc/ssl/etcd/ssl/admin-{{ inventory_hostname }}-key.pem"
  27. when:
  28. - has_etcdctl
  29. - etcd_cluster_is_healthy
  30. - old_etcd_members is defined
  31. - name: Remove old cluster members
  32. shell: "{{ bin_dir}}/etcdctl --endpoints={{ etcd_access_addresses }} member remove {{ item[1].replace(' ','').split(',')[0] }}"
  33. environment:
  34. - ETCDCTL_API: 3
  35. - ETCDCTL_CA_FILE: /etc/ssl/etcd/ssl/ca.pem
  36. - ETCDCTL_CERT: "/etc/ssl/etcd/ssl/admin-{{ inventory_hostname }}.pem"
  37. - ETCDCTL_KEY: "/etc/ssl/etcd/ssl/admin-{{ inventory_hostname }}-key.pem"
  38. with_nested:
  39. - "{{ old_etcd_members.split(',') }}"
  40. - "{{ member_list.stdout_lines }}"
  41. when:
  42. - has_etcdctl
  43. - etcd_cluster_is_healthy
  44. - old_etcd_members is defined
  45. - item[0] == item[1].replace(' ','').split(',')[2]