postgresql-schema-exists

Description

Ensures a schema exists for an (existing) postgresql database.

Variables

Name Type Default Description

db_name

string --

The name of the database to connect to and add the schema. Required

db_schema_name

string --

Name of the schema to add. Required

db_user

string --

The name of the role to set as owner of the schema. Required

Code

doc:
  short_help: Ensures a schema exists for an (existing) postgresql database.

args:
  db_schema_name:
    doc:
      short_help: Name of the schema to add.
    type: string
    required: true
  db_name:
    doc:
      short_help: The name of the database to connect to and add the schema.
    type: string
    required: true
  db_user:
    doc:
      short_help: The name of the role to set as owner of the schema.
    type: string
    required: true

frecklets:
- task:
    become: true
    become_user: postgres
  frecklet:
    name: postgresql_schema
    type: ansible-module
    properties:
      idempotent: true
      elevated: true
      internet: false
    desc:
      short: 'create database schema: {{:: db_schema_name ::}}'
      references:
        "'postgresql_schema' Ansible module": https://docs.ansible.com/ansible/latest/modules/postgresql_schema_module.html
  vars:
    name: '{{:: db_schema_name ::}}'
    database: '{{:: db_name ::}}'
    owner: '{{:: db_user ::}}'
    state: present
frecklecute postgresql-schema-exists --help

Usage: frecklecute postgresql-schema-exists [OPTIONS]

  Ensures a schema exists for an (existing) postgresql database.

Options:
  --db-name DB_NAME               The name of the database to connect to and
                                  add the schema.  [required]
  --db-schema-name DB_SCHEMA_NAME
                                  Name of the schema to add.  [required]
  --db-user DB_USER               The name of the role to set as owner of the
                                  schema.  [required]
  --help                          Show this message and exit.
# -*- coding: utf-8 -*-


#
# module path: pycklets.postgresql_schema_exists.PostgresqlSchemaExists
#


from dataclasses import dataclass
from pyckles import AutoPycklet
from typing import *    # noqa

@dataclass
class PostgresqlSchemaExists(AutoPycklet):
    """Ensures a schema exists for an (existing) postgresql database.

       Args:
         db_name: The name of the database to connect to and add the schema.
         db_schema_name: Name of the schema to add.
         db_user: The name of the role to set as owner of the schema.

    """

    FRECKLET_ID = "postgresql-schema-exists"

    db_name: str = None
    db_schema_name: str = None
    db_user: str = None


    def __post_init__(self):
        super(PostgresqlSchemaExists, self).__init__(var_names=["db_name", "db_schema_name", "db_user"])


frecklet_class = PostgresqlSchemaExists
# -*- coding: utf-8 -*-


#
# module path: pycklets.postgresql_schema_exists.PostgresqlSchemaExists
#


from pyckles import AutoPycklet

class PostgresqlSchemaExists(AutoPycklet):
    """Ensures a schema exists for an (existing) postgresql database.

       Args:
         db_name: The name of the database to connect to and add the schema.
         db_schema_name: Name of the schema to add.
         db_user: The name of the role to set as owner of the schema.

    """

    FRECKLET_ID = "postgresql-schema-exists"

    def __init__(self, db_name=None, db_schema_name=None, db_user=None):

        super(PostgresqlSchemaExists, self).__init__(var_names=["db_name", "db_schema_name", "db_user"])
        self._db_name = db_name
        self._db_schema_name = db_schema_name
        self._db_user = db_user

    @property
    def db_name(self):
        return self._db_name

    @db_name.setter
    def db_name(self, db_name):
        self._db_name = db_name

    @property
    def db_schema_name(self):
        return self._db_schema_name

    @db_schema_name.setter
    def db_schema_name(self, db_schema_name):
        self._db_schema_name = db_schema_name

    @property
    def db_user(self):
        return self._db_user

    @db_user.setter
    def db_user(self, db_user):
        self._db_user = db_user



frecklet_class = PostgresqlSchemaExists