mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 11:51:26 -07:00
Sanity fixes to parameter types (#52325)
This commit is contained in:
parent
47190088b4
commit
677c04c01d
25 changed files with 445 additions and 404 deletions
|
@ -1,18 +1,17 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright: Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['stableinterface'],
|
||||
'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
DOCUMENTATION = r'''
|
||||
---
|
||||
module: postgresql_db
|
||||
short_description: Add or remove PostgreSQL databases from a remote host.
|
||||
|
@ -23,87 +22,100 @@ options:
|
|||
name:
|
||||
description:
|
||||
- name of the database to add or remove
|
||||
type: str
|
||||
required: true
|
||||
aliases: [ db ]
|
||||
owner:
|
||||
description:
|
||||
- Name of the role to set as owner of the database
|
||||
type: str
|
||||
template:
|
||||
description:
|
||||
- Template used to create the database
|
||||
type: str
|
||||
encoding:
|
||||
description:
|
||||
- Encoding of the database
|
||||
type: str
|
||||
lc_collate:
|
||||
description:
|
||||
- Collation order (LC_COLLATE) to use in the database. Must match collation order of template database unless C(template0) is used as template.
|
||||
type: str
|
||||
lc_ctype:
|
||||
description:
|
||||
- Character classification (LC_CTYPE) to use in the database (e.g. lower, upper, ...) Must match LC_CTYPE of template database unless C(template0)
|
||||
is used as template.
|
||||
type: str
|
||||
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"
|
||||
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.
|
||||
state:
|
||||
description: |
|
||||
The database state. present implies that the database should be created if necessary.
|
||||
absent implies that the database should be removed if present.
|
||||
dump requires a target definition to which the database will be backed up.
|
||||
(Added in 2.4) restore also requires a target definition from which the database will be restored.
|
||||
(Added in 2.4) The format of the backup will be detected based on the target name.
|
||||
Supported compression formats for dump and restore are: .bz2, .gz, and .xz
|
||||
Supported formats for dump and restore are: .sql and .tar
|
||||
description:
|
||||
- The database state.
|
||||
- C(present) implies that the database should be created if necessary.
|
||||
- C(absent) implies that the database should be removed if present.
|
||||
- C(dump) requires a target definition to which the database will be backed up. (Added in Ansible 2.4)
|
||||
- C(restore) also requires a target definition from which the database will be restored. (Added in Ansible 2.4)
|
||||
- The format of the backup will be detected based on the target name.
|
||||
- Supported compression formats for dump and restore include C(.bz2), C(.gz) and C(.xz)
|
||||
- Supported formats for dump and restore include C(.sql) and C(.tar)
|
||||
type: str
|
||||
choices: [ absent, dump, present, restore ]
|
||||
default: present
|
||||
choices: [ "present", "absent", "dump", "restore" ]
|
||||
target:
|
||||
version_added: "2.4"
|
||||
description:
|
||||
- File to back up or restore from. Used when state is "dump" or "restore"
|
||||
- File to back up or restore from.
|
||||
- Used when I(state) is C(dump) or C(restore).
|
||||
type: path
|
||||
version_added: "2.4"
|
||||
target_opts:
|
||||
version_added: "2.4"
|
||||
description:
|
||||
- Further arguments for pg_dump or pg_restore. Used when state is "dump" or "restore"
|
||||
- Further arguments for pg_dump or pg_restore.
|
||||
- Used when I(state) is C(dump) or C(restore).
|
||||
type: str
|
||||
version_added: "2.4"
|
||||
maintenance_db:
|
||||
version_added: "2.5"
|
||||
description:
|
||||
- The value specifies the initial database (which is also called as maintenance DB) that Ansible connects to.
|
||||
type: str
|
||||
default: postgres
|
||||
version_added: "2.5"
|
||||
author: "Ansible Core Team"
|
||||
extends_documentation_fragment:
|
||||
- postgres
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Create a new database with name "acme"
|
||||
- postgresql_db:
|
||||
EXAMPLES = r'''
|
||||
- name: Create a new database with name "acme"
|
||||
postgresql_db:
|
||||
name: acme
|
||||
|
||||
# Create a new database with name "acme" and specific encoding and locale
|
||||
# settings. If a template different from "template0" is specified, encoding
|
||||
# and locale settings must match those of the template.
|
||||
- postgresql_db:
|
||||
# Note: If a template different from "template0" is specified, encoding and locale settings must match those of the template.
|
||||
- name: Create a new database with name "acme" and specific encoding and locale # settings.
|
||||
postgresql_db:
|
||||
name: acme
|
||||
encoding: UTF-8
|
||||
lc_collate: de_DE.UTF-8
|
||||
lc_ctype: de_DE.UTF-8
|
||||
template: template0
|
||||
|
||||
# Dump an existing database to a file
|
||||
- postgresql_db:
|
||||
- name: Dump an existing database to a file
|
||||
postgresql_db:
|
||||
name: acme
|
||||
state: dump
|
||||
target: /tmp/acme.sql
|
||||
|
||||
# Dump an existing database to a file (with compression)
|
||||
- postgresql_db:
|
||||
- name: Dump an existing database to a file (with compression)
|
||||
postgresql_db:
|
||||
name: acme
|
||||
state: dump
|
||||
target: /tmp/acme.sql.gz
|
||||
|
||||
# Dump a single schema for an existing database
|
||||
- postgresql_db:
|
||||
- name: Dump a single schema for an existing database
|
||||
postgresql_db:
|
||||
name: acme
|
||||
state: dump
|
||||
target: /tmp/acme.sql
|
||||
|
@ -366,19 +378,19 @@ def do_with_password(module, cmd, password):
|
|||
|
||||
def main():
|
||||
argument_spec = pgutils.postgres_common_argument_spec()
|
||||
argument_spec.update(dict(
|
||||
db=dict(required=True, aliases=['name']),
|
||||
owner=dict(default=""),
|
||||
template=dict(default=""),
|
||||
encoding=dict(default=""),
|
||||
lc_collate=dict(default=""),
|
||||
lc_ctype=dict(default=""),
|
||||
state=dict(default="present", choices=["absent", "present", "dump", "restore"]),
|
||||
target=dict(default="", type="path"),
|
||||
target_opts=dict(default=""),
|
||||
maintenance_db=dict(default="postgres"),
|
||||
session_role=dict(),
|
||||
))
|
||||
argument_spec.update(
|
||||
db=dict(type='str', required=True, aliases=['name']),
|
||||
owner=dict(type='str', default=''),
|
||||
template=dict(type='str', default=''),
|
||||
encoding=dict(type='str', default=''),
|
||||
lc_collate=dict(type='str', default=''),
|
||||
lc_ctype=dict(type='str', default=''),
|
||||
state=dict(type='str', default='present', choices=['absent', 'dump', 'present', 'restore']),
|
||||
target=dict(type='path', default=''),
|
||||
target_opts=dict(type='str', default=''),
|
||||
maintenance_db=dict(type='str', default="postgres"),
|
||||
session_role=dict(type='str'),
|
||||
)
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=argument_spec,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue