forked from leoaaraujo/playbooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
playbook_backup_objects.yml
60 lines (55 loc) · 1.28 KB
/
playbook_backup_objects.yml
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
48
49
50
51
52
53
54
55
56
57
58
59
60
---
- name: Openshift - Backup Objects
hosts: localhost
gather_facts: no
vars:
objects:
- rolebindings
- serviceaccounts
- secrets
- imagestreamtags
- cm
- egressnetworkpolicies
- rolebindingrestrictions
- limitranges
- resourcequotas
- dc
- ds
- pv
- pvc
- templates
- cronjobs
- statefulsets
- hpa
- deployments
- replicasets
- poddisruptionbudget
- endpoints
- oauthclient
- route
- rc
- is
- networkpolicies
- podpreset
tasks:
- name: "Generate list of projects"
shell: oc get projects | awk '{print $1}' | grep -v NAME
ignore_errors: yes
changed_when: false
register: projects
run_once: true
- set_fact:
projects={{ projects.stdout_lines }}
- name: "Define data variable"
shell: date '+%Y%m%d'
ignore_errors: yes
register: data
- name: "Create backup dir"
file:
dest: "/tmp/backup-objects-{{ data.stdout }}"
state: directory
- name: Openshift - Export Objects
shell: oc -n {{ item.0 }} get --export {{ item.1 }} -o yaml > /tmp/backup-objects-{{ data.stdout }}/{{ item.0 }}-{{ item.1 }}.yaml
with_nested:
- "{{ projects }}"
- "{{ objects }}"