ansible.builtin.postgresql_schema (v2.9.24) — module

Add or remove PostgreSQL schema

| "added in version" 2.3 of ansible.builtin"

Authors: Flavien Chantelot (@Dorn-) <contact@flavien.io>, Thomas O'Donnell (@andytom)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.24

Description

Add or remove PostgreSQL schema.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a new schema with name acme in test database
  postgresql_schema:
    db: test
    name: acme
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a new schema acme with a user bob who will own it
  postgresql_schema:
    name: acme
    owner: bob
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Drop schema "acme" with cascade
  postgresql_schema:
    name: acme
    state: absent
    cascade_drop: yes

Inputs

    
name:
    aliases:
    - schema
    description:
    - Name of the schema to add or remove.
    required: true
    type: str

port:
    aliases:
    - login_port
    default: 5432
    description:
    - Database port to connect to.
    type: int

owner:
    description:
    - Name of the role to set as owner of the schema.
    type: str

state:
    choices:
    - absent
    - present
    default: present
    description:
    - The schema state.
    type: str

ca_cert:
    aliases:
    - ssl_rootcert
    description:
    - Specifies the name of a file containing SSL certificate authority (CA) certificate(s).
    - If the file exists, the server's certificate will be verified to be signed by one
      of these authorities.
    type: str
    version_added: '2.8'
    version_added_collection: ansible.builtin

database:
    aliases:
    - db
    - login_db
    default: postgres
    description:
    - Name of the database to connect to and add or remove the schema.
    type: str

ssl_mode:
    choices:
    - allow
    - disable
    - prefer
    - require
    - verify-ca
    - verify-full
    default: prefer
    description:
    - Determines whether or with what priority a secure SSL TCP/IP connection will be
      negotiated with the server.
    - See https://www.postgresql.org/docs/current/static/libpq-ssl.html for more information
      on the modes.
    - Default of C(prefer) matches libpq default.
    type: str
    version_added: '2.8'
    version_added_collection: ansible.builtin

login_host:
    default: ''
    description:
    - Host running the database.
    - If you have connection issues when using C(localhost), try to use C(127.0.0.1) instead.
    type: str

login_user:
    default: postgres
    description:
    - The username this module should use to establish its PostgreSQL session.
    type: str

cascade_drop:
    default: false
    description:
    - Drop schema with CASCADE to remove child objects.
    type: bool
    version_added: '2.8'
    version_added_collection: ansible.builtin

session_role:
    description:
    - Switch to session_role after connecting.
    - The specified session_role must be a role that the current login_user is a member
      of.
    - Permissions checking for SQL commands is carried out as though the session_role
      were the one that had logged in originally.
    type: str
    version_added: '2.8'
    version_added_collection: ansible.builtin

login_password:
    default: ''
    description:
    - The password this module should use to establish its PostgreSQL session.
    type: str

login_unix_socket:
    default: ''
    description:
    - Path to a Unix domain socket for local connections.
    type: str

Outputs

queries:
  description: List of executed queries.
  returned: always
  sample:
  - CREATE SCHEMA "acme"
  type: list
schema:
  description: Name of the schema.
  returned: success, changed
  sample: acme
  type: str

See also