Browse Source

Merge pull request #5451 from ingvagabund/consolidate-etcd-upgrade

Automatic merge from submit-queue

Consolidate etcd upgrade

Consolidates `etcd_upgrade` into the `etcd` role.
OpenShift Merge Robot 7 năm trước cách đây
mục cha
commit
67ff061a94

+ 5 - 1
playbooks/common/openshift-cluster/upgrades/etcd/upgrade.yml

@@ -98,7 +98,11 @@
   serial: 1
   tasks:
   - include_role:
-      name: etcd_upgrade
+      name: etcd
+      tasks_from: upgrade_image
+    vars:
+      r_etcd_common_etcd_runtime: "host"
+      etcd_peer: "{{ openshift.common.hostname }}"
     when:
     - ansible_distribution == 'Fedora'
     - not openshift.common.is_containerized | bool

+ 8 - 7
playbooks/common/openshift-cluster/upgrades/etcd/upgrade_image_members.yml

@@ -5,13 +5,14 @@
 - name: Upgrade containerized hosts to {{ etcd_upgrade_version }}
   hosts: oo_etcd_hosts_to_upgrade
   serial: 1
-  roles:
-  - role: etcd_upgrade
-    r_etcd_upgrade_action: upgrade
-    r_etcd_upgrade_mechanism: image
-    r_etcd_upgrade_version: "{{ etcd_upgrade_version }}"
-    r_etcd_common_etcd_runtime: "{{ openshift.common.etcd_runtime }}"
-    etcd_peer: "{{ openshift.common.hostname }}"
+  tasks:
+  - include_role:
+      name: etcd
+      tasks_from: upgrade_image
+    vars:
+      r_etcd_upgrade_version: "{{ etcd_upgrade_version }}"
+      r_etcd_common_etcd_runtime: "{{ openshift.common.etcd_runtime }}"
+      etcd_peer: "{{ openshift.common.hostname }}"
     when:
     - etcd_container_version | default('99') | version_compare(etcd_upgrade_version,'<')
     - openshift.common.is_containerized | bool

+ 8 - 7
playbooks/common/openshift-cluster/upgrades/etcd/upgrade_rpm_members.yml

@@ -5,13 +5,14 @@
 - name: Upgrade to {{ etcd_upgrade_version }}
   hosts: oo_etcd_hosts_to_upgrade
   serial: 1
-  roles:
-  - role: etcd_upgrade
-    r_etcd_upgrade_action: upgrade
-    r_etcd_upgrade_mechanism: rpm
-    r_etcd_upgrade_version: "{{ etcd_upgrade_version }}"
-    r_etcd_common_etcd_runtime: "host"
-    etcd_peer: "{{ openshift.common.hostname }}"
+  tasks:
+  - include_role:
+      name: etcd
+      tasks_from: upgrade_rpm
+    vars:
+      r_etcd_upgrade_version: "{{ etcd_upgrade_version }}"
+      r_etcd_common_etcd_runtime: "host"
+      etcd_peer: "{{ openshift.common.hostname }}"
     when:
     - etcd_rpm_version.stdout | default('99') | version_compare(etcd_upgrade_version, '<')
     - ansible_distribution == 'RedHat'

+ 8 - 1
roles/etcd_upgrade/tasks/upgrade_image.yml

@@ -29,8 +29,15 @@
 ## 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: Detecting Atomic Host Operating System
+  stat:
+    path: /run/ostree-booted
+  register: l_ostree_booted
+
 - name: Upgrade etcd for etcdctl when not atomic
-  package: name=etcd state=latest
+  package:
+    name: etcd
+    state: latest
   when: not l_ostree_booted.stat.exists | bool
 
 - name: Verify cluster is healthy

roles/etcd_upgrade/tasks/upgrade_rpm.yml → roles/etcd/tasks/upgrade/upgrade_rpm.yml


+ 2 - 0
roles/etcd/tasks/upgrade_image.yml

@@ -0,0 +1,2 @@
+---
+- include: upgrade/upgrade_image.yml

+ 2 - 0
roles/etcd/tasks/upgrade_rpm.yml

@@ -0,0 +1,2 @@
+---
+- include: upgrade/upgrade_rpm.yml

+ 3 - 0
roles/etcd_common/defaults/main.yml

@@ -73,3 +73,6 @@ etcd_advertise_client_urls: "{{ etcd_url_scheme }}://{{ etcd_ip }}:{{ etcd_clien
 etcd_listen_client_urls: "{{ etcd_url_scheme }}://{{ etcd_ip }}:{{ etcd_client_port }}"
 
 etcd_systemd_dir: "/etc/systemd/system/{{ etcd_service }}.service.d"
+
+# etcd_peer needs to be set by a role caller
+etcdctlv2: "etcdctl --cert-file {{ etcd_peer_cert_file }} --key-file {{ etcd_peer_key_file }} --ca-file {{ etcd_peer_ca_file }} -C https://{{ etcd_peer }}:{{ etcd_client_port }}"

+ 0 - 3
roles/etcd_upgrade/defaults/main.yml

@@ -1,3 +0,0 @@
----
-r_etcd_upgrade_action: upgrade
-r_etcd_upgrade_mechanism: rpm

+ 0 - 17
roles/etcd_upgrade/meta/main.yml

@@ -1,17 +0,0 @@
----
-galaxy_info:
-  author: Jan Chaloupka
-  description:
-  company: Red Hat, Inc.
-  license: Apache License, Version 2.0
-  min_ansible_version: 1.9
-  platforms:
-  - name: EL
-    versions:
-    - 7
-  categories:
-  - cloud
-  - system
-dependencies:
-- role: etcd_common
-  r_etcd_common_embedded_etcd: "{{ r_etcd_upgrade_embedded_etcd }}"

+ 0 - 14
roles/etcd_upgrade/tasks/main.yml

@@ -1,14 +0,0 @@
----
-# INPUT r_etcd_upgrade_action
-- name: Fail if invalid etcd_upgrade_action provided
-  fail:
-    msg: "etcd_upgrade role can only be called with 'upgrade'"
-  when:
-  - r_etcd_upgrade_action not in ['upgrade']
-
-- name: Detecting Atomic Host Operating System
-  stat:
-    path: /run/ostree-booted
-  register: l_ostree_booted
-
-- include: "{{ r_etcd_upgrade_action }}.yml"

+ 0 - 11
roles/etcd_upgrade/tasks/upgrade.yml

@@ -1,11 +0,0 @@
----
-# INPUT r_etcd_upgrade_version
-# INPUT r_etcd_upgrade_mechanism
-- name: Failt if r_etcd_upgrade_mechanism is not set during upgrade
-  fail:
-    msg: "r_etcd_upgrade_mechanism can be only set to 'rpm' or 'image'"
-  when:
-  - r_etcd_upgrade_mechanism not in ['rpm', 'image']
-
-- name: "Upgrade {{ r_etcd_upgrade_mechanism }} based etcd"
-  include: upgrade_{{ r_etcd_upgrade_mechanism }}.yml

+ 0 - 3
roles/etcd_upgrade/vars/main.yml

@@ -1,3 +0,0 @@
----
-# EXPECTS etcd_peer
-etcdctlv2: "etcdctl --cert-file {{ etcd_peer_cert_file }} --key-file {{ etcd_peer_key_file }} --ca-file {{ etcd_peer_ca_file }} -C https://{{ etcd_peer }}:{{ etcd_client_port }}"