summaryrefslogtreecommitdiffstats
path: root/playbooks/common/openshift-cluster/upgrades/etcd/containerized_tasks.yml
blob: 35f391f8c24904aeaea7fc3de2b320bda236d8fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---
- name: Verify cluster is healthy pre-upgrade
  command: "etcdctl --cert-file /etc/etcd/peer.crt --key-file /etc/etcd/peer.key --ca-file /etc/etcd/ca.crt -C https://{{ openshift.common.hostname }}:2379 cluster-health"

- name: Get current image
  shell: grep 'ExecStart=' /etc/systemd/system/etcd_container.service | awk '{print $NF}'
  register: current_image

- name: Set new_etcd_image
  set_fact:
    new_etcd_image: "{{ current_image.stdout | regex_replace('/etcd.*$','/etcd3:' ~ upgrade_version ) if upgrade_version | version_compare('3.0','>=')
                        else current_image.stdout.split(':')[0] ~ ':' ~ upgrade_version }}"

- name: Pull new etcd image
  command: "docker pull {{ new_etcd_image }}"

- name: Update to latest etcd image
  replace:
    dest: /etc/systemd/system/etcd_container.service
    regexp: "{{ current_image.stdout }}$"
    replace: "{{ new_etcd_image }}"

- name: Restart etcd_container
  systemd:
    name: etcd_container
    daemon_reload: yes
    state: restarted

## TODO: probably should just move this into the backup playbooks, also this
## will fail on atomic host. We need to revisit how to do etcd backups there as
## the container may be newer than etcdctl on the host. Assumes etcd3 obsoletes etcd (7.3.1)
- name: Upgrade etcd for etcdctl when not atomic
  action: "{{ ansible_pkg_mgr }} name=etcd ensure=latest"
  when: not openshift.common.is_atomic | bool

- name: Verify cluster is healthy
  command: "etcdctl --cert-file /etc/etcd/peer.crt --key-file /etc/etcd/peer.key --ca-file /etc/etcd/ca.crt -C https://{{ openshift.common.hostname }}:2379 cluster-health"
  register: etcdctl
  until: etcdctl.rc == 0
  retries: 3
  delay: 10

- name: Store new etcd_image
  openshift_facts:
    role: etcd
    local_facts:
      etcd_image: "{{ new_etcd_image }}"