This project is a fork from https://github.com/oravirt/ansible-oracle-modules made by @oravirt.
The purpose of the fork is to :
- use Ansible standards (check mode, diff mode, ansible-doc, ansible-test, ...),
- clean code,
- reuse code with module_utils,
- change the gathering of modules into a collection to ease its use and versioning,
- fix bugs, add features, add tests.
Theses modules are a collection on Ansible Galaxy. The collection page is here : https://galaxy.ansible.com/ari_stark/ansible_oracle_modules.
The Python module cx_Oracle
needs to be installed on the Ansible host. (pip install cx_Oracle
)
- This module manages Oracle directory objects.
- It can create, replace or drop directories.
- This module return some facts about Oracle database.
- It requires privileges to access v$database.
- The option
gather_subset
can filter facts to gather and return.
- This module manages Oracle privileges.
- It can deal with system privileges, role privileges and object privileges (procedure, function, package, package body and directory).
- It has 3 possible states:
present
,absent
andidentical
. Statespresent
andabsent
ensure privileges are present or absent. Stateidentical
replace privileges with the ones in parameter.
- This module manages parameters in an Oracle database (i.e alter system set param=value).
- Parameters value comparison is case sensitive, module wise. To avoid Ansible changed state, check the case of the value.
- Hidden parameters can be changed using sysdba privileges.
Note: When specifying sga-parameters the database requests memory based on granules which are variable in size depending on the size requested, and that means the database may round the requested value to the nearest multiple of a granule. e.g sga_max_size=1500M will be rounded up to 1504 (which is 94 granules of 16MB). That will cause the displayed value to be 1504M, which has the effect that the next time the module is is run with a desired value of 1500M it will be changed again. So that is something to consider when setting parameters that affects the SGA.
- This module manages pluggable databases (PDB) in an Oracle container database (CDB).
- It can :
- create a PDB from seed, clone a PDB or plug a PDB from XML ;
- drop or unplug a PDB ;
- open or close a PDB.
- Only a few Oracle options are available to create, drop or alter a pluggable database.
- This module manages Oracle quota for users.
- It can ensure a single quota is present/absent.
- It can ensure a list of quotas matches the quotas in database.
- It can ensure a user has no quota.
- Username and tablespace name are case insensitive.
- This module manages Oracle role objects.
- It handles creation and deletion of roles.
- It doesn't support changing password. There's no hint to know a password was changed, so no change is made.
- This module executes SQL queries or PL/SQL blocks.
- It can be used to execute select statements to fetch data from database.
- It can be used to execute arbitrary SQL statement. Connection is set to autocommit, so there's no transaction management.
- It can be used to execute PL/SQL blocks.
- It cannot execute SQL statements and PL/SQL blocks in one call.
- Its inputs are direct SQL or a file containing SQL.
- This module manages Oracle tablespace objects.
- It can create, alter or drop tablespaces and datafiles.
- It supports permanent, undo and temporary tablespaces.
- It supports online/offline state and read only/read write state.
- It doesn't support defining default tablespace and other more specific actions.
- It supports check mode, diff mode and it returns DDL requests executed by the module.
- This module manages Oracle user/schema.
- It can create, alter or drop users.
- It can empty schemas (droping all its content).
- It can change password of users ; lock/unlock and expire/unexpire accounts.
- It can't be used to give privileges (refer to oracle_grant).
pre-req: cx_Oracle
- Manages ASM diskgroup state. (absent/present)
- Takes a list of disks and makes sure those disks are part of the DG. If the disk is removed from the disk it will be removed from the DG.
- Also manages attributes
Note:
- Supports redundancy levels, but does not yet handle specifying failuregroups
- Manages ASM volumes. (absent/present)
pre-req: cx_Oracle, datetime
- Manages AWR snapshot settings
pre-rec: cx_Oracle
- Create/remove databases (cdb/non-cdb)
- Can be created by passing in a responsefile or just by using parameters
- Gathers facts about Grid Infrastructure cluster configuration
pre-req: cx_Oracle, re
- Manages DBMS_SCHEDULER jobs
pre-req: cx_Oracle
- Manages DBMS_SCHEDULER job classes
pre-req: cx_Oracle, re
- Manages DBMS_SCHEDULER job schedules
pre-req: cx_Oracle, datetime
- Manages DBMS_SCHEDULER windows
pre-req: cx_Oracle, ldap, re
- Syncronises users/role grants from LDAP/Active Directory to the database
pre-rec: cx_Oracle
- Manage redo-groups and their size in RAC or single instance environments
- NOTE: For RAC environments, the database needs to be in ARCHIVELOG mode. This is not required for SI environments.
pre-req: cx_Oracle, re
- Manages resource manager consumer groups including its mappings and grants
pre-req: cx_Oracle (if GI is not running)
- Manages services in an Oracle database (RAC/Single instance)
Note: At the moment, Idempotence only applies to the state (present,absent,started, stopped). No other options are considered.
pre-req: cx_Oracle
- Managing DBMS_STATS global preferences
Tests are made against an Oracle XE 18.4 database. Tests are now started with ansible-test.
- Compile and sanity tests were run against Python 2.7 and 3.5 to 3.9. There's still a lot of change to make to comply to sanity tests, but compile error should all be fixed.
- Integration tests for refactored modules are available in
tests/integration
. - Unit tests are available in
tests/unit
. - Lots of tests are still missing, specificaly for non refactored modules.
To run tests:
ansible-test sanity --docker default
ansible-test units --docker default --python [2.7|3.6|...]
ansible-test integration
(requires a local database, and only run with Ansible version >=2.10 due to the use or community.general.json_query filter)
To run code coverage:
ansible-test coverage erase
ansible-test integration --coverage
ansible-test coverage report
oransible-test coverage html
for more details.