Commit Graph

264 Commits (b47cde9d4c9962b4d8f4ab48505b008dad8b70e7)

Author SHA1 Message Date
Michael Scherer 8b125f8c2c Mark path as type='path', do not leak login_password by error (#3396) 2016-12-08 11:24:16 -05:00
Michael Scherer c0179330c9 Update the type of some arguments in mysql_db module (#3285)
login_password should not be logged, so mark it as 'no_log'
the others arguments are path to file, and so should be type='path',
which permit to remove the line handling '~' and shell variables.
2016-12-08 11:24:16 -05:00
Tom Paine 7422ada2c8 Update mysql_db.py
* Update mysql_db.py

Resubmission of https://github.com/ansible/ansible-modules-core/pull/2961 in single commit.

* Update mysql_db.py
2016-12-08 11:24:16 -05:00
Matt Clay b7a5e1e0c8 Add optional connect timeout to mysql* modules. 2016-12-08 11:24:12 -05:00
Kenny Gryp 69b07aaf9d added sql_log_bin setting to disable binary logging as option 2016-12-08 11:24:11 -05:00
Tobias Wolf 75e8b365b4 Add supports_check_mode=True to mysql_db module
The most important cases are state=present and state=absent.

Future work: import and dump could be simulated and hence checked.
2016-12-08 11:24:09 -05:00
Matt Martz aaf762573e Various simple linting type cleanups on modules 2016-12-08 11:24:06 -05:00
Toshio Kuratomi 50eda6c62e password needs to be type str.
In 1.9 this was the default.  In 2.0.0 and 2.0.1 this doesn't get set.
2.1.0 will fix the default but we should fix this now.
2016-12-08 11:24:05 -05:00
Toshio Kuratomi f6aa1ff9a4 Remove duplicate documentation fields 2016-12-08 11:24:01 -05:00
Lee H 8e84ba71ae - fix check_mode test to avoid errors
- correct test mode check to ensure it returns and doesnt apply changes
  (via jmainguy)
2016-12-08 11:24:00 -05:00
Mark van Driel a24cdbe15e Fixed "invalid privileges string: set expected at most 1 arguments, got 2" 2016-12-08 11:23:58 -05:00
Jonathan Mainguy e9a752f769 add ansi support 2016-12-08 11:23:58 -05:00
Mark van Driel d67f2eb104 Fixes require ssl in combination with other privileges
Fixes require ssl in combination with grant option

Refactoring: code cleanup to make it easier to understand

Code rewritten inspired by @willthames

Added WITH GRANT OPTION as exception; when only REQUIRESSL and/or GRANT are specified we have to add USAGE
2016-12-08 11:23:57 -05:00
KIKUCHI Koichiro 2974358b2b Add check_mode support to mysql_user. 2016-12-08 11:23:56 -05:00
Jonathan Mainguy 47d0719cfe Fix bad merge 2016-12-08 11:23:56 -05:00
Josh Rendek bddcf737c9 Fix quote on grants of more than one word
Fixed a quote location on the grants composed of more than one word. Current docs will raise an error with a invalid privilege command.
2016-12-08 11:23:55 -05:00
Toshio Kuratomi 65b9243056 mariadb isn't always the last elemen of the version string 2016-12-08 11:23:53 -05:00
Toshio Kuratomi 0a64899eba Fix mysqldump usage of config_file 2016-12-08 11:23:53 -05:00
Toshio Kuratomi dafb39da2e Account for mariadb versioning 2016-12-08 11:23:53 -05:00
Jonathan Mainguy 0cdb2719e5 Unify all 3 mysql modules.
Use same connection method, use config_file, and add ssl support
2016-12-08 11:23:53 -05:00
Lee H 7feb64d31c - add version_added as requested to host_all 2016-12-08 11:23:53 -05:00
Lee H 5606197c28 - remove user_anonymous as the same thing can be accomplished by user='', but leave in the examples for removing anonymous users 2016-12-08 11:23:53 -05:00
Lee H 95895177d0 - add example showing removal of anonymous user accounts 2016-12-08 11:23:52 -05:00
Jonathan Mainguy b86224a7ec Add Jmainguy as author, fix hash check 2016-12-08 11:23:52 -05:00
Lee Hardy f2f0f83ee6 - fix user_exists statement with host_all to use only username parameter 2016-12-08 11:23:52 -05:00
Lee Hardy 1113975741 - mysql: add user_anonymous parameter, which interacts with anonymous users - mysql; add host_all parameter, which forces iteration over all 'user'@... matches 2016-12-08 11:23:51 -05:00
Derek Smith b9baed507b updated examples
added mysql 5.7 user password modification support with backwards compatibility

resolved mysql server version check and differences in user authentication management

explicitly state support for mysql_native_password type and no others. fixed some failing logic and updated samples

updated comment to actually match logic.

simplified conditionals and a little refactor
2016-12-08 11:23:51 -05:00
trevoro b5a3dd4818 adding password_hash support to mysql_user module
fixing user_add arguments error

fixing user_mod arguments error
2016-12-08 11:23:51 -05:00
Mark Theunissen c3450d542f Remove Mark Theunissen as maintainer 2016-12-08 11:23:50 -05:00
Jonathan Mainguy caf6115f43 Update documentation to reflect need for mysql client 2016-12-08 11:23:46 -05:00
wtanaka.com c31a6fd23f Update target parameter documentation
xz support was only added recently (2015-05-15), so referring to it
unqualified in the online documentation is confusing.
2016-12-08 11:23:46 -05:00
Greg DeKoenigsberg 742b452dc1 @lorin stepping down as maintainer 2016-12-08 11:23:45 -05:00
Brian Coca 3906fd426b document mysql collation can only be set during creation 2016-12-08 11:23:44 -05:00
Jonathan Mainguy 833676960d Update doc to reflect password is required if adding a new user 2016-12-08 11:23:44 -05:00
Jonathan Mainguy 346c9ab80e Update error message to be more explicit 2016-12-08 11:23:44 -05:00
Sam Yaple f2c1eeb54c Actually remove the section we are replacing 2016-12-08 11:23:32 -05:00
Sam Yaple 52d364b74c Refix bug 1226 after revert
This patch properly fixes bug 1226 without introducing a breaking
change to idempotency which was introduced in PR #1358

We can properly assign permissions to databases with a '.' in the name
of the database as well as assign priviliges to all databases as
specified with '*'
2016-12-08 11:23:32 -05:00
Sam Yaple f8bcdffa36 Revert "escapeds changes"
While this change doesn't break the creation, it does break
idempotency. This change will convert '*.*' to '`*`.*' which is
functionally the same, however when the user_mod() function looks up
the current privileges with privileges_get() it will read '*.*'

Since '*.*' != '`*`.*' it will go through the process of updating the
privleges always resulting in a 'changed' result.

This reverts commit db9ab9b2629f00350a743a4eca72fb5ee8dc8c77.
2016-12-08 11:23:31 -05:00
Guilherme Carlos aaac05c96c Fix login_user on mysql_user
`login_username` was provided but `login_user` is the correct option
2016-12-08 11:23:24 -05:00
Will Thames e5d96dc934 Correct handling of empty role_attr_flags
role_attr_flags is the empty string by default, not None.
2016-12-08 11:23:24 -05:00
Jesse Sandberg 807feb3ac4 Validate variable, return only the found variable value instead of tuple
Docs imply the mysql_variables is used to operate a single variable therefore
- fail before making any db connections if variable is not set
- validate chars for mysql variable name with re.match(^[a-z0-9_]+)
- use "SHOW VARIABLE WHERE Variable_name" instead of LIKE search
- getvariable() returns only the value or None if variable is not found
- the module returns only the found variable value instead of tuple for easier operation eg. as registere variable in tasks
2016-12-08 11:23:24 -05:00
sysadmin75 9bd58bd224 Fix to revoke privileges for mysql user = '' Issue #9848 2016-12-08 11:23:24 -05:00
acaveroc dda41fd95a Add version_added and type of parameter 2016-12-08 11:23:19 -05:00
acaveroc 2c6f69c95e Assorted minor bug fixes
- Modified data type for port definition from string to integer
- Modified login_host default value for compatibilize with port definition according with MySQL Documentation (https://dev.mysql.com/doc/refman/5.0/en/connecting.html)
2016-12-08 11:23:19 -05:00
acaveroc 1283fdd118 Add port definition support for mysql_vars module 2016-12-08 11:23:19 -05:00
Matt Martz 3d28efaf7e Replace tabbed indentation with spaces for mysql_db module 2016-12-08 11:23:16 -05:00
ToBeReplaced 5e259a8dd9 Make ALL_IN_SCHEMA for tables affect views
ALL TABLES is considered to include views, so we must check for reltypes
'r' and 'v', not just 'r'. This bug was introduced due to using a
custom, backwards-compatible version of "ALL TABLES IN SCHEMA".
2016-12-08 11:23:15 -05:00
Bryan Fleming 6f8d60a5ed fixes #1120 - privileges using columns 2016-12-08 11:23:13 -05:00
Sergei Antipov e62f870859 mysql_user | Hide password 2016-12-08 11:23:08 -05:00
Greg DeKoenigsberg eb881d7d5d Proper author info for all remaining modules 2016-12-08 11:23:07 -05:00
Louis-Michel Couture 03240cfcb6 Update example to remove outdated information 2016-12-08 11:23:05 -05:00
Toshio Kuratomi fa60891f68 Fix a problem introduced with #1101 and optimize privilege handling
* If a db user belonged to a role which had a privilege, the user would
  not have the privilege added as the role gave the appearance that the
  user already had it.  Fixed to always check the privileges specific to
  the user.
* Make fewer db queries to determine if privileges need to be changed
  and change them (was four for each privilege.  Now two for each object
  that has a set of privileges changed).
2016-12-08 11:23:03 -05:00
Toshio Kuratomi 5027fc0642 Expand tildes and vars in the config file path 2016-12-08 11:23:03 -05:00
Will Thames 34e0e17090 Perform privilege grants/revokes only when required
Use `has_table_privileges` and `has_database_privileges`
to test whether a user already has a privilege before
granting it, or whether a user doesn't have  a privilege
before revoking it.
2016-12-08 11:23:03 -05:00
Toshio Kuratomi 4f42e752e6 Allow playbook specified login_user and login_password to override config file settings 2016-12-08 11:23:03 -05:00
Toshio Kuratomi 0af631499a Use a list comprehension instead of map and lambda 2016-12-08 11:23:02 -05:00
Toshio Kuratomi c291c2dfea Fix for the new import code when password is empty 2016-12-08 11:23:02 -05:00
Dennis Rowe 5109628693 Strip spaces around perms 2016-12-08 11:23:02 -05:00
Johann Schmitz 8f8109f1e0 Improved output of mysql_db plugin
Show error number and error description on connect error to ease debugging.
2016-12-08 11:23:02 -05:00
Jonathan Mainguy 7ab2ddbe2a escapeds changes
fixed merge conflict

remove uneeded regexs

arrays
2016-12-08 11:23:02 -05:00
Robin Miller a2f685a134 Replaced lambda functions with list comprehensions. 2016-12-08 11:23:02 -05:00
Robin Miller 8859a7cf8e Only revoke actually granted permissions, not 'ALL'.
This prevents errors when the login_user does not have 'ALL'
permissions, and the 'priv' value contains fewer permissions than are
held by an existing user. This is particularly an issue when using an
Amazon Web Services RDS instance, as there is no (accessible) user with
'ALL' permissions on *.*.
2016-12-08 11:23:01 -05:00
fdupoux e34c7f31dc Refactoring to avoid duplication of code which manages the decompression of database dumps in various formats 2016-12-08 11:23:01 -05:00
fdupoux 9b83311471 Simplify code which prepares the decompression command 2016-12-08 11:23:01 -05:00
Toshio Kuratomi dd4838e4aa Refactor dump compression and use get_bin_path for finding the compressors 2016-12-08 11:23:01 -05:00
fdupoux aa79810cc8 Decompress mysql dumps on the fly using python subprocess during an import to simplify operation 2016-12-08 11:23:01 -05:00
Jonathan Mainguy b25bc20d3d changes hostname to lowercase 2016-12-08 11:23:00 -05:00
Brian Coca 831af880f0 minor doc fix and made sure check_implicit_admin is true boolean 2016-12-08 11:23:00 -05:00
Toshio Kuratomi 5c96c5c9c2 Fix splitting of role_attrs 2016-12-08 11:23:00 -05:00
fdupoux 6f2f07ef51 Add support for xz compression (for dump and import) in mysql_db module 2016-12-08 11:22:59 -05:00
Jonathan Mainguy 1ba2e34ae1 Adds all_databases option which allows a user to dump or import all databases at once, identical to mysqldump --all-databases
fix line 132

Update to name=all

cleaned up all_database per abadger's suggestions
2016-12-08 11:22:57 -05:00
Will Thames 9aff204f63 Usage is not a valid database or table privilege
Remove `USAGE` from the `VALID_PRIVS` dict for both database and
table because it is not a valid privilege for either (and
breaks the implementation of `has_table_privilege` and
`has_database_privilege`

See http://www.postgresql.org/docs/9.0/static/sql-grant.html
2016-12-08 11:22:57 -05:00
Will Thames 43bad27948 Update postgresql users only when necessary
For read-only databases, users should not change when no changes
are required.

Don't issue ALTER ROLE when role attribute flags, users password
or expiry time is not changing.

In certain cases (hashed passwords in the DB, but the password
argument is not hashed) passlib.hash is required to avoid
running ALTER ROLE.
2016-12-08 11:22:56 -05:00
Julia Kreger 6f7cd5c307 Set default for mysql_user config_file
The default value set by the module was a value of None for the
config_file parameter, which propogates into the connect method
call overriding the stated default in the method.

Instead, the default should be set with-in the parameter
specification so the file check is not requested to check None.
2016-12-08 11:22:56 -05:00
Sven Schliesing 90d434d66d use default value for parameter config_file in connect() 2016-12-08 11:22:55 -05:00
muffl0n 62bc6f2ba6 Use MySQLdbs read_default_file 2016-12-08 11:22:55 -05:00
tedder 9fd568f655 code review fixes per #957 2016-12-08 11:22:52 -05:00
tedder 35ce9fb095 skip password changes so pg_authid isn't needed
Some places ([AWS RDS](https://forums.aws.amazon.com/thread.jspa?threadID=151248)) don't have, or don't allow, access to the `pg_authid` table. The only reason that is necessary is to check for a password change.

This flag is a workaround so passwords can only be set at creation time. It isn't as elegant as changing the password down the line, but it fixes the longstanding issue #297 that prevented this from being useful on AWS RDS.
2016-12-08 11:22:52 -05:00
Solomon Gifford d14bbf514e mysql_user #829: add update_password to mysql_user 2016-12-08 11:22:52 -05:00
Toshio Kuratomi e5ba4e87d8 Fix for int port assignment in a playbook failing
Ports are integer values but the old code was assuming they were
strings.  When login_port is put into playbook complex_args as an
integer the code would fail.  This update should make the argument
validating make sure we have an integer and then we can send that value
directly to the relevant APIs.

Fixes #818
2016-12-08 11:22:46 -05:00
Jonathan Mainguy 1608163b26 Now correctly gzip/bzips file back up in case of import failure
Removed gunzip and bunzip2 dependency
2016-12-08 11:22:46 -05:00
Toshio Kuratomi b9984b1dfe Fix documentation to have correct param name 2016-12-08 11:22:45 -05:00
David Hummel 63e9de3170 Fix issue #793: mysql_db: for state={absent,present} connections to database mysql fail for users other than root 2016-12-08 11:22:42 -05:00
Johannes Steger 1a440d6a06 Fix function identifier quoting 2016-12-08 11:22:39 -05:00
Toshio Kuratomi e11ea4b402 Also catch mysql errors so we can give the error message back through json rather than tracebacking 2016-12-08 11:22:37 -05:00
Bruce Pennypacker 605a5a5b53 requested changes 2016-12-08 11:22:37 -05:00
Bruce Pennypacker 9cbe3eb8ae Added support for 'REQUIRE SSL' grant option 2016-12-08 11:22:37 -05:00
Michael J. Schultz 588d03db8d Build the db connection on `"postgres"` instead of `"template1"`
According to the postgresql docs[1], you should not have a connection with
`"template1"` when copying multiple databases.

[1]: http://www.postgresql.org/docs/9.1/static/manage-ag-templatedbs.html
2016-12-08 11:22:36 -05:00
Jonathan Mainguy 13990e9479 adds error message if socket does not exist 2016-12-08 11:22:35 -05:00
kustodian 8621f9a7cd Fixed postgresql_db failing on Python 2.4 with --check
This reverts commit 81cbdb6c8cf54c41ba2ee3330c968e2feea05a5c and adds ignoring of the SystemExit exception because of Python 2.4.
2016-12-08 11:22:33 -05:00
Petros Moisiadis 63b18ae618 mysql_user: Added missing privileges
Added missing privileges 'CREATE TABLESPACE' and 'PROXY' (see: http://dev.mysql.com/doc/refman/5.5/en/privileges-provided.html).
2016-12-08 11:22:32 -05:00
Andrew Shults 2390184084 Strip white space to support multiline permissions in YAML 2016-12-08 11:22:32 -05:00
Toshio Kuratomi 9fde3c2dc5 Add USAGE as a valid privilege 2016-12-08 11:22:31 -05:00
Toshio Kuratomi cd7cc07e85 Gixes to doc formatting 2016-12-08 11:22:31 -05:00
Toshio Kuratomi 307116b838 Fix typo so docs will build 2016-12-08 11:22:31 -05:00
Toshio Kuratomi ddc81c7b93 Escape % in db+table names before adding to a format string being passed into db.execute()
Fixes #416
2016-12-08 11:22:29 -05:00
Dan fe787f1bc9 Adds a login_unix_socket option to the postgresql_privs module. 2016-12-08 11:22:29 -05:00
Dan ee65c55fb0 Adds a unix_socket/login_unix_socket option to the postgresql_user module. 2016-12-08 11:22:29 -05:00
Dan 789ee410f1 Adds a login_unix_socket option to the postgresql_db module. 2016-12-08 11:22:29 -05:00
Toshio Kuratomi 5734838cd1 Fix module traceback instead of returning an error 2016-12-08 11:22:29 -05:00
Toshio Kuratomi e8081baca9 Fix for single role_attr 2016-12-08 11:22:28 -05:00
Toshio Kuratomi 47b009b001 Add a bare grant to the list of allowed privileges 2016-12-08 11:22:28 -05:00
Devin Christensen b2829cf6b9 Fix user_alter in postgresql_user 2016-12-08 11:22:28 -05:00
Devin Christensen ff7a9eb625 Fix user_add in postgresql_user 2016-12-08 11:22:28 -05:00
Toshio Kuratomi bed60553ca Escape mysql identifiers 2016-12-08 11:22:28 -05:00
Toshio Kuratomi 87b2afc272 Correct new function name 2016-12-08 11:22:28 -05:00
Toshio Kuratomi 3e9771f544 Normalize privs and flags to uppercase so comparisons against allowed names will work 2016-12-08 11:22:28 -05:00
Toshio Kuratomi e0ac340f59 Make sure we quote or confirm good all user provided identifiers 2016-12-08 11:22:28 -05:00
Toshio Kuratomi d3787840a4 Audit escaping of identifiers in the postgresql_user module 2016-12-08 11:22:28 -05:00
Toshio Kuratomi 32aaa07325 More robust quoting of database identifiers
Note: These aren't database values, those are already using the
appropriate Pyhton DB API method for quoting.
2016-12-08 11:22:27 -05:00
Michael DeHaan 5d814d9fb2 Some more module categorization. 2016-12-08 11:22:25 -05:00
Michael DeHaan ef2a2b9093 package files 2016-12-08 11:22:22 -05:00
Michael DeHaan 213e518165 file extensions! 2016-12-08 11:22:22 -05:00
Michael DeHaan c7eec45b73 Restructuring. 2016-12-08 11:22:22 -05:00