add oracle instant client ansible role
This commit is contained in:
72
README.md
Normal file
72
README.md
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
ansible-role-oracleinstaclient
|
||||||
|
==============================
|
||||||
|
|
||||||
|
Install oracle instant client base package and sqlplus
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
|
||||||
|
None.
|
||||||
|
|
||||||
|
Role Variables
|
||||||
|
--------------
|
||||||
|
|
||||||
|
Make sure to update all these values when updateing packages.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# ldpath variable, do not forget to update when changing versions!
|
||||||
|
oic_pkg_version: "19.8"
|
||||||
|
oic_ld_library_path: "/usr/lib/oracle/{{ oic_pkg_version }}/client64/lib"
|
||||||
|
oic_package_base_url: "https://download.oracle.com/otn_software/linux/instantclient/19800"
|
||||||
|
oic_package_dest: "/tmp"
|
||||||
|
|
||||||
|
# oracle instant client database connection parameters
|
||||||
|
oic_databases:
|
||||||
|
- sid: TEST
|
||||||
|
host: testdb.mydbserver.com
|
||||||
|
port: 2322
|
||||||
|
service_name: TEST
|
||||||
|
|
||||||
|
# oic packages
|
||||||
|
oic_install_packages:
|
||||||
|
- { pkg_name: "oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm", pkg_hash: "sha256:c42159e5466c661cc85d7a4d062e98aa06dc84251eea9de10ba2ddf2a7ea37cd" }
|
||||||
|
- { pkg_name: "oracle-instantclient19.8-sqlplus-19.8.0.0.0-1.x86_64.rpm", pkg_hash: "sha256:436f74965d27894ce67242d6d155c41e3a561e959bf2ce8ba027931a29d63700" }
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Dependencies
|
||||||
|
------------
|
||||||
|
|
||||||
|
None.
|
||||||
|
|
||||||
|
Example Playbook
|
||||||
|
----------------
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: oracle instant client test play
|
||||||
|
hosts: all
|
||||||
|
become: true
|
||||||
|
vars:
|
||||||
|
oic_install_packages:
|
||||||
|
- { pkg_name: "oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm", pkg_hash: "sha256:c42159e5466c661cc85d7a4d062e98aa06dc84251eea9de10ba2ddf2a7ea37cd" }
|
||||||
|
- { pkg_name: "oracle-instantclient19.8-sqlplus-19.8.0.0.0-1.x86_64.rpm", pkg_hash: "sha256:436f74965d27894ce67242d6d155c41e3a561e959bf2ce8ba027931a29d63700" }
|
||||||
|
oic_databases:
|
||||||
|
- sid: TEST
|
||||||
|
host: testdb.mydbserver.com
|
||||||
|
port: 2322
|
||||||
|
service_name: TEST
|
||||||
|
roles:
|
||||||
|
- oracle_instant_client
|
||||||
|
```
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
GPLv3
|
||||||
|
|
||||||
|
Author Information
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Aaron (aaron@0x29a.ch)
|
||||||
30
defaults/main.yml
Normal file
30
defaults/main.yml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
# oracle instant client ldpath variable
|
||||||
|
oic_pkg_version: "19.8"
|
||||||
|
oic_ld_library_path: "/usr/lib/oracle/{{ oic_pkg_version }}/client64/lib"
|
||||||
|
oic_package_base_url: "https://download.oracle.com/otn_software/linux/instantclient/19800"
|
||||||
|
oic_package_dest: "/tmp"
|
||||||
|
|
||||||
|
# oracle instant client paths for env
|
||||||
|
oic_subdirectory: "/usr/lib/oracle/{{ oic_pkg_version }}/client64"
|
||||||
|
oic_config_path: "{{ oic_subdirectory }}/lib/network/admin"
|
||||||
|
oic_bin_path: "{{ oic_subdirectory }}/bin"
|
||||||
|
|
||||||
|
# oracle instant client user and group
|
||||||
|
oic_user: oracle
|
||||||
|
oic_user_id: 11000
|
||||||
|
oic_group: oinstall
|
||||||
|
oic_group_id: 11000
|
||||||
|
|
||||||
|
# oracle instant client database connection parameters
|
||||||
|
oic_databases:
|
||||||
|
- sid: TEST
|
||||||
|
host: testdb.mytestdb.com
|
||||||
|
port: 2322
|
||||||
|
service_name: TEST
|
||||||
|
|
||||||
|
# oralce instant client installed packages
|
||||||
|
oic_install_packages:
|
||||||
|
- { pkg_name: "oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm", pkg_hash: "sha256:c42159e5466c661cc85d7a4d062e98aa06dc84251eea9de10ba2ddf2a7ea37cd" }
|
||||||
|
- { pkg_name: "oracle-instantclient19.8-sqlplus-19.8.0.0.0-1.x86_64.rpm", pkg_hash: "sha256:436f74965d27894ce67242d6d155c41e3a561e959bf2ce8ba027931a29d63700" }
|
||||||
7
handlers/main.yml
Normal file
7
handlers/main.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: "run ldconfig"
|
||||||
|
command: "/sbin/ldconfig"
|
||||||
|
args:
|
||||||
|
creates: "/sbin/ldconfig"
|
||||||
|
become: True
|
||||||
53
meta/main.yml
Normal file
53
meta/main.yml
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
galaxy_info:
|
||||||
|
author: your name
|
||||||
|
description: your role description
|
||||||
|
company: your company (optional)
|
||||||
|
|
||||||
|
# If the issue tracker for your role is not on github, uncomment the
|
||||||
|
# next line and provide a value
|
||||||
|
# issue_tracker_url: http://example.com/issue/tracker
|
||||||
|
|
||||||
|
# Choose a valid license ID from https://spdx.org - some suggested licenses:
|
||||||
|
# - BSD-3-Clause (default)
|
||||||
|
# - MIT
|
||||||
|
# - GPL-2.0-or-later
|
||||||
|
# - GPL-3.0-only
|
||||||
|
# - Apache-2.0
|
||||||
|
# - CC-BY-4.0
|
||||||
|
license: license (GPL-2.0-or-later, MIT, etc)
|
||||||
|
|
||||||
|
min_ansible_version: 2.9
|
||||||
|
|
||||||
|
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||||
|
# min_ansible_container_version:
|
||||||
|
|
||||||
|
#
|
||||||
|
# Provide a list of supported platforms, and for each platform a list of versions.
|
||||||
|
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
|
||||||
|
# To view available platforms and versions (or releases), visit:
|
||||||
|
# https://galaxy.ansible.com/api/v1/platforms/
|
||||||
|
#
|
||||||
|
# platforms:
|
||||||
|
# - name: Fedora
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 25
|
||||||
|
# - name: SomePlatform
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 1.0
|
||||||
|
# - 7
|
||||||
|
# - 99.99
|
||||||
|
|
||||||
|
galaxy_tags: []
|
||||||
|
# List tags for your role here, one per line. A tag is a keyword that describes
|
||||||
|
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
||||||
|
# remove the '[]' above, if you add tags to this list.
|
||||||
|
#
|
||||||
|
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
||||||
|
# Maximum 20 tags per role.
|
||||||
|
|
||||||
|
dependencies: []
|
||||||
|
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||||
|
# if you add dependencies to this list.
|
||||||
|
|
||||||
34
tasks/config.yaml
Normal file
34
tasks/config.yaml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: ensure oracle instant client group exists
|
||||||
|
group:
|
||||||
|
state: present
|
||||||
|
name: "{{ oic_group }}"
|
||||||
|
gid: "{{ oic_group_id }}"
|
||||||
|
|
||||||
|
- name: ensure oracle instant client user exists
|
||||||
|
user:
|
||||||
|
state: present
|
||||||
|
name: "{{ oic_user }}"
|
||||||
|
uid: "{{ oic_user_id }}"
|
||||||
|
group: "{{ oic_group }}"
|
||||||
|
|
||||||
|
- name: ensure network/admin subdirectory exists
|
||||||
|
file:
|
||||||
|
path: "{{ oic_config_path }}"
|
||||||
|
state: directory
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
|
||||||
|
- name: update the $PATH variable for oracle binaries
|
||||||
|
copy:
|
||||||
|
dest: /etc/profile.d/custom-path.sh
|
||||||
|
content: 'PATH=$PATH:{{ oic_bin_path }}'
|
||||||
|
|
||||||
|
- name: push tnsnames.ora
|
||||||
|
template:
|
||||||
|
src: tnsnames.ora.j2
|
||||||
|
dest: "{{ oic_config_path }}/tnsnames.ora"
|
||||||
|
mode: 0655
|
||||||
|
owner: "{{ oic_user }}"
|
||||||
|
group: "{{ oic_group }}"
|
||||||
8
tasks/fetch.yaml
Normal file
8
tasks/fetch.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: fetch oracle instant client artifacts
|
||||||
|
get_url:
|
||||||
|
url: "{{ oic_package_base_url }}/{{ item.pkg_name }}"
|
||||||
|
dest: "{{ oic_package_dest }}"
|
||||||
|
checksum: "{{ item.pkg_hash }}"
|
||||||
|
loop: "{{ oic_install_packages }}"
|
||||||
21
tasks/install.yaml
Normal file
21
tasks/install.yaml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: install dependencies
|
||||||
|
yum:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: present
|
||||||
|
loop: "{{ oic_dependencies }}"
|
||||||
|
|
||||||
|
- name: install oracle instan client packages
|
||||||
|
yum:
|
||||||
|
name: "{{ oic_package_dest }}/{{ item.pkg_name }}"
|
||||||
|
state: present
|
||||||
|
loop: "{{ oic_install_packages }}"
|
||||||
|
|
||||||
|
- name: make sure oracle client is in the library path
|
||||||
|
lineinfile:
|
||||||
|
dest: "/etc/ld.so.conf.d/oracle-instantclient.conf"
|
||||||
|
line: "{{ oic_ld_library_path }}"
|
||||||
|
insertbefore: "BOF"
|
||||||
|
create: True
|
||||||
|
notify: "run ldconfig"
|
||||||
24
tasks/main.yaml
Normal file
24
tasks/main.yaml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: load variables based on distribution type
|
||||||
|
include_vars: '{{ item }}'
|
||||||
|
with_first_found:
|
||||||
|
- '{{ ansible_distribution }}_{{ ansible_distribution_major_version }}.yaml'
|
||||||
|
- '{{ ansible_os_family }}.yaml'
|
||||||
|
tags:
|
||||||
|
- 'oic_vars'
|
||||||
|
|
||||||
|
- name: import fetching tasks
|
||||||
|
import_tasks: fetch.yaml
|
||||||
|
tags:
|
||||||
|
- 'oic_fetch'
|
||||||
|
|
||||||
|
- name: import installation tasks
|
||||||
|
import_tasks: install.yaml
|
||||||
|
tags:
|
||||||
|
- 'oic_install'
|
||||||
|
|
||||||
|
- name: impost configuration tasks
|
||||||
|
import_tasks: config.yaml
|
||||||
|
tags:
|
||||||
|
- 'oic_config'
|
||||||
24
templates/tnsnames.ora.j2
Normal file
24
templates/tnsnames.ora.j2
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{% if oic_databases is defined %}
|
||||||
|
{% for db in oic_databases %}
|
||||||
|
{{ db.sid }} =
|
||||||
|
(DESCRIPTION =
|
||||||
|
(ADDRESS =
|
||||||
|
(PROTOCOL = TCP)
|
||||||
|
(HOST = {{ db.host }})
|
||||||
|
(PORT = {{ db.port }})
|
||||||
|
)
|
||||||
|
(CONNECT_DATA=
|
||||||
|
(SERVICE_NAME={{ db.service_name }})
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if oic_listener_host is defined and oic_listener_port is defined %}
|
||||||
|
LISTENER =
|
||||||
|
(ADDRESS =
|
||||||
|
(PROTOCOL = TCP)
|
||||||
|
(HOST = {{ oic_listener_host }})
|
||||||
|
(PORT = {{ oic_listener_port }})
|
||||||
|
)
|
||||||
|
{% endif %}
|
||||||
2
tests/inventory
Normal file
2
tests/inventory
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
localhost
|
||||||
|
|
||||||
5
tests/test.yml
Normal file
5
tests/test.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- ansible-role-oracleinstantclient
|
||||||
4
vars/RedHat_7.yaml
Normal file
4
vars/RedHat_7.yaml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
oic_dependencies:
|
||||||
|
- libaio
|
||||||
7
vars/RedHat_8.yaml
Normal file
7
vars/RedHat_8.yaml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
# To install and use oracle instant client you'll need libnsl on rhel8 which is not listed as dependency.
|
||||||
|
# See: https://access.redhat.com/solutions/4975641
|
||||||
|
oic_dependencies:
|
||||||
|
- libnsl
|
||||||
|
- libaio
|
||||||
Reference in New Issue
Block a user