ari_stark.ansible_oracle_modules.oracle_pdb (1.2.1) — module

Manage Oracle pluggable databases

| "added in version" 0.8.0 of ari_stark.ansible_oracle_modules"

Authors: Mikael Sandström (@oravirt), Ari Stark (@ari-stark)

Install collection

Install with ansible-galaxy collection install ari_stark.ansible_oracle_modules:==1.2.1


Add to requirements.yml

  collections:
    - name: ari_stark.ansible_oracle_modules
      version: 1.2.1

Description

This module manages Oracle pluggable databases.

It can create PDB from seed, clone PDB or plug PDB from XML ; drop or unplug a PDB ; open or close a PDB.

Only a few options are available to create, drop or alter a pluggable database.

To create of a PDB, you have to use one of these three options : I(clone_from), I(pdb_admin_username) or I(plug_file).

The check of the parameters are minimal, full responsability is delegated to Oracle to check if parameters are corrects.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Open a PDB in read write
  oracle_pdb:
    hostname: "localhost"
    service_name: "XE"
    username: "sys"
    password: "password"
    mode: "sysdba"
    pdb_name: "XEPDB2"
    state: "opened"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Open a PDB in read only
  oracle_pdb:
    hostname: "localhost"
    service_name: "XE"
    username: "sys"
    password: "password"
    mode: "sysdba"
    pdb_name: "XEPDB2"
    state: "opened"
    read_only: yes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove a PDB
  oracle_pdb:
    hostname: "localhost"
    service_name: "XE"
    username: "sys"
    password: "password"
    mode: "sysdba"
    pdb_name: "XEPDB2"
    state: "absent"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Creates a PDB
  oracle_pdb:
    hostname: "localhost"
    service_name: "XE"
    username: "sys"
    password: "password"
    mode: "sysdba"
    pdb_name: "XEPDB2"
    state: "opened"
    pdb_admin_username: "foo"
    pdb_admin_password: "bar"
    file_name_convert:
        "/opt/oracle/oradata/XE/pdbseed": "/tmp/xepdb2/dbf01"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Check the PDB exists. Do nothing but return the state of the PDB.
  oracle_pdb:
    hostname: "localhost"
    service_name: "XE"
    username: "sys"
    password: "password"
    mode: "sysdba"
    pdb_name: "XEPDB2"
    state: "present"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Unplug a PDB
  oracle_pdb:
    hostname: "localhost"
    service_name: "XE"
    username: "sys"
    password: "password"
    mode: "sysdba"
    pdb_name: "XEPDB2"
    state: "absent"
    unplug_file: "/tmp/xepdb2.xml"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Plug in a PDB to a new location
  oracle_pdb:
    hostname: "localhost"
    service_name: "XE"
    username: "sys"
    password: "password"
    mode: "sysdba"
    pdb_name: "XEPDB3"
    state: "opened"
    plug_file: "/tmp/xepdb2.xml"
    file_name_convert:
        "/tmp/xepdb2/dbf01": "/tmp/xepdb3/dbf01"

Inputs

    
mode:
    choices:
    - normal
    - sysdba
    default: normal
    description:
    - This option is the database administration privileges.
    type: str

port:
    default: 1521
    description:
    - Specify the listening port on the database server.
    type: int

roles:
    default: []
    description:
    - This option is to define roles for the PDB admin.
    - This option has meaning only with I(pdb_admin_username).
    elements: str
    type: list

state:
    choices:
    - absent
    - closed
    - opened
    - present
    default: opened
    description:
    - Change the state of a PDB.
    - Unless one of I(clone_from), I(pdb_admin_username) or I(plug_file) is defined, the
      PDB won't be created.
    - If the PDB already exists, the options used for creation will be ignored.
    - If I(absent), PDB will be dropped with existing files or unplugged.
    - If I(closed), PDB will be closed if it exists.
    - If I(opened), PDB will be opened if it exists.
    - If I(present), the state of the PDB will be returned if it exists. It's a simple
      check of PDB existence.
    - If the PDB doesn't exist, is not created and the state I(closed), I(opened) and
      I(present) are used, the task will fail.
    type: str

hostname:
    default: localhost
    description:
    - Specify the host name or IP address of the database server computer.
    type: str

password:
    description:
    - Set the password to use to connect the database server.
    - Must not be set if using Oracle wallet.
    type: str

pdb_name:
    description:
    - The name of the PDB to manage.
    required: true
    type: str

username:
    aliases:
    - user
    description:
    - Set the login to use to connect the database server.
    - Must not be set if using Oracle wallet.
    type: str

file_dest:
    description:
    - Specify the file_dest clause.
    required: false
    type: str

plug_file:
    description:
    - Set the XML file to use to plug a disconnected PDB.
    - It will trigger the creation of the PDB from a XML.
    - If I(file_name_convert) is defined, the tablespace files are copied to the new location.
    - If I(file_name_convert) is not defined, the clause NOCOPY is used.
    - It is mutually exclusive with I(clone_from) and I(pdb_admin_username).
    required: false
    type: str

read_only:
    default: false
    description:
    - Defines if the PDB is to be opened in read only.
    - This option has meaning only with I(state=opened)
    type: bool

clone_from:
    description:
    - This option is the name of the PDB to clone.
    - It will trigger the creation of the PDB as a clone.
    - It can be used in conjunction with the option I(snapshot_copy).
    - It is mutually exclusive with I(pdb_admin_username) and I(plug_file).
    required: false
    type: str

oracle_home:
    description:
    - Define the directory into which all Oracle software is installed.
    - Define ORACLE_HOME environment variable if set.
    type: str

unplug_file:
    description:
    - Set the XML file to use to unplug an existing PDB.
    - This option has meaning only when used with I(state=absent).
    - If the PDB doesn't exists, this option won't do anything.
    required: false
    type: str

service_name:
    aliases:
    - cdb_name
    description:
    - Specify the service name of the database you want to access.
    - The service name is the service to access the CDB.
    required: true
    type: str

snapshot_copy:
    default: false
    description:
    - This option is to define if the clone to create will be a snapshot copy.
    - This option has meaning only with I(clone_from).
    type: bool

file_name_convert:
    default: {}
    description:
    - Specify the file_name_convert clause.
    type: dict

pdb_admin_password:
    aliases:
    - admin_pass
    description:
    - Set the password for the PDB admin.
    - This option must be used with I(pdb_admin_username).
    required: false
    type: str

pdb_admin_username:
    aliases:
    - admin_user
    description:
    - Set the username of the PDB admin.
    - This option must be used with I(pdb_admin_password).
    - It will trigger the creation of the PDB from a seed.
    - It is mutually exclusive with I(clone_from) and I(plug_file).
    required: false
    type: str

Outputs

ddls:
  description: Ordered list of DDL requests executed during module execution.
  elements: str
  returned: always
  type: list
pdb_name:
  description: The name of the PDB.
  returned: when I(state=present)
  type: str
read_only:
  description: If the PDB is opened in read only.
  returned: when I(state=present)
  type: bool
state:
  description: The state of the PDB.
  returned: when I(state=present)
  type: str