summaryrefslogtreecommitdiffstats
path: root/playbooks/common
diff options
context:
space:
mode:
authorOpenShift Bot <eparis+openshiftbot@redhat.com>2017-04-25 22:47:20 -0500
committerGitHub <noreply@github.com>2017-04-25 22:47:20 -0500
commit9fa4e1c17ddf5e6554ded7ecdc3432e526df561e (patch)
tree4e7344eb1f1ab11c55e94563da7b0f80f85c06a5 /playbooks/common
parent4805e68a752382c8014aede29fc6a615f0428b62 (diff)
parent974f01c81d11027a7d944fc547df4ab557e99e58 (diff)
downloadopenshift-9fa4e1c17ddf5e6554ded7ecdc3432e526df561e.tar.gz
openshift-9fa4e1c17ddf5e6554ded7ecdc3432e526df561e.tar.bz2
openshift-9fa4e1c17ddf5e6554ded7ecdc3432e526df561e.tar.xz
openshift-9fa4e1c17ddf5e6554ded7ecdc3432e526df561e.zip
Merge pull request #3860 from sdodson/backup-v3-data
Merged by openshift-bot
Diffstat (limited to 'playbooks/common')
-rw-r--r--playbooks/common/openshift-cluster/upgrades/etcd/backup.yml60
1 files changed, 28 insertions, 32 deletions
diff --git a/playbooks/common/openshift-cluster/upgrades/etcd/backup.yml b/playbooks/common/openshift-cluster/upgrades/etcd/backup.yml
index 7ef79afa9..fb51a0061 100644
--- a/playbooks/common/openshift-cluster/upgrades/etcd/backup.yml
+++ b/playbooks/common/openshift-cluster/upgrades/etcd/backup.yml
@@ -3,8 +3,8 @@
hosts: etcd_hosts_to_backup
vars:
embedded_etcd: "{{ groups.oo_etcd_to_config | default([]) | length == 0 }}"
- timestamp: "{{ lookup('pipe', 'date +%Y%m%d%H%M%S') }}"
etcdctl_command: "{{ 'etcdctl' if not openshift.common.is_containerized or embedded_etcd else 'docker exec etcd_container etcdctl' if not openshift.common.is_etcd_system_container else 'runc exec etcd etcdctl' }}"
+ timestamp: "{{ lookup('pipe', 'date +%Y%m%d%H%M%S') }}"
roles:
- openshift_facts
tasks:
@@ -13,29 +13,20 @@
role: etcd
local_facts: {}
when: "'etcd' not in openshift"
-
- - stat: path=/var/lib/openshift
- register: var_lib_openshift
-
- - stat: path=/var/lib/origin
- register: var_lib_origin
-
- - name: Create origin symlink if necessary
- file: src=/var/lib/openshift/ dest=/var/lib/origin state=link
- when: var_lib_openshift.stat.exists == True and var_lib_origin.stat.exists == False
+ - set_fact:
+ etcd_backup_dir: "{{ openshift.etcd.etcd_data_dir }}/openshift-backup-{{ backup_tag | default('') }}{{ timestamp }}"
# TODO: replace shell module with command and update later checks
- # We assume to be using the data dir for all backups.
- name: Check available disk space for etcd backup
- shell: df --output=avail -k {{ openshift.common.data_dir }} | tail -n 1
+ shell: df --output=avail -k {{ openshift.etcd.etcd_data_dir }} | tail -n 1
register: avail_disk
# AUDIT:changed_when: `false` because we are only inspecting
# state, not manipulating anything
changed_when: false
# TODO: replace shell module with command and update later checks
- - name: Check current embedded etcd disk usage
- shell: du -k {{ openshift.etcd.etcd_data_dir }} | tail -n 1 | cut -f1
+ - name: Check current etcd disk usage
+ shell: du --exclude='*openshift-backup*' -k {{ openshift.etcd.etcd_data_dir }} | tail -n 1 | cut -f1
register: etcd_disk_usage
when: embedded_etcd | bool
# AUDIT:changed_when: `false` because we are only inspecting
@@ -52,37 +43,42 @@
# For non containerized and non embedded we should have the correct version of
# etcd installed already. So don't do anything.
#
- # For embedded or containerized we need to use the latest because OCP 3.3 uses
- # a version of etcd that can only be backed up with etcd-3.x and if it's
- # containerized then etcd version may be newer than that on the host so
- # upgrade it.
- #
- # On atomic we have neither yum nor dnf so ansible throws a hard to debug error
- # if you use package there, like this: "Could not find a module for unknown."
- # see https://bugzilla.redhat.com/show_bug.cgi?id=1408668
+ # For containerized installs we now exec into etcd_container
#
- # TODO - We should refactor all containerized backups to use the containerized
- # version of etcd to perform the backup rather than relying on the host's
- # binaries. Until we do that we'll continue to have problems backing up etcd
- # when atomic host has an older version than the version that's running in the
- # container whether that's embedded or not
- - name: Install latest etcd for containerized or embedded
+ # For embedded non containerized we need to ensure we have the latest version
+ # etcd on the host.
+ - name: Install latest etcd for embedded
package:
name: etcd
state: latest
- when: ( embedded_etcd | bool or openshift.common.is_containerized ) and not openshift.common.is_atomic
+ when:
+ - embedded_etcd | bool
+ - not openshift.common.is_atomic | bool
- name: Generate etcd backup
command: >
{{ etcdctl_command }} backup --data-dir={{ openshift.etcd.etcd_data_dir }}
- --backup-dir={{ openshift.common.data_dir }}/etcd-backup-{{ backup_tag | default('') }}{{ timestamp }}
+ --backup-dir={{ etcd_backup_dir }}
+
+ # According to the docs change you can simply copy snap/db
+ # https://github.com/openshift/openshift-docs/commit/b38042de02d9780842dce95cfa0ef45d53b58bc6
+ - name: Check for v3 data store
+ stat:
+ path: "{{ openshift.etcd.etcd_data_dir }}/member/snap/db"
+ register: v3_db
+
+ - name: Copy etcd v3 data store
+ command: >
+ cp -a {{ openshift.etcd.etcd_data_dir }}/member/snap/db
+ {{ etcd_backup_dir }}/member/snap/
+ when: v3_db.stat.exists
- set_fact:
etcd_backup_complete: True
- name: Display location of etcd backup
debug:
- msg: "Etcd backup created in {{ openshift.common.data_dir }}/etcd-backup-{{ backup_tag | default('') }}{{ timestamp }}"
+ msg: "Etcd backup created in {{ etcd_backup_dir }}"
- name: Gate on etcd backup
hosts: localhost