forked from oravirt/ansible-oracle-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-modules.yml
executable file
·134 lines (106 loc) · 5.4 KB
/
test-modules.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
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
# Test playbook to test all oracle modules
---
- hosts: moddev
user: vagrant
sudo: yes
sudo_user: oracle
gather_facts: false
vars:
oracle_home: /u01/app/oracle/11.2.0.4/home1
hostname: moddev1
service_name: asmdb
set_init_mode: sysdba
set_init_user: sys
user: system
password: Oracle123
oracle_env:
ORACLE_HOME: "{{ oracle_home }}"
LD_LIBRARY_PATH: "{{ oracle_home }}/lib"
set_init: False
restart_db: False
init_parameters:
- { name: db_recovery_file_dest_size, value: 4G, state: present, scope: both }
- { name: db_recovery_file_dest, value: '+FRA', state: present, scope: both }
- { name: pga_aggregate_target, value: 300M, state: present, scope: both }
- { name: _parallel_statement_queuing, value: true, state: present, scope: both }
- { name: sga_target, value: 900M, state: present, scope: spfile }
- { name: sga_max_size, value: 900M, state: present, scope: spfile }
- { name: open_cursors, value: 400, state: present, scope: both }
- { name: processes, value: 700, state: present, scope: spfile }
- { name: log_archive_dest_2, value: 'service=hippie2, LGWR ASYNC NOAFFIRM db_unique_name=hippie2 valid_for=(online_logfile,primary_role)', state: present, scope: both }
tablespaces:
- { name: newtbs, datafile: '+DATA', size: 5M, bigfile: True, autoextend: false , next: 5M, maxsize: 500M, content: permanent, state: present }
- { name: newundo, datafile: '+DATA', size: 5M, bigfile: false, autoextend: true, next: 5M, maxsize: 500M, content: undo, state: present }
- { name: newtemp, datafile: '+DATA', size: 5M, bigfile: false, autoextend: on, next: 5M, maxsize: 500M, content: temp, state: present }
dba_user:
- schema: dbauser
schema_password_hash: B7C930D09B3AF263 # passwd = dbauser
state: present
default_tablespace: users
grants:
- "dba"
passw_user:
- schema: userpw
schema_password: userpw
state: present
default_tablespace: newtbs
grants:
- "approle1"
roles:
- name: approle1
role_grants:
- 'create session'
- 'select any table'
state: present
tasks:
- name: Create tablespace
oracle_tablespace: hostname={{ hostname }} service_name={{ service_name }} user={{ user }} password={{ password }} tablespace={{ item.name }} datafile={{ item.datafile }} size={{ item.size }} bigfile={{ item.bigfile }} autoextend={{ item.autoextend }} next={{ item.next }} maxsize={{ item.maxsize }} content={{ item.content }} state={{ item.state }}
environment: oracle_env
with_items: tablespaces
- name: Create application role
oracle_role: hostname={{ hostname }} service_name={{ service_name }} user={{ user }} password={{ password }} role={{ item.name }} state={{ item.state }}
environment: oracle_env
with_items: roles
- name: Add grants to role
oracle_grants: hostname={{ hostname }} service_name={{ service_name }} user={{ user }} password={{ password }} role={{ item.0.name }} grants="{{ item.1 }}" state={{ item.0.state }}
environment: oracle_env
with_subelements:
- roles
- role_grants
- name: Create DBA user
oracle_user: hostname={{ hostname }} service_name={{ service_name }} mode=normal user={{ user }} password={{ password }} schema={{ item.0.schema }} schema_password_hash={{ item.0.schema_password_hash }} state={{ item.0.state }} default_tablespace={{ item.0.default_tablespace }} grants={{ item.1 }}
environment: oracle_env
with_subelements:
- dba_user
- grants
- name: Create Application user
oracle_user: hostname={{ hostname }} service_name={{ service_name }} mode=normal user={{ user }} password={{ password }} schema={{ item.0.schema }} schema_password={{ item.0.schema_password }} state={{ item.0.state }} default_tablespace={{ item.0.default_tablespace }} grants={{ item.1 }}
environment: oracle_env
with_subelements:
- passw_user
- grants
- name: Set parameters
oracle_parameter: hostname={{ hostname }} service_name={{ service_name }} user={{ set_init_user }} password={{ password }} mode={{ set_init_mode }} name={{ item.name }} value="{{ item.value }}" state={{ item.state }} scope={{ item.scope }}
environment: oracle_env
with_items: init_parameters
when: set_init
register: param_change
- name: Restart database (stop)
shell: "{{ oracle_home }}/bin/srvctl stop database -d {{ service_name }}"
environment: oracle_env
when: param_change.changed and set_init and restart_db
- name: Restart database (start)
shell: "{{ oracle_home }}/bin/srvctl start database -d {{ service_name }}"
environment: oracle_env
when: param_change.changed and set_init and restart_db
- name: Check if database is running
shell: "{{ oracle_home }}/bin/srvctl status database -d {{ service_name }}"
environment: oracle_env
register: check_db_up
when: restart_db
tags: check
- name: Check if database is running
debug: msg={{ item }}
with_items: check_db_up.stdout_lines
when: restart_db
tags: check