|
|
@ -15,69 +15,81 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
|
|
DOCUMENTATION = r'''
|
|
|
|
DOCUMENTATION = r'''
|
|
|
|
---
|
|
|
|
---
|
|
|
|
module: mysql_db
|
|
|
|
module: mysql_db
|
|
|
|
short_description: Add or remove MySQL databases from a remote host.
|
|
|
|
short_description: Add or remove MySQL databases from a remote host
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Add or remove MySQL databases from a remote host.
|
|
|
|
- Add or remove MySQL databases from a remote host.
|
|
|
|
version_added: "0.6"
|
|
|
|
version_added: '0.6'
|
|
|
|
options:
|
|
|
|
options:
|
|
|
|
name:
|
|
|
|
name:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- name of the database to add or remove.
|
|
|
|
- Name of the database to add or remove.
|
|
|
|
- I(name=all) May only be provided if I(state) is C(dump) or C(import).
|
|
|
|
- I(name=all) may only be provided if I(state) is C(dump) or C(import).
|
|
|
|
- List of databases is provided with I(state=dump), I(state=present) and I(state=absent).
|
|
|
|
- List of databases is provided with I(state=dump), I(state=present) and I(state=absent).
|
|
|
|
- if name=all Works like --all-databases option for mysqldump (Added in 2.0).
|
|
|
|
- If I(name=all) it works like --all-databases option for mysqldump (Added in 2.0).
|
|
|
|
required: true
|
|
|
|
required: true
|
|
|
|
type: list
|
|
|
|
type: list
|
|
|
|
elements: str
|
|
|
|
elements: str
|
|
|
|
aliases: [ db ]
|
|
|
|
aliases: [db]
|
|
|
|
state:
|
|
|
|
state:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The database state
|
|
|
|
- The database state
|
|
|
|
|
|
|
|
type: str
|
|
|
|
default: present
|
|
|
|
default: present
|
|
|
|
choices: [ "present", "absent", "dump", "import" ]
|
|
|
|
choices: ['absent', 'dump', 'import', 'present']
|
|
|
|
collation:
|
|
|
|
collation:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Collation mode (sorting). This only applies to new table/databases and does not update existing ones, this is a limitation of MySQL.
|
|
|
|
- Collation mode (sorting). This only applies to new table/databases and
|
|
|
|
|
|
|
|
does not update existing ones, this is a limitation of MySQL.
|
|
|
|
|
|
|
|
type: str
|
|
|
|
|
|
|
|
default: ''
|
|
|
|
encoding:
|
|
|
|
encoding:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Encoding mode to use, examples include C(utf8) or C(latin1_swedish_ci), at creation of database, dump or importation of sql script
|
|
|
|
- Encoding mode to use, examples include C(utf8) or C(latin1_swedish_ci),
|
|
|
|
|
|
|
|
at creation of database, dump or importation of sql script.
|
|
|
|
|
|
|
|
type: str
|
|
|
|
|
|
|
|
default: ''
|
|
|
|
target:
|
|
|
|
target:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Location, on the remote host, of the dump file to read from or write to. Uncompressed SQL
|
|
|
|
- Location, on the remote host, of the dump file to read from or write to.
|
|
|
|
files (C(.sql)) as well as bzip2 (C(.bz2)), gzip (C(.gz)) and xz (Added in 2.0) compressed files are supported.
|
|
|
|
- Uncompressed SQL files (C(.sql)) as well as bzip2 (C(.bz2)), gzip (C(.gz)) and
|
|
|
|
|
|
|
|
xz (Added in 2.0) compressed files are supported.
|
|
|
|
|
|
|
|
type: path
|
|
|
|
single_transaction:
|
|
|
|
single_transaction:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Execute the dump in a single transaction
|
|
|
|
- Execute the dump in a single transaction.
|
|
|
|
type: bool
|
|
|
|
type: bool
|
|
|
|
default: 'no'
|
|
|
|
default: no
|
|
|
|
version_added: "2.1"
|
|
|
|
version_added: '2.1'
|
|
|
|
quick:
|
|
|
|
quick:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Option used for dumping large tables
|
|
|
|
- Option used for dumping large tables.
|
|
|
|
type: bool
|
|
|
|
type: bool
|
|
|
|
default: 'yes'
|
|
|
|
default: yes
|
|
|
|
version_added: "2.1"
|
|
|
|
version_added: '2.1'
|
|
|
|
ignore_tables:
|
|
|
|
ignore_tables:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- A list of table names that will be ignored in the dump of the form database_name.table_name
|
|
|
|
- A list of table names that will be ignored in the dump
|
|
|
|
required: false
|
|
|
|
of the form database_name.table_name.
|
|
|
|
|
|
|
|
type: list
|
|
|
|
|
|
|
|
elements: str
|
|
|
|
|
|
|
|
required: no
|
|
|
|
default: []
|
|
|
|
default: []
|
|
|
|
version_added: "2.7"
|
|
|
|
version_added: '2.7'
|
|
|
|
hex_blob:
|
|
|
|
hex_blob:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Dump binary columns using hexadecimal notation
|
|
|
|
- Dump binary columns using hexadecimal notation.
|
|
|
|
required: false
|
|
|
|
required: no
|
|
|
|
default: false
|
|
|
|
default: no
|
|
|
|
type: bool
|
|
|
|
type: bool
|
|
|
|
version_added: "2.10"
|
|
|
|
version_added: '2.10'
|
|
|
|
force:
|
|
|
|
force:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Continue dump or import even if we get an SQL error.
|
|
|
|
- Continue dump or import even if we get an SQL error.
|
|
|
|
- Used only when I(state) is C(dump) or C(import).
|
|
|
|
- Used only when I(state) is C(dump) or C(import).
|
|
|
|
required: no
|
|
|
|
required: no
|
|
|
|
type: bool
|
|
|
|
type: bool
|
|
|
|
default: no
|
|
|
|
default: no
|
|
|
|
version_added: "2.10"
|
|
|
|
version_added: '2.10'
|
|
|
|
seealso:
|
|
|
|
seealso:
|
|
|
|
- module: mysql_info
|
|
|
|
- module: mysql_info
|
|
|
|
- module: mysql_variables
|
|
|
|
- module: mysql_variables
|
|
|
@ -101,7 +113,8 @@ requirements:
|
|
|
|
- mysqldump (command line binary)
|
|
|
|
- mysqldump (command line binary)
|
|
|
|
notes:
|
|
|
|
notes:
|
|
|
|
- Requires the mysql and mysqldump binaries on the remote host.
|
|
|
|
- Requires the mysql and mysqldump binaries on the remote host.
|
|
|
|
- This module is B(not idempotent) when I(state) is C(import), and will import the dump file each time if run more than once.
|
|
|
|
- This module is B(not idempotent) when I(state) is C(import),
|
|
|
|
|
|
|
|
and will import the dump file each time if run more than once.
|
|
|
|
extends_documentation_fragment: mysql
|
|
|
|
extends_documentation_fragment: mysql
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
@ -158,7 +171,9 @@ EXAMPLES = r'''
|
|
|
|
target: /tmp/dump.sql
|
|
|
|
target: /tmp/dump.sql
|
|
|
|
|
|
|
|
|
|
|
|
# Import of sql script with encoding option
|
|
|
|
# Import of sql script with encoding option
|
|
|
|
- name: Import dump.sql with specific latin1 encoding, similar to mysql -u <username> --default-character-set=latin1 -p <password> < dump.sql
|
|
|
|
- name: >
|
|
|
|
|
|
|
|
Import dump.sql with specific latin1 encoding,
|
|
|
|
|
|
|
|
similar to mysql -u <username> --default-character-set=latin1 -p <password> < dump.sql
|
|
|
|
mysql_db:
|
|
|
|
mysql_db:
|
|
|
|
state: import
|
|
|
|
state: import
|
|
|
|
name: all
|
|
|
|
name: all
|
|
|
@ -166,7 +181,9 @@ EXAMPLES = r'''
|
|
|
|
target: /tmp/dump.sql
|
|
|
|
target: /tmp/dump.sql
|
|
|
|
|
|
|
|
|
|
|
|
# Dump of database with encoding option
|
|
|
|
# Dump of database with encoding option
|
|
|
|
- name: Dump of Databse with specific latin1 encoding, similar to mysqldump -u <username> --default-character-set=latin1 -p <password> <database>
|
|
|
|
- name: >
|
|
|
|
|
|
|
|
Dump of Databse with specific latin1 encoding,
|
|
|
|
|
|
|
|
similar to mysqldump -u <username> --default-character-set=latin1 -p <password> <database>
|
|
|
|
mysql_db:
|
|
|
|
mysql_db:
|
|
|
|
state: dump
|
|
|
|
state: dump
|
|
|
|
name: db_1
|
|
|
|
name: db_1
|
|
|
|