-
Notifications
You must be signed in to change notification settings - Fork 3
/
database_clone2.yaml
90 lines (73 loc) · 2.19 KB
/
database_clone2.yaml
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
---
# Summary of Steps
# 1. Stop target database (if running)
# 2. Unmount the filesystem on target server (if mounted)
# 3. Take snapshot of the source volumes on Pure
# 4. Mount the cloned volumes on target server
# 5. Bring up the database on target server in mount mode
# 6. Change the database name using nid
# 7. Rename the directories on cloned database
# 8. Bring up the database & change filenames
#
- name: Oracle Database Refresh v2
hosts: tgtservers
vars_files:
- vars/arrays.yaml
- vars/database.yaml
collections:
- purestorage.flasharray
tasks:
# Set Suffix
- set_fact:
suffix: "ansible{{ 1000 | random }}"
run_once: yes
# Set-up
- include: tasks/setup.yaml
tags: setup
# Create Oracle admin directories
- include: tasks/create_admin.yaml
tags: setup
# - pause:
# prompt: "Look in /tmp"
# Take Snapshot of database volumes
- include: tasks/take_snapshot2.yaml
run_once: yes
# - meta: end_play
# Stop Target Database
- include: tasks/shutdown_DB.yaml
tags: shutdown
# Unmount Target volume
- include: tasks/unmount_volume.yaml
tags: unmount
# Copy Snapshot to target database volume
- include: tasks/copy_volume2.yaml
tags: refresh
# Create database volumes tags
- include: tasks/create_tag.yaml
tags: refresh
# - meta: end_play
# Mount Target volume
- include: tasks/mount_volume.yaml
tags: mount
# Startup Mount Target Database
- include: tasks/5_startup.yaml
tags: startup
# Change Database Name
- name: Change database name
shell: '{{ tgt_dir }}/6_dbnewid.sh > 6_dbnewid.log 2>&1'
args:
chdir: "{{ tgt_dir }}"
# Rename target database file names
- name: Rename Target database directories
shell: 'mv -v {{ item.value.sourced }} {{ item.value.targetd }}'
args:
chdir: "{{ tgt_dir }}"
with_dict: "{{ dirmap }}"
# Rename target database file names
- name: Rename Target database file names
shell: '{{ tgt_dir }}/8_rendbfiles.sh > 8_rendbfiles.log 2>&1'
args:
chdir: "{{ tgt_dir }}"
# Delete Snapshot of database volumes
- include: tasks/delete_snapshot2.yaml
run_once: yes