Skip to content

Commit b00bd7e

Browse files
Fixing issues with services and adding Readme files
1 parent 7af4070 commit b00bd7e

File tree

7 files changed

+151
-35
lines changed

7 files changed

+151
-35
lines changed

README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
11
# ansible-oracledb
2-
Using Ansible to install an Oracle datatabase 12c, I know this has been done before, but I am learning Ansible.
2+
Using Ansible to install an Oracle datatabase 12c and configure it. The following steps are executed.
3+
4+
1. The OS is configured with packages and required kernel configurations to install and configure and Oracle database.
5+
1. The Oracle database is installed and configured using an RSP file. The RSP file is configured using templates in Ansible.
6+
1. The /etc/oratab is modified to allow the usage of commands to start and to shutdown the database. The file is modified using a regular expresion, through Ansible.
7+
1. A couple of services, to manage the database and its listener, are created using templates to create services configuration files and an Ansible module called service to enable the services.
8+
1. The database and its listener are started using the Ansible module called service.
9+
10+
This can be executed with the following line.
11+
12+
ansible-playbook --ask-vault-pass -i inventories/dev/hosts site.yml --extra-vars " environment_chosen=dev"
13+
14+
The password for the vault file is Oracle.

roles/create_db_service/README.md

+31-11
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,51 @@
1-
Role Name
2-
=========
1+
create_db_service
2+
=================
33

4-
A brief description of the role goes here.
4+
This role creates a couple of systemd services to startup and shutdow the Oracle databse service and its listener. As the scripts {{ oracle_home }}/bin/dbstart and {{ oracle_home }}/bin/dbshut are used. The /etc/oratab file is modified to allow the usage of these scripts.
55

66
Requirements
77
------------
88

9-
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
9+
An Oracle database has been installed using the role install_oracle_db.
1010

1111
Role Variables
1212
--------------
1313

14-
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
14+
#### cdbs_service_path: /usr/lib/systemd/system
15+
The path used to create the service files used to manage the database and its listener as services.
16+
17+
#### oracle_base
18+
The oracle base path used by the service.
19+
20+
#### oracle_home
21+
The Oracle Home used by the service.
22+
23+
#### sid
24+
The Oracle SID used by the service.
1525

1626
Dependencies
1727
------------
1828

19-
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
29+
Before running using this, the following roles must be executed.
30+
31+
1. os_settings
32+
1. install_oracle_db
33+
34+
This role depens on some variables located at ANSIBLE-ORACLEDB/inventories/dev/group_vars/oracledb_vars.yml
2035

2136
Example Playbook
2237
----------------
2338

24-
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
39+
The following example shows how to use this role. It needs root as this will create two services one for the database and the other for the listener.
2540

26-
- hosts: servers
27-
roles:
28-
- { role: username.rolename, x: 42 }
41+
- hosts: database
42+
remote_user: oracle
43+
become: yes
44+
become_user: root
45+
tasks:
46+
# Here we will call the role to create Linux Services for Oracle database
47+
- include_role:
48+
name: create_db_service
2949

3050
License
3151
-------
@@ -35,4 +55,4 @@ BSD
3555
Author Information
3656
------------------
3757

38-
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
58+
[Linkedin](https://www.linkedin.com/in/raul-castillo-11051980/)

roles/install_oracle_db/README.md

+82-11
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,102 @@
1-
Role Name
2-
=========
1+
install_oracle_db
2+
=================
33

4-
A brief description of the role goes here.
4+
This roles installs the Oracle database 12.2.0.1.0 and configures it using an RSP file.
55

66
Requirements
77
------------
88

9-
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
9+
The role os_setting must be executed before.
1010

1111
Role Variables
1212
--------------
1313

14-
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
14+
Most of the following variables are used to configure the RSP file through templates.
15+
16+
#### inst_software_source_dir: /u01/software
17+
This is the directory where Oracle database installers are copied from.
18+
#### inst_sofware_destiny_dir: /u01/staging/oracledb # create dir, unzip installer, use as source to install
19+
This is the directory where Oracle database installers are copied from
20+
#### inst_template_dir: "{{ inst_sofware_destiny_dir }}/templates"
21+
The directory used to save the template used to generate a RSP file.
22+
#### inst_user_home: /home/oracle
23+
The directory home for the oracle user.
24+
#### inst_root_dir: "{{ inst_user_home }}/database" # database is installed here
25+
The directory where the database is installed.
26+
#### inst_db_installer: linuxx64_12201_database.zip
27+
The name of the Oracle databse installer.
28+
#### inst_install_option: INSTALL_DB_AND_CONFIG
29+
The option used on the RSP file to isntall and configure the Oracle database.
30+
#### inst_group_name: oinstall
31+
The Linux group used to install the database.
32+
#### inst_inventory_location: "{{ inst_root_dir }}/oraInventory"
33+
The directory where the inventory is saved.
34+
#### inst_oracle_home: "{{ oracle_home }}"
35+
The oracle home for the database.
36+
#### inst_ora_root_file: "{{ inst_oracle_home }}/root.sh"
37+
The file generated during the installation that must be executed by root.
38+
#### inst_ora_tab_file: /etc/oratab
39+
The file that allows us or not the execution of a command to start/shutdown the database.
40+
#### inst_oracle_base: "{{ oracle_base }}"
41+
The Oracle base directory
42+
#### inst_install_edition: SE2
43+
The Oracle install edition set within the RSP file.
44+
#### inst_dba_group: dba
45+
The dba group's name.
46+
#### inst_is_rac_install: "false"
47+
The flag used to tell the installer we do not need a RAC.
48+
#### inst_start_db_type: GENERAL_PURPOSE
49+
The type of database we want to create.
50+
#### inst_global_db_name: "{{ global_db_name }}"
51+
The global database name.
52+
#### inst_db_sid: "{{ sid }}"
53+
The database sid.
54+
#### inst_conf_as_container: "false"
55+
The flag used to say we do not want a container.
56+
#### inst_db_charset: AL32UTF8
57+
The charset we want our database to use.
58+
#### inst_automatic_memory: "false"
59+
The flag used to say we do not want automatic memory management
60+
#### inst_memory_limit: 1024
61+
Specify the total memory allocation for the database
62+
#### inst_example_schemas: "false"
63+
A flag used to tell the installer we do not want example schemas
64+
#### inst_management_option: DEFAULT
65+
If you want to manage your database using the default Database Express option
66+
#### inst_enable_recovery: "false"
67+
This variable is to be set to false if database recovery is not required
68+
#### inst_storage_type: FILE_SYSTEM_STORAGE
69+
The type of storage to use for the database
70+
#### inst_data_location: "{{ inst_root_dir }}/databasefilelocation"
71+
Specify the database file location which is a directory for datafiles, control files, redo logs
72+
#### inst_security_update: "false"
73+
Specify whether to enable the user to set the password for My Oracle Support credentials.
74+
#### inst_decline_security_update: "true"
75+
Specify whether user doesn't want to configure Security Updates
76+
#### vault_sys_password
77+
The password for sys. Varible configured in ANSIBLE-ORACLEDB/inventories/dev/group_vars/vault.yml
78+
#### vault_system_password
79+
The password for system. Varible configured in ANSIBLE-ORACLEDB/inventories/dev/group_vars/vault.yml
80+
#### vault_dbsnmp_password
81+
The password for dbsnmp. Varible configured in ANSIBLE-ORACLEDB/inventories/dev/group_vars/vault.yml
1582

1683
Dependencies
1784
------------
1885

19-
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
86+
This role depends on the exeuction of the role os_settings.
87+
88+
This role uses some variables located at ANSIBLE-ORACLEDB/inventories/dev/group_vars/oracledb_vars.yml.
2089

2190
Example Playbook
2291
----------------
2392

24-
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
93+
The following example shows how to call this role.
2594

26-
- hosts: servers
27-
roles:
28-
- { role: username.rolename, x: 42 }
95+
- hosts: database
96+
remote_user: oracle
97+
tasks:
98+
- include_role:
99+
name: install_oracle_db
29100

30101
License
31102
-------
@@ -35,4 +106,4 @@ BSD
35106
Author Information
36107
------------------
37108

38-
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
109+
[RSCC](https://www.linkedin.com/in/raul-castillo-11051980/)

roles/install_oracle_db/tasks/main.yml

-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
- name: Installing and configuring the database
3939
command: "{{ inst_sofware_destiny_dir }}/database/runInstaller \
4040
-responseFile {{ inst_template_dir }}/db_install.rsp -silent -waitforcompletion -showProgress"
41-
args:
42-
creates: "{{ inst_ora_inst_root_file }}"
4341

4442
- name: "Executing {{ inst_ora_root_file }}"
4543
command: "{{ inst_ora_root_file }}"

roles/install_oracle_db/vars/main.yml

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
inst_install_option: INSTALL_DB_AND_CONFIG
1111
inst_group_name: oinstall
1212
inst_inventory_location: "{{ inst_root_dir }}/oraInventory"
13-
inst_ora_inst_root_file: "{{ inst_inventory_location }}/orainstRoot.sh"
1413
inst_oracle_home: "{{ oracle_home }}"
1514
inst_ora_root_file: "{{ inst_oracle_home }}/root.sh"
1615
inst_ora_tab_file: /etc/oratab

roles/os_settings/README.md

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Role Name
2-
=========
1+
os_settings
2+
===========
33

44
The goal of this roles is to set the Linux Operating System v7 according to the requirements provided by Oracle to install an Oracle database 12.2
55

@@ -18,7 +18,6 @@ os_packages, a list of OS packages installed on target(s) machines.
1818
sysctl_configurations, a dictionary, which represents the configurations applied on /etc/sysctl.conf before the installation of Oracle database.
1919
limits, a dictionary, which represents the soft and hard limits for processes and files to be set before installing Oracle database.
2020

21-
2221
Dependencies
2322
------------
2423
At this moment this roles does not depend on other roles or external variables.
@@ -28,10 +27,18 @@ Example Playbook
2827

2928
This roles can be executed as is shown below.
3029

31-
- include_role:
32-
name: os_settings
30+
- hosts: database
31+
remote_user: oracle
32+
tasks:
33+
- include_role:
34+
name: os_settings
3335

3436
License
3537
-------
3638

3739
BSD
40+
41+
Author Information
42+
------------------
43+
44+
[RSCC](https://www.linkedin.com/in/raul-castillo-11051980/)

site.yml

+13-4
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,21 @@
2828
- include_role:
2929
name: create_db_service
3030

31-
- name: Starting Oracle database
32-
service:
33-
name: oracledb
34-
state: started
31+
- hosts: database
32+
remote_user: oracle
33+
tasks:
34+
- name: Stopping the database listener
35+
command: "{{ oracle_home }}/bin/lsnrctl stop"
36+
37+
- name: Stopping the database
38+
command: "{{ oracle_home }}/bin/dbshut {{ oracle_home }}"
3539

3640
- name: Starting Oracle database listener
3741
service:
3842
name: oracledblistener
3943
state: started
44+
45+
- name: Starting Oracle database
46+
service:
47+
name: oracledb
48+
state: started

0 commit comments

Comments
 (0)