From 856ccf0f95f9973081234877136f45a9fb7826fe Mon Sep 17 00:00:00 2001 From: Nick Mills-Barrett Date: Sat, 9 Mar 2024 11:26:48 +0000 Subject: [PATCH] Rename `postgresql` -> `postgres` operations & facts Backwards compatible with deprecation flags. --- pyinfra/facts/postgres.py | 168 +++++++++ pyinfra/facts/postgresql.py | 169 +-------- pyinfra/operations/postgres.py | 347 +++++++++++++++++ pyinfra/operations/postgresql.py | 353 +----------------- .../postgresql.database/add_database.json | 2 +- .../add_database_noop.json | 2 +- .../add_database_owner.json | 2 +- .../postgresql.database/remove_database.json | 2 +- .../remove_database_noop.json | 2 +- .../postgresql.role/role_add_noop.json | 2 +- .../postgresql.role/role_remove_noop.json | 2 +- .../operations/postgresql.role/user_add.json | 2 +- .../postgresql.role/user_add_no_login.json | 2 +- .../postgresql.role/user_add_privileges.json | 2 +- .../postgresql.role/user_add_replication.json | 2 +- .../postgresql.role/user_add_super.json | 2 +- .../postgresql.role/user_remove.json | 2 +- 17 files changed, 550 insertions(+), 513 deletions(-) create mode 100644 pyinfra/facts/postgres.py create mode 100644 pyinfra/operations/postgres.py diff --git a/pyinfra/facts/postgres.py b/pyinfra/facts/postgres.py new file mode 100644 index 000000000..af795020b --- /dev/null +++ b/pyinfra/facts/postgres.py @@ -0,0 +1,168 @@ +from __future__ import annotations + +from pyinfra.api import FactBase, MaskString, QuoteString, StringCommand +from pyinfra.api.util import try_int + +from .util.databases import parse_columns_and_rows + + +def make_psql_command( + database=None, + user=None, + password=None, + host=None, + port=None, + executable="psql", +): + target_bits: list[str] = [] + + if password: + target_bits.append(MaskString('PGPASSWORD="{0}"'.format(password))) + + target_bits.append(executable) + + if database: + target_bits.append("-d {0}".format(database)) + + if user: + target_bits.append("-U {0}".format(user)) + + if host: + target_bits.append("-h {0}".format(host)) + + if port: + target_bits.append("-p {0}".format(port)) + + return StringCommand(*target_bits) + + +def make_execute_psql_command(command, **psql_kwargs): + return StringCommand( + make_psql_command(**psql_kwargs), + "-Ac", + QuoteString(command), # quote this whole item as a single shell argument + ) + + +class PostgresFactBase(FactBase): + abstract = True + + psql_command: str + requires_command = "psql" + + def command( + self, + psql_user=None, + psql_password=None, + psql_host=None, + psql_port=None, + ): + return make_execute_psql_command( + self.psql_command, + user=psql_user, + password=psql_password, + host=psql_host, + port=psql_port, + ) + + +class PostgresRoles(PostgresFactBase): + """ + Returns a dict of PostgreSQL roles and data: + + .. code:: python + + { + "pyinfra": { + "super": true, + "createrole": false, + "createdb": false, + ... + }, + } + """ + + default = dict + psql_command = "SELECT * FROM pg_catalog.pg_roles" + + def process(self, output): + # Remove the last line of the output (row count) + output = output[:-1] + rows = parse_columns_and_rows( + output, + "|", + # Remove the "rol" prefix on column names + remove_column_prefix="rol", + ) + + users = {} + + for details in rows: + for key, value in list(details.items()): + if key in ("oid", "connlimit"): + details[key] = try_int(value) + + if key in ( + "super", + "inherit", + "createrole", + "createdb", + "canlogin", + "replication", + "bypassrls", + ): + details[key] = value == "t" + + users[details.pop("name")] = details + + return users + + +class PostgresDatabases(PostgresFactBase): + """ + Returns a dict of PostgreSQL databases and metadata: + + .. code:: python + + { + "pyinfra_stuff": { + "encoding": "UTF8", + "collate": "en_US.UTF-8", + "ctype": "en_US.UTF-8", + ... + }, + } + """ + + default = dict + psql_command = "SELECT pg_catalog.pg_encoding_to_char(encoding), * FROM pg_catalog.pg_database" + + def process(self, output): + # Remove the last line of the output (row count) + output = output[:-1] + rows = parse_columns_and_rows( + output, + "|", + # Remove the "dat" prefix on column names + remove_column_prefix="dat", + ) + + databases = {} + + for details in rows: + details["encoding"] = details.pop("pg_encoding_to_char") + + for key, value in list(details.items()): + if key.endswith("id") or key in ( + "dba", + "tablespace", + "connlimit", + ): + details[key] = try_int(value) + + if key in ("istemplate", "allowconn"): + details[key] = value == "t" + + databases[details.pop("name")] = details + + return databases diff --git a/pyinfra/facts/postgresql.py b/pyinfra/facts/postgresql.py index 87e7f7cb5..2e6934c82 100644 --- a/pyinfra/facts/postgresql.py +++ b/pyinfra/facts/postgresql.py @@ -1,168 +1,9 @@ -from __future__ import annotations +from .postgres import PostgresDatabases, PostgresRoles -from pyinfra.api import FactBase, MaskString, QuoteString, StringCommand -from pyinfra.api.util import try_int -from .util.databases import parse_columns_and_rows +class PostgresqlRoles(PostgresRoles): + deprecated = True -def make_psql_command( - database=None, - user=None, - password=None, - host=None, - port=None, - executable="psql", -): - target_bits: list[str] = [] - - if password: - target_bits.append(MaskString('PGPASSWORD="{0}"'.format(password))) - - target_bits.append(executable) - - if database: - target_bits.append("-d {0}".format(database)) - - if user: - target_bits.append("-U {0}".format(user)) - - if host: - target_bits.append("-h {0}".format(host)) - - if port: - target_bits.append("-p {0}".format(port)) - - return StringCommand(*target_bits) - - -def make_execute_psql_command(command, **psql_kwargs): - return StringCommand( - make_psql_command(**psql_kwargs), - "-Ac", - QuoteString(command), # quote this whole item as a single shell argument - ) - - -class PostgresqlFactBase(FactBase): - abstract = True - - psql_command: str - requires_command = "psql" - - def command( - self, - psql_user=None, - psql_password=None, - psql_host=None, - psql_port=None, - ): - return make_execute_psql_command( - self.psql_command, - user=psql_user, - password=psql_password, - host=psql_host, - port=psql_port, - ) - - -class PostgresqlRoles(PostgresqlFactBase): - """ - Returns a dict of PostgreSQL roles and data: - - .. code:: python - - { - "pyinfra": { - "super": true, - "createrole": false, - "createdb": false, - ... - }, - } - """ - - default = dict - psql_command = "SELECT * FROM pg_catalog.pg_roles" - - def process(self, output): - # Remove the last line of the output (row count) - output = output[:-1] - rows = parse_columns_and_rows( - output, - "|", - # Remove the "rol" prefix on column names - remove_column_prefix="rol", - ) - - users = {} - - for details in rows: - for key, value in list(details.items()): - if key in ("oid", "connlimit"): - details[key] = try_int(value) - - if key in ( - "super", - "inherit", - "createrole", - "createdb", - "canlogin", - "replication", - "bypassrls", - ): - details[key] = value == "t" - - users[details.pop("name")] = details - - return users - - -class PostgresqlDatabases(PostgresqlFactBase): - """ - Returns a dict of PostgreSQL databases and metadata: - - .. code:: python - - { - "pyinfra_stuff": { - "encoding": "UTF8", - "collate": "en_US.UTF-8", - "ctype": "en_US.UTF-8", - ... - }, - } - """ - - default = dict - psql_command = "SELECT pg_catalog.pg_encoding_to_char(encoding), * FROM pg_catalog.pg_database" - - def process(self, output): - # Remove the last line of the output (row count) - output = output[:-1] - rows = parse_columns_and_rows( - output, - "|", - # Remove the "dat" prefix on column names - remove_column_prefix="dat", - ) - - databases = {} - - for details in rows: - details["encoding"] = details.pop("pg_encoding_to_char") - - for key, value in list(details.items()): - if key.endswith("id") or key in ( - "dba", - "tablespace", - "connlimit", - ): - details[key] = try_int(value) - - if key in ("istemplate", "allowconn"): - details[key] = value == "t" - - databases[details.pop("name")] = details - - return databases +class PostgresqlDatabases(PostgresDatabases): + deprecated = True diff --git a/pyinfra/operations/postgres.py b/pyinfra/operations/postgres.py new file mode 100644 index 000000000..c099e21c3 --- /dev/null +++ b/pyinfra/operations/postgres.py @@ -0,0 +1,347 @@ +""" +The PostgreSQL modules manage PostgreSQL databases, users and privileges. + +Requires the ``psql`` CLI executable on the target host(s). + +All operations in this module take four optional arguments: + + ``psql_user``: the username to connect to postgresql to + + ``psql_password``: the password for the connecting user + + ``psql_host``: the hostname of the server to connect to + + ``psql_port``: the port of the server to connect to + +See example/postgresql.py for detailed example + +""" + +from pyinfra import host +from pyinfra.api import MaskString, StringCommand, operation +from pyinfra.facts.postgres import ( + PostgresDatabases, + PostgresRoles, + make_execute_psql_command, + make_psql_command, +) + + +@operation(is_idempotent=False) +def sql( + sql, + database=None, + # Details for speaking to PostgreSQL via `psql` CLI + psql_user=None, + psql_password=None, + psql_host=None, + psql_port=None, +): + """ + Execute arbitrary SQL against PostgreSQL. + + + sql: SQL command(s) to execute + + database: optional database to execute against + + psql_*: global module arguments, see above + """ + + yield make_execute_psql_command( + sql, + database=database, + user=psql_user, + password=psql_password, + host=psql_host, + port=psql_port, + ) + + +@operation() +def role( + role, + present=True, + password=None, + login=True, + superuser=False, + inherit=False, + createdb=False, + createrole=False, + replication=False, + connection_limit=None, + # Details for speaking to PostgreSQL via `psql` CLI + psql_user=None, + psql_password=None, + psql_host=None, + psql_port=None, +): + """ + Add/remove PostgreSQL roles. + + + role: name of the role + + present: whether the role should be present or absent + + password: the password for the role + + login: whether the role can login + + superuser: whether role will be a superuser + + inherit: whether the role inherits from other roles + + createdb: whether the role is allowed to create databases + + createrole: whether the role is allowed to create new roles + + replication: whether this role is allowed to replicate + + connection_limit: the connection limit for the role + + psql_*: global module arguments, see above + + Updates: + pyinfra will not attempt to change existing roles - it will either + create or drop roles, but not alter them (if the role exists this + operation will make no changes). + + **Example:** + + .. code:: python + + postgresql.role( + name="Create the pyinfra PostgreSQL role", + role="pyinfra", + password="somepassword", + superuser=True, + login=True, + sudo_user="postgres", + ) + + """ + + roles = host.get_fact( + PostgresRoles, + psql_user=psql_user, + psql_password=psql_password, + psql_host=psql_host, + psql_port=psql_port, + ) + + is_present = role in roles + + # User not wanted? + if not present: + if is_present: + yield make_execute_psql_command( + 'DROP ROLE "{0}"'.format(role), + user=psql_user, + password=psql_password, + host=psql_host, + port=psql_port, + ) + else: + host.noop("postgresql role {0} does not exist".format(role)) + return + + # If we want the user and they don't exist + if not is_present: + sql_bits = ['CREATE ROLE "{0}"'.format(role)] + + for key, value in ( + ("LOGIN", login), + ("SUPERUSER", superuser), + ("INHERIT", inherit), + ("CREATEDB", createdb), + ("CREATEROLE", createrole), + ("REPLICATION", replication), + ): + if value: + sql_bits.append(key) + + if connection_limit: + sql_bits.append("CONNECTION LIMIT {0}".format(connection_limit)) + + if password: + sql_bits.append(MaskString("PASSWORD '{0}'".format(password))) + + yield make_execute_psql_command( + StringCommand(*sql_bits), + user=psql_user, + password=psql_password, + host=psql_host, + port=psql_port, + ) + else: + host.noop("postgresql role {0} exists".format(role)) + + +@operation() +def database( + database, + present=True, + owner=None, + template=None, + encoding=None, + lc_collate=None, + lc_ctype=None, + tablespace=None, + connection_limit=None, + # Details for speaking to PostgreSQL via `psql` CLI + psql_user=None, + psql_password=None, + psql_host=None, + psql_port=None, +): + """ + Add/remove PostgreSQL databases. + + + name: name of the database + + present: whether the database should exist or not + + owner: the PostgreSQL role that owns the database + + template: name of the PostgreSQL template to use + + encoding: encoding of the database + + lc_collate: lc_collate of the database + + lc_ctype: lc_ctype of the database + + tablespace: the tablespace to use for the template + + connection_limit: the connection limit to apply to the database + + psql_*: global module arguments, see above + + Updates: + pyinfra will not attempt to change existing databases - it will either + create or drop databases, but not alter them (if the db exists this + operation will make no changes). + + **Example:** + + .. code:: python + + postgresql.database( + name="Create the pyinfra_stuff database", + database="pyinfra_stuff", + owner="pyinfra", + encoding="UTF8", + sudo_user="postgres", + ) + + """ + + current_databases = host.get_fact( + PostgresDatabases, + psql_user=psql_user, + psql_password=psql_password, + psql_host=psql_host, + psql_port=psql_port, + ) + + is_present = database in current_databases + + if not present: + if is_present: + yield make_execute_psql_command( + 'DROP DATABASE "{0}"'.format(database), + user=psql_user, + password=psql_password, + host=psql_host, + port=psql_port, + ) + else: + host.noop("postgresql database {0} does not exist".format(database)) + return + + # We want the database but it doesn't exist + if present and not is_present: + sql_bits = ['CREATE DATABASE "{0}"'.format(database)] + + for key, value in ( + ("OWNER", '"{0}"'.format(owner) if owner else owner), + ("TEMPLATE", template), + ("ENCODING", encoding), + ("LC_COLLATE", lc_collate), + ("LC_CTYPE", lc_ctype), + ("TABLESPACE", tablespace), + ("CONNECTION LIMIT", connection_limit), + ): + if value: + sql_bits.append("{0} {1}".format(key, value)) + + yield make_execute_psql_command( + StringCommand(*sql_bits), + user=psql_user, + password=psql_password, + host=psql_host, + port=psql_port, + ) + else: + host.noop("postgresql database {0} exists".format(database)) + + +@operation(is_idempotent=False) +def dump( + dest, + database=None, + # Details for speaking to PostgreSQL via `psql` CLI + psql_user=None, + psql_password=None, + psql_host=None, + psql_port=None, +): + """ + Dump a PostgreSQL database into a ``.sql`` file. Requires ``pg_dump``. + + + dest: name of the file to dump the SQL to + + database: name of the database to dump + + psql_*: global module arguments, see above + + **Example:** + + .. code:: python + + postgresql.dump( + name="Dump the pyinfra_stuff database", + dest="/tmp/pyinfra_stuff.dump", + database="pyinfra_stuff", + sudo_user="postgres", + ) + + """ + + yield StringCommand( + make_psql_command( + executable="pg_dump", + database=database, + user=psql_user, + password=psql_password, + host=psql_host, + port=psql_port, + ), + ">", + dest, + ) + + +@operation(is_idempotent=False) +def load( + src, + database=None, + # Details for speaking to PostgreSQL via `psql` CLI + psql_user=None, + psql_password=None, + psql_host=None, + psql_port=None, +): + """ + Load ``.sql`` file into a database. + + + src: the filename to read from + + database: name of the database to import into + + psql_*: global module arguments, see above + + **Example:** + + .. code:: python + + postgresql.load( + name="Import the pyinfra_stuff dump into pyinfra_stuff_copy", + src="/tmp/pyinfra_stuff.dump", + database="pyinfra_stuff_copy", + sudo_user="postgres", + ) + + """ + + yield StringCommand( + make_psql_command( + database=database, + user=psql_user, + password=psql_password, + host=psql_host, + port=psql_port, + ), + "<", + src, + ) diff --git a/pyinfra/operations/postgresql.py b/pyinfra/operations/postgresql.py index d31e22223..022013871 100644 --- a/pyinfra/operations/postgresql.py +++ b/pyinfra/operations/postgresql.py @@ -1,347 +1,28 @@ -""" -The PostgreSQL modules manage PostgreSQL databases, users and privileges. +from pyinfra.api import operation -Requires the ``psql`` CLI executable on the target host(s). +from . import postgres -All operations in this module take four optional arguments: - + ``psql_user``: the username to connect to postgresql to - + ``psql_password``: the password for the connecting user - + ``psql_host``: the hostname of the server to connect to - + ``psql_port``: the port of the server to connect to -See example/postgresql.py for detailed example +@operation(is_idempotent=False, is_deprecated=True, deprecated_for="postgres.sql") +def sql(*args, **kwargs): + yield from postgres.sql._inner(*args, **kwargs) -""" -from pyinfra import host -from pyinfra.api import MaskString, StringCommand, operation -from pyinfra.facts.postgresql import ( - PostgresqlDatabases, - PostgresqlRoles, - make_execute_psql_command, - make_psql_command, -) +@operation(is_idempotent=False, is_deprecated=True, deprecated_for="postgres.role") +def role(*args, **kwargs): + yield from postgres.role._inner(*args, **kwargs) -@operation(is_idempotent=False) -def sql( - sql, - database=None, - # Details for speaking to PostgreSQL via `psql` CLI - psql_user=None, - psql_password=None, - psql_host=None, - psql_port=None, -): - """ - Execute arbitrary SQL against PostgreSQL. +@operation(is_idempotent=False, is_deprecated=True) +def database(*args, **kwargs): + yield from postgres.database._inner(*args, **kwargs) - + sql: SQL command(s) to execute - + database: optional database to execute against - + psql_*: global module arguments, see above - """ - yield make_execute_psql_command( - sql, - database=database, - user=psql_user, - password=psql_password, - host=psql_host, - port=psql_port, - ) +@operation(is_idempotent=False, is_deprecated=True) +def dump(*args, **kwargs): + yield from postgres.dump._inner(*args, **kwargs) -@operation() -def role( - role, - present=True, - password=None, - login=True, - superuser=False, - inherit=False, - createdb=False, - createrole=False, - replication=False, - connection_limit=None, - # Details for speaking to PostgreSQL via `psql` CLI - psql_user=None, - psql_password=None, - psql_host=None, - psql_port=None, -): - """ - Add/remove PostgreSQL roles. - - + role: name of the role - + present: whether the role should be present or absent - + password: the password for the role - + login: whether the role can login - + superuser: whether role will be a superuser - + inherit: whether the role inherits from other roles - + createdb: whether the role is allowed to create databases - + createrole: whether the role is allowed to create new roles - + replication: whether this role is allowed to replicate - + connection_limit: the connection limit for the role - + psql_*: global module arguments, see above - - Updates: - pyinfra will not attempt to change existing roles - it will either - create or drop roles, but not alter them (if the role exists this - operation will make no changes). - - **Example:** - - .. code:: python - - postgresql.role( - name="Create the pyinfra PostgreSQL role", - role="pyinfra", - password="somepassword", - superuser=True, - login=True, - sudo_user="postgres", - ) - - """ - - roles = host.get_fact( - PostgresqlRoles, - psql_user=psql_user, - psql_password=psql_password, - psql_host=psql_host, - psql_port=psql_port, - ) - - is_present = role in roles - - # User not wanted? - if not present: - if is_present: - yield make_execute_psql_command( - 'DROP ROLE "{0}"'.format(role), - user=psql_user, - password=psql_password, - host=psql_host, - port=psql_port, - ) - else: - host.noop("postgresql role {0} does not exist".format(role)) - return - - # If we want the user and they don't exist - if not is_present: - sql_bits = ['CREATE ROLE "{0}"'.format(role)] - - for key, value in ( - ("LOGIN", login), - ("SUPERUSER", superuser), - ("INHERIT", inherit), - ("CREATEDB", createdb), - ("CREATEROLE", createrole), - ("REPLICATION", replication), - ): - if value: - sql_bits.append(key) - - if connection_limit: - sql_bits.append("CONNECTION LIMIT {0}".format(connection_limit)) - - if password: - sql_bits.append(MaskString("PASSWORD '{0}'".format(password))) - - yield make_execute_psql_command( - StringCommand(*sql_bits), - user=psql_user, - password=psql_password, - host=psql_host, - port=psql_port, - ) - else: - host.noop("postgresql role {0} exists".format(role)) - - -@operation() -def database( - database, - present=True, - owner=None, - template=None, - encoding=None, - lc_collate=None, - lc_ctype=None, - tablespace=None, - connection_limit=None, - # Details for speaking to PostgreSQL via `psql` CLI - psql_user=None, - psql_password=None, - psql_host=None, - psql_port=None, -): - """ - Add/remove PostgreSQL databases. - - + name: name of the database - + present: whether the database should exist or not - + owner: the PostgreSQL role that owns the database - + template: name of the PostgreSQL template to use - + encoding: encoding of the database - + lc_collate: lc_collate of the database - + lc_ctype: lc_ctype of the database - + tablespace: the tablespace to use for the template - + connection_limit: the connection limit to apply to the database - + psql_*: global module arguments, see above - - Updates: - pyinfra will not attempt to change existing databases - it will either - create or drop databases, but not alter them (if the db exists this - operation will make no changes). - - **Example:** - - .. code:: python - - postgresql.database( - name="Create the pyinfra_stuff database", - database="pyinfra_stuff", - owner="pyinfra", - encoding="UTF8", - sudo_user="postgres", - ) - - """ - - current_databases = host.get_fact( - PostgresqlDatabases, - psql_user=psql_user, - psql_password=psql_password, - psql_host=psql_host, - psql_port=psql_port, - ) - - is_present = database in current_databases - - if not present: - if is_present: - yield make_execute_psql_command( - 'DROP DATABASE "{0}"'.format(database), - user=psql_user, - password=psql_password, - host=psql_host, - port=psql_port, - ) - else: - host.noop("postgresql database {0} does not exist".format(database)) - return - - # We want the database but it doesn't exist - if present and not is_present: - sql_bits = ['CREATE DATABASE "{0}"'.format(database)] - - for key, value in ( - ("OWNER", '"{0}"'.format(owner) if owner else owner), - ("TEMPLATE", template), - ("ENCODING", encoding), - ("LC_COLLATE", lc_collate), - ("LC_CTYPE", lc_ctype), - ("TABLESPACE", tablespace), - ("CONNECTION LIMIT", connection_limit), - ): - if value: - sql_bits.append("{0} {1}".format(key, value)) - - yield make_execute_psql_command( - StringCommand(*sql_bits), - user=psql_user, - password=psql_password, - host=psql_host, - port=psql_port, - ) - else: - host.noop("postgresql database {0} exists".format(database)) - - -@operation(is_idempotent=False) -def dump( - dest, - database=None, - # Details for speaking to PostgreSQL via `psql` CLI - psql_user=None, - psql_password=None, - psql_host=None, - psql_port=None, -): - """ - Dump a PostgreSQL database into a ``.sql`` file. Requires ``pg_dump``. - - + dest: name of the file to dump the SQL to - + database: name of the database to dump - + psql_*: global module arguments, see above - - **Example:** - - .. code:: python - - postgresql.dump( - name="Dump the pyinfra_stuff database", - dest="/tmp/pyinfra_stuff.dump", - database="pyinfra_stuff", - sudo_user="postgres", - ) - - """ - - yield StringCommand( - make_psql_command( - executable="pg_dump", - database=database, - user=psql_user, - password=psql_password, - host=psql_host, - port=psql_port, - ), - ">", - dest, - ) - - -@operation(is_idempotent=False) -def load( - src, - database=None, - # Details for speaking to PostgreSQL via `psql` CLI - psql_user=None, - psql_password=None, - psql_host=None, - psql_port=None, -): - """ - Load ``.sql`` file into a database. - - + src: the filename to read from - + database: name of the database to import into - + psql_*: global module arguments, see above - - **Example:** - - .. code:: python - - postgresql.load( - name="Import the pyinfra_stuff dump into pyinfra_stuff_copy", - src="/tmp/pyinfra_stuff.dump", - database="pyinfra_stuff_copy", - sudo_user="postgres", - ) - - """ - - yield StringCommand( - make_psql_command( - database=database, - user=psql_user, - password=psql_password, - host=psql_host, - port=psql_port, - ), - "<", - src, - ) +@operation(is_idempotent=False, is_deprecated=True) +def load(*args, **kwargs): + yield from postgres.load._inner(*args, **kwargs) diff --git a/tests/operations/postgresql.database/add_database.json b/tests/operations/postgresql.database/add_database.json index 5f8dc42e6..12ec0616d 100644 --- a/tests/operations/postgresql.database/add_database.json +++ b/tests/operations/postgresql.database/add_database.json @@ -1,7 +1,7 @@ { "args": ["somedb"], "facts" :{ - "postgresql.PostgresqlDatabases": { + "postgres.PostgresDatabases": { "psql_host=None, psql_password=None, psql_port=None, psql_user=None": {} } }, diff --git a/tests/operations/postgresql.database/add_database_noop.json b/tests/operations/postgresql.database/add_database_noop.json index d5cf04859..c64acf4a8 100644 --- a/tests/operations/postgresql.database/add_database_noop.json +++ b/tests/operations/postgresql.database/add_database_noop.json @@ -1,7 +1,7 @@ { "args": ["somedb"], "facts" :{ - "postgresql.PostgresqlDatabases": { + "postgres.PostgresDatabases": { "psql_host=None, psql_password=None, psql_port=None, psql_user=None": { "somedb": {} } diff --git a/tests/operations/postgresql.database/add_database_owner.json b/tests/operations/postgresql.database/add_database_owner.json index fd616a5ad..f5795d47e 100644 --- a/tests/operations/postgresql.database/add_database_owner.json +++ b/tests/operations/postgresql.database/add_database_owner.json @@ -4,7 +4,7 @@ "owner": "someowner" }, "facts" :{ - "postgresql.PostgresqlDatabases": { + "postgres.PostgresDatabases": { "psql_host=None, psql_password=None, psql_port=None, psql_user=None": {} } }, diff --git a/tests/operations/postgresql.database/remove_database.json b/tests/operations/postgresql.database/remove_database.json index b0e27f818..6115783f9 100644 --- a/tests/operations/postgresql.database/remove_database.json +++ b/tests/operations/postgresql.database/remove_database.json @@ -4,7 +4,7 @@ "present": false }, "facts" :{ - "postgresql.PostgresqlDatabases": { + "postgres.PostgresDatabases": { "psql_host=None, psql_password=None, psql_port=None, psql_user=None": { "somedb": {} } diff --git a/tests/operations/postgresql.database/remove_database_noop.json b/tests/operations/postgresql.database/remove_database_noop.json index 24e3c3c69..95421f504 100644 --- a/tests/operations/postgresql.database/remove_database_noop.json +++ b/tests/operations/postgresql.database/remove_database_noop.json @@ -4,7 +4,7 @@ "present": false }, "facts" :{ - "postgresql.PostgresqlDatabases": { + "postgres.PostgresDatabases": { "psql_host=None, psql_password=None, psql_port=None, psql_user=None": {} } }, diff --git a/tests/operations/postgresql.role/role_add_noop.json b/tests/operations/postgresql.role/role_add_noop.json index 2cdb8521e..7acf41d41 100644 --- a/tests/operations/postgresql.role/role_add_noop.json +++ b/tests/operations/postgresql.role/role_add_noop.json @@ -1,7 +1,7 @@ { "args": ["testuser"], "facts": { - "postgresql.PostgresqlRoles": { + "postgres.PostgresRoles": { "psql_host=None, psql_password=None, psql_port=None, psql_user=None": { "testuser": {} } diff --git a/tests/operations/postgresql.role/role_remove_noop.json b/tests/operations/postgresql.role/role_remove_noop.json index dc7bf72fd..76b07d9c3 100644 --- a/tests/operations/postgresql.role/role_remove_noop.json +++ b/tests/operations/postgresql.role/role_remove_noop.json @@ -4,7 +4,7 @@ "present": false }, "facts": { - "postgresql.PostgresqlRoles": { + "postgres.PostgresRoles": { "psql_host=None, psql_password=None, psql_port=None, psql_user=None": {} } }, diff --git a/tests/operations/postgresql.role/user_add.json b/tests/operations/postgresql.role/user_add.json index 73abd450d..2c995eb98 100644 --- a/tests/operations/postgresql.role/user_add.json +++ b/tests/operations/postgresql.role/user_add.json @@ -5,7 +5,7 @@ "password": "abc" }, "facts": { - "postgresql.PostgresqlRoles": { + "postgres.PostgresRoles": { "psql_host=None, psql_password=None, psql_port=None, psql_user=None": {} } }, diff --git a/tests/operations/postgresql.role/user_add_no_login.json b/tests/operations/postgresql.role/user_add_no_login.json index dd6134ac4..6bf19b911 100644 --- a/tests/operations/postgresql.role/user_add_no_login.json +++ b/tests/operations/postgresql.role/user_add_no_login.json @@ -4,7 +4,7 @@ "login": false }, "facts": { - "postgresql.PostgresqlRoles": { + "postgres.PostgresRoles": { "psql_host=None, psql_password=None, psql_port=None, psql_user=None": {} } }, diff --git a/tests/operations/postgresql.role/user_add_privileges.json b/tests/operations/postgresql.role/user_add_privileges.json index 193fd2525..8af0affc7 100644 --- a/tests/operations/postgresql.role/user_add_privileges.json +++ b/tests/operations/postgresql.role/user_add_privileges.json @@ -7,7 +7,7 @@ "replication": true }, "facts": { - "postgresql.PostgresqlRoles": { + "postgres.PostgresRoles": { "psql_host=None, psql_password=None, psql_port=None, psql_user=None": {} } }, diff --git a/tests/operations/postgresql.role/user_add_replication.json b/tests/operations/postgresql.role/user_add_replication.json index c6b7dd60d..f65e8a0a5 100644 --- a/tests/operations/postgresql.role/user_add_replication.json +++ b/tests/operations/postgresql.role/user_add_replication.json @@ -5,7 +5,7 @@ "replication": true }, "facts": { - "postgresql.PostgresqlRoles": { + "postgres.PostgresRoles": { "psql_host=None, psql_password=None, psql_port=None, psql_user=None": {} } }, diff --git a/tests/operations/postgresql.role/user_add_super.json b/tests/operations/postgresql.role/user_add_super.json index 02c289261..ed59a0786 100644 --- a/tests/operations/postgresql.role/user_add_super.json +++ b/tests/operations/postgresql.role/user_add_super.json @@ -4,7 +4,7 @@ "superuser": true }, "facts": { - "postgresql.PostgresqlRoles": { + "postgres.PostgresRoles": { "psql_host=None, psql_password=None, psql_port=None, psql_user=None": {} } }, diff --git a/tests/operations/postgresql.role/user_remove.json b/tests/operations/postgresql.role/user_remove.json index cbbb401fb..571019a2c 100644 --- a/tests/operations/postgresql.role/user_remove.json +++ b/tests/operations/postgresql.role/user_remove.json @@ -4,7 +4,7 @@ "present": false }, "facts": { - "postgresql.PostgresqlRoles": { + "postgres.PostgresRoles": { "psql_host=None, psql_password=None, psql_port=None, psql_user=None": { "testuser": {} }