-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3_oracledb_install.yaml
202 lines (174 loc) · 7.26 KB
/
3_oracledb_install.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# Work in Progress!
---
- name: Configure server - Oracle DB install.
hosts: "{{ hosts | default('db_servers') }}"
vars:
v_maj: "{{ oracle_version.split('.') | first | string }}"
v_maj_min: "{{ oracle_version.split('.')[:2] | join('.') | string }}"
tasks:
- name: Add oracle home info to root and oracle user's .bash_profiles.
tags: user_mgmt, users
ansible.builtin.lineinfile:
path: "{{ item }}"
line: "export ORACLE_HOME={{ oracle_home }}"
regexp: "export ORACLE_HOME="
create: true
loop:
- "/home/{{ oracle_user }}/.bash_profile"
- "/root/.bash_profile"
- name: Unzip Oracle Database binary.
tags: zip, db
ansible.builtin.unarchive:
src: "{{ db_zip }}"
dest: "{{ oracle_home }}"
owner: "{{ oracle_user }}"
group: oinstall
creates: "{{ oracle_home }}/runInstaller"
remote_src: true
# - name: Unzip new OPatch to replace old.
# tags: asm
# ansible.builtin.unarchive:
# src: "{{ db_opatch_zip }}"
# dest: "{{ oracle_home }}"
# remote_src: true
# owner: "{{ oracle_user }}"
# group: oinstall
# mode: '755'
# when: asm_setup
- name: Template response file for silent install.
tags: install, db, template
ansible.builtin.template:
src: db_install.rsp.j2
dest: "/home/{{ oracle_user }}/db_install.rsp"
owner: "{{ oracle_user }}"
group: oinstall
mode: '600'
- name: Install Oracle DB.
tags: install, db, runinstaller
become: true
become_user: "{{ oracle_user }}"
ansible.builtin.shell: |
set -o pipefail
source /home/{{ oracle_user }}/.bash_profile
{{ oracle_home }}/runInstaller -silent -ignorePrereqFailure -waitforcompletion -noconfig -responseFile /home/{{ oracle_user }}/db_install.rsp
register: db_install
failed_when: "'Successfully Setup Software' not in db_install.stdout"
- name: Attempting to run root.sh script...
block:
- name: Run root.sh script.
tags: install, db, root
ansible.builtin.command: "{{ oracle_home }}/root.sh"
register: root_exec
always:
- name: Print immediate output from root.sh script.
tags: install, db, root
ansible.builtin.debug:
msg: "{{ root_exec.stdout_lines }}"
- name: Check root.sh script's logs.
tags: install, db, root
ansible.builtin.shell: "find {{ oracle_home }}/install -name 'root*.log' -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -d' ' -f2- | xargs cat"
register: root_log
changed_when: false
- name: Print logs from root.sh script.
tags: install, db, root
ansible.builtin.debug:
msg: "{{ root_log.stdout_lines }}"
# - name: Template out netca response file.
# tags: install, db, netca
# ansible.builtin.template:
# src: netca.rsp.j2
# dest: "/home/{{ oracle_user }}/netca.rsp"
# owner: "{{ oracle_user }}"
# group: oinstall
# mode: '600'
# - name: Configure netca with response file.
# tags: install, db, netca
# become: true
# become_user: "{{ oracle_user }}"
# ansible.builtin.command:
# cmd: "{{ grid_home if asm_setup else oracle_home }}/bin/netca -silent -responsefile /home/{{ grid_user if asm_setup else oracle_user }}/netca.rsp"
# creates: "{{ grid_home if asm_setup else oracle_home }}/network/admin/listener.ora"
# - name: Check status of listener for debugging.
# tags: install, db, netca
# ansible.builtin.command: "lsnrctl status"
# register: lsnrctl_status
# failed_when: "'The command completed successfully' not in lsnrctl_status.stdout_lines"
# - name: Print listener status for debugging/verification.
# tags: install, db, netca
# ansible.builtin.debug:
# msg: "{{ lsnrctl_status.stdout }}"
# - name: Add SSH key to Oracle user's authorized_keys file.
# tags: oracle, ssh_copy_id, authorized_keys
# ansible.builtin.authorized_key:
# user: "{{ oracle_user }}"
# state: present
# key: "{{ lookup('file', ansible_ssh_private_key_file + '.pub') }}"
- hosts: "{{ hosts | default('db_servers') }}"
vars:
ansible_user: "{{ oracle_user }}"
ansible_ssh_password: "{{ oracle_pass }}"
v_maj: "{{ oracle_version.split('.') | first | string }}"
v_maj_min: "{{ oracle_version.split('.')[:2] | join('.') | string }}"
tasks:
- name: Template out dbca response file.
tags: install, db, dbca
ansible.builtin.template:
src: dbca.rsp.j2
dest: "/home/{{ oracle_user }}/dbca.rsp"
owner: "{{ oracle_user }}"
group: oinstall
mode: '600'
- name: Attempting to create Oracle database instance...
block:
- name: Initiate asynchronous creation of Oracle Database instance using dbca.
tags: install, db, dbca
ansible.builtin.command:
cmd: "{{ oracle_home }}/bin/dbca -silent -createDatabase -responseFile /home/{{ oracle_user }}/dbca.rsp"
creates: "{{ oracle_home }}/dbs/init{{ db_unique_name }}.ora"
async: 3630
poll: 0
register: dbca
- name: Wait 1 minute before running first status check on dbca process.
tags: install, db, dbca
ansible.builtin.pause:
minutes: 1
# - name: Checking status of database instance creation - checking every minute. This may take 15 minutes to an hour.
# tags: install, db, dbca
# ansible.builtin.async_status:
# jid: "{{ dbca.ansible_job_id }}"
# register: dbca_check
- name: Checking status of database instance creation every minute. This may take 15 minutes to an hour.
tags: install, db, dbca
vars:
dbca_jid: "{{ dbca.ansible_job_id }}"
ansible.builtin.include_tasks:
file: tasks/check_dbca_status.yaml
always:
- name: Last status check of database instance creation for debugging / verification.
tags: install, db, dbca
ansible.builtin.async_status:
jid: "{{ dbca.ansible_job_id }}"
register: dbca_check
- name: Gather ansible_date_time.time fact for timestamp.
tags: install, db, dbca
ansible.builtin.setup:
gather_subset: [date_time]
- name: Get latest updates from log file for status on Oracle database creation process.
tags: install, db, dbca
ansible.builtin.command: "tail -n 20 {{ oracle_base }}/cfgtoollogs/dbca/{{ db_unique_name }}/{{ db_unique_name }}.log"
register: dbca_log
- name: Print dbca status.
tags: install, db, dbca
ansible.builtin.debug:
msg: |
INFO: {{ ansible_date_time.time }} - {{ db_unique_name }} creation status:
{{ dbca_log.stdout_lines | to_nice_yaml }}
- name: Cleanup async job cache for database creation.
tags: install, db, dbca
ansible.builtin.async_status:
jid: "{{ dbca.ansible_job_id }}"
mode: cleanup
# - name: Print output of dbca process for debugging / verification.
# tags: install, db, dbca
# ansible.builtin.debug:
# msg: "{{ dbca.stdout }}"