Skip to content

Commit 2247430

Browse files
committed
Add HOWTO for manual installation
1 parent 8eaa242 commit 2247430

File tree

1 file changed

+192
-0
lines changed

1 file changed

+192
-0
lines changed
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
:toc:
2+
:toc-placement!:
3+
:toclevels: 4
4+
toc::[]
5+
6+
:sectnums:
7+
:sectnumlevels: 4
8+
9+
= HOWTO: Local Installation of Ansible-Oracle
10+
11+
== Intro
12+
13+
This guide will show you how to get Ansible-Oracle up and running with a local installation (as opposed to a container or Vagrant setup).
14+
15+
It is assumed that the server doesn't have Internet access and therefore it's demonstrated how to install all necessary binaries manually.
16+
17+
To enable you to run the Ansible-Oracle environment independently of other versions of Ansible, Python and Galaxy modules, everything will be encapsulated within a Python Virtual Environment (venv). If you prefer to install everything globally, you'll find info on how to do so below.
18+
19+
The steps in this guide were tested with OL9.5, Python 3.9, Ansible 2.14 and Ansible-Oracle 4.11.1.
20+
21+
== What you need
22+
23+
=== Server and OS
24+
25+
* Oracle Linux 9 or RHEL 9 (this guide was tested with OL 9.5)
26+
* OS install DVD or ISO attached to your machine.
27+
* At least 50 MB free space in the /home filesystem.
28+
29+
=== Mandatory RPMs
30+
31+
These RPMs can be installed from the OS install image (DVD ISO).
32+
33+
* git
34+
* ansible-core
35+
* python3-pip
36+
37+
=== Other mandatory files
38+
39+
Download these files on a device with Internet access and transfer them to the target server's /tmp directory.
40+
41+
* ansible-oracle zip file from GitHub (this very repository)
42+
* Ansible Collections: The versions mentioned here are specific for Ansible-Oracle 4.11 and Ansible 2.14. For other versions, check the dependency list in the file "galaxy.yml" in the root directory of this repository. When downloading from Ansible Galaxy, make sure to select modules for your version Ansible.
43+
** https://galaxy.ansible.com/ui/repo/published/opitzconsulting/ansible_oracle/
44+
** https://galaxy.ansible.com/ui/repo/published/ansible/posix/ 1.5.4
45+
** https://galaxy.ansible.com/ui/repo/published/ansible/utils/ 5.1.0
46+
** https://galaxy.ansible.com/ui/repo/published/community/general/?version=9.5.4
47+
(for Ansible 2.14)
48+
** https://galaxy.ansible.com/ui/repo/published/community/crypto/
49+
** https://galaxy.ansible.com/ui/repo/published/ibre5041/ansible_oracle_modules/
50+
3.2.3
51+
** https://galaxy.ansible.com/ui/repo/published/devsec/hardening/ 8.8.0
52+
** https://galaxy.ansible.com/ui/repo/published/community/mysql/
53+
(Dependency for Hardening)
54+
* Python Packages (for `pip install`): Get them via `pip download <package>`
55+
** cx_Oracle OR:
56+
** oracledb; If you `pip download` this, you’ll also get:
57+
*** pycparser
58+
*** cffi
59+
*** cryptography
60+
61+
==== Optional:
62+
63+
* https://yum.oracle.com/repo/OracleLinux/OL9/developer/EPEL/x86_64/getPackage/tig-2.5.5-1.el9.x86_64.rpm[tig], for easier navigation of git repos.
64+
65+
== Setup Ansible
66+
67+
=== User
68+
69+
[source,bash]
70+
----
71+
dnf install -y git ansible-core python3-pip
72+
useradd ansible
73+
74+
su - ansible
75+
mkdir .ssh
76+
cd .ssh/
77+
vi authorized_keys_
78+
ssh-keygen -t ed25519
79+
## No password
80+
## Paste the contents of id_ecdsa.pub into /root/.ssh/authorized_keys on target machine
81+
----
82+
83+
=== Python Virtual Environment and Ansible Collections
84+
85+
[source,bash]
86+
----
87+
# As ansible user
88+
mkdir -p /home/ansible/ansible/inventory
89+
cd ~/ansible
90+
unzip /tmp/ansible-oracle-4.11.1.zip
91+
mv ansible-oracle-4.11.1 ansible-oracle
92+
cd ansible-oracle
93+
echo ".venv/" >> .gitignore
94+
python3 -m venv .venv
95+
96+
# Install Python Packages for this virtual environment
97+
source .venv/bin/activate
98+
pip install /tmp/python-packages/cx_Oracle-*.whl
99+
100+
# If you want to use the newer python-oracledb instead of cx_Oracle, uncomment:
101+
#pip install /tmp/python-packages/pycparser
102+
#pip install /tmp/python-packages/cffi
103+
#pip install /tmp/python-packages/cryptography
104+
#pip install /tmp/python-packages/oracledb
105+
----
106+
107+
Install packages in the virtual environment; omit the ``-p
108+
~/ansible/ansible-oracle/.venv/lib/collections'' to install for the user
109+
``ansible'':
110+
111+
[source,bash]
112+
----
113+
ansible-galaxy collection install /tmp/ansible_collections/ansible-posix-1.5.4.tar.gz -p ~/ansible/ansible-oracle/.venv/lib/collections
114+
ansible-galaxy collection install /tmp/ansible_collections/ansible-utils-5.1.0.tar.gz -p ~/ansible/ansible-oracle/.venv/lib/collections
115+
ansible-galaxy collection install /tmp/ansible_collections/community-general-9.5.4.tar.gz -p ~/ansible/ansible-oracle/.venv/lib/collections
116+
ansible-galaxy collection install /tmp/ansible_collections/community-crypto-2.24.0.tar.gz -p ~/ansible/ansible-oracle/.venv/lib/collections
117+
ansible-galaxy collection install /tmp/ansible_collections/community-mysql-3.12.0.tar.gz -p ~/ansible/ansible-oracle/.venv/lib/collections
118+
ansible-galaxy collection install /tmp/ansible_collections/devsec-hardening-8.8.0.tar.gz -p ~/ansible/ansible-oracle/.venv/lib/collections
119+
ansible-galaxy collection install /tmp/ansible_collections/ibre5041-ansible_oracle_modules-3.2.3.tar.gz -p ~/ansible/ansible-oracle/.venv/lib/collections
120+
ansible-galaxy collection install /tmp/ansible_collections/opitzconsulting-ansible_oracle-4.11.1.tar.gz -p ~/ansible/ansible-oracle/.venv/lib/collections
121+
----
122+
123+
....
124+
Starting galaxy collection install process
125+
[WARNING]: The specified collections path '/home/ansible/ansible/ansible-oracle/collections' is not part of the configured Ansible collections paths
126+
'/home/ansible/.ansible/collections:/usr/share/ansible/collections'. The installed collection will not be picked up in an Ansible run, unless within a
127+
playbook-adjacent collections directory.
128+
....
129+
130+
For background info on Ansible in a Python venv, see: https://www.redhat.com/en/blog/python-venv-ansible[How to set up and use Python virtual environments for Ansible]
131+
132+
=== Shell Alias
133+
134+
This alias for Bash sets the environment and jumps to the ansible-oracle directory.
135+
136+
`alias aov='cd ~/ansible/ansible-oracle ; source .venv/bin/activate ; export ANSIBLE_COLLECTIONS_PATHS=".venv/lib/collections:$ANSIBLE_COLLECTIONS_PATHS"'`
137+
138+
You could also define the path to the ansible collections in `ansible.cfg`:
139+
140+
[source,ini]
141+
----
142+
[defaults]
143+
collections_paths = .venv/lib/collections
144+
----
145+
146+
147+
=== SSH Key
148+
149+
For passwordless login, the ansible user needs a SSH key. This is optional, if you run on local connections or if you prefer to provide a password.
150+
151+
[source,bash]
152+
----
153+
ssh-keygen -q -t ed25519 -N '' <<< $'\ny' >/dev/null 2>&1
154+
----
155+
156+
Copy the contents of `id_ed25519.pub` to the target host’s root user
157+
into `~/.ssh/authorized_keys`.
158+
159+
== Target Host
160+
161+
=== cx_Oracle
162+
163+
The target (database) host needs `cx_Oracle` installed. Ansible-Oracle
164+
uses this module to issue database queries. The Playbook `os.yml`
165+
installs this package, when it can be downloaded or when you point it to the package from your inventory, e.g., `cx_oracle_source: "file:///tmp/cx_Oracle-7.3.0-cp27-cp27mu-manylinux1_x86_64.whl"`.
166+
167+
Otherwise, the package must be manually installed as root.
168+
169+
==== _Optional_: install cx_Oracle manually
170+
171+
As shown above, on the _target_ machine:
172+
173+
[source,bash]
174+
----
175+
pip install /tmp/python-packages/cx_Oracle-*.whl
176+
----
177+
178+
==== _Optional_: use python-oracledb instead
179+
180+
The newer python-oracledb RPM is available on yum.oracle.com For OL9,
181+
download:
182+
https://yum.oracle.com/repo/OracleLinux/OL9/developer/EPEL/x86_64/getPackage/python3-oracledb-1.2.2-1.el9.x86_64.rpm
183+
184+
[source,bash]
185+
----
186+
dnf localinstall python3-oracledb-1.2.2-1.el9.x86_64.rpm
187+
----
188+
189+
== Ready to go!
190+
191+
Activate the virtual environment by issuing `aov`.
192+
Then, run your playbooks as usual.

0 commit comments

Comments
 (0)