-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_schema.yml
78 lines (70 loc) · 2.32 KB
/
create_schema.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
---
# Segment 1.
- name: Inmemory inventory creation.
hosts: all
collections:
- ibre5041.ansible_oracle_modules
become: yes
become_user: root
become_method: sudo
vars:
# Uncomment this ORACLE_SID list if you want to constrain this playbook to certain databases only
- db_list: [ TEST19C ]
tasks:
- oracle_oratab:
writable_only: true
register: sid_list
- debug:
var: sid_list
# Strip the host string and parse it to the in memory inventory.
# All the hosts will be added to the group,'server'. The playbook will be played in the group.
- name: Database target
add_host:
groups: [oracle, oracledabase]
name: '{{ inventory_hostname }}_{{ sid_list.oracle_list[item].ORACLE_SID }}'
hostname: '{{ inventory_hostname }}'
ansible_connection: ssh
ansible_ssh_user: "{{ ansible_ssh_user }}"
ansible_port: "{{ ansible_port }}"
ansible_ssh_private_key_file: "{{ ansible_ssh_private_key_file }}"
ansible_host: "{{ inventory_hostname }}"
ORACLE_HOME: "{{ sid_list.oracle_list[item].ORACLE_HOME }}"
ORACLE_SID: "{{ sid_list.oracle_list[item].ORACLE_SID }}"
oracle_owner: "{{ sid_list.oracle_list[item].owner }}"
loop: "{{ db_list | default(sid_list.oracle_list.keys())}}"
changed_when: False
# Segment 2. Software Management.
- name: Oracle DB Management
hosts: oracledabase
collections:
- ibre5041.ansible_oracle_modules
gather_facts: true
tasks:
- name: create tablespaces
oracle_tablespace:
mode: sysdba
tablespace: app
bigfile: true
size: 10G
autoextend: true
- oracle_user:
mode: sysdba
schema: myschema
authentication_type: none
default_tablespace: app
state: present
- oracle_grants:
mode: sysdba
schema: myschema
state: present
grants:
- 'create session'
- 'create any table'
- connect
- resource
environment:
ORACLE_HOME: "{{ ORACLE_HOME }}"
ORACLE_SID: "{{ ORACLE_SID }}"
become: yes
become_user: "{{ oracle_owner }}"
become_method: sudo