New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR #41748 Added no-data option to dump process so only an empty schema can be … #41904

Open
wants to merge 10 commits into
base: devel
from

Conversation

Projects
None yet
6 participants
@jw34

jw34 commented Jun 25, 2018

…dumped as per FR #41748

SUMMARY

changes to mysql_db module to include --no-data dump option (to dump just a DB schema)

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

mysql_db

ANSIBLE VERSION

ansible 2.5.5
config file = None
configured module search path = [u'/home/jwolfe/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /home/jwolfe/venvs/vibrent/local/lib/python2.7/site-packages/ansible
executable location = /home/jwolfe/venvs/vibrent/bin/ansible
python version = 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0]

ADDITIONAL INFORMATION

modified mysql_db.py to include no-data dump option.

@ansibot

This comment has been minimized.

Contributor

ansibot commented Jun 25, 2018

The test ansible-test sanity --test pylint [explain] failed with 1 error:

lib/ansible/modules/database/mysql/mysql_db.py:138:0: syntax-error invalid syntax (<string>, line 138)

The test ansible-test sanity --test ansible-doc --python 2.6 [explain] failed with 1 error:

lib/ansible/modules/database/mysql/mysql_db.py:0:0: has a documentation error formatting or is missing documentation.

The test ansible-test sanity --test ansible-doc --python 2.7 [explain] failed with 1 error:

lib/ansible/modules/database/mysql/mysql_db.py:0:0: has a documentation error formatting or is missing documentation.

The test ansible-test sanity --test ansible-doc --python 3.5 [explain] failed with 1 error:

lib/ansible/modules/database/mysql/mysql_db.py:0:0: has a documentation error formatting or is missing documentation.

The test ansible-test sanity --test ansible-doc --python 3.6 [explain] failed with 1 error:

lib/ansible/modules/database/mysql/mysql_db.py:0:0: has a documentation error formatting or is missing documentation.

The test ansible-test sanity --test ansible-doc --python 3.7 [explain] failed with 1 error:

lib/ansible/modules/database/mysql/mysql_db.py:0:0: has a documentation error formatting or is missing documentation.

The test ansible-test sanity --test compile --python 2.7 [explain] failed with 1 error:

lib/ansible/modules/database/mysql/mysql_db.py:138:91: SyntaxError: def db_dump(module, host, user, password, db_name, target, all_databases, no_data=None port, config_file, socket=None, ssl_cert=None, ssl_key=None, ssl_ca=None,

The test ansible-test sanity --test compile --python 3.5 [explain] failed with 1 error:

lib/ansible/modules/database/mysql/mysql_db.py:138:91: SyntaxError: def db_dump(module, host, user, password, db_name, target, all_databases, no_data=None port, config_file, socket=None, ssl_cert=None, ssl_key=None, ssl_ca=None,

The test ansible-test sanity --test compile --python 2.6 [explain] failed with 1 error:

lib/ansible/modules/database/mysql/mysql_db.py:138:91: SyntaxError: def db_dump(module, host, user, password, db_name, target, all_databases, no_data=None port, config_file, socket=None, ssl_cert=None, ssl_key=None, ssl_ca=None,

The test ansible-test sanity --test compile --python 3.6 [explain] failed with 1 error:

lib/ansible/modules/database/mysql/mysql_db.py:138:91: SyntaxError: def db_dump(module, host, user, password, db_name, target, all_databases, no_data=None port, config_file, socket=None, ssl_cert=None, ssl_key=None, ssl_ca=None,

The test ansible-test sanity --test compile --python 3.7 [explain] failed with 1 error:

lib/ansible/modules/database/mysql/mysql_db.py:138:91: SyntaxError: def db_dump(module, host, user, password, db_name, target, all_databases, no_data=None port, config_file, socket=None, ssl_cert=None, ssl_key=None, ssl_ca=None,

The test ansible-test sanity --test docs-build [explain] failed with the error:

Command "/usr/bin/python test/sanity/code-smell/docs-build.py" returned exit status 1.
>>> Standard Error
Traceback (most recent call last):
  File "test/sanity/code-smell/docs-build.py", line 101, in <module>
    main()
  File "test/sanity/code-smell/docs-build.py", line 17, in main
    raise subprocess.CalledProcessError(sphinx.returncode, cmd, output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['make', 'singlehtmldocs']' returned non-zero exit status 2.

The test ansible-test sanity --test import --python 2.6 [explain] failed with 1 error:

lib/ansible/modules/database/mysql/mysql_db.py:138:91: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 2.7 [explain] failed with 2 errors:

lib/ansible/modules/database/mysql/mysql_db.py:0:0: SyntaxError: invalid syntax (mysql_db.py, line 138) (in /root/ansible/test/runner/.tox/minimal-py27/bin/importer.py:82)
lib/ansible/modules/database/mysql/mysql_db.py:138:91: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.5 [explain] failed with 2 errors:

lib/ansible/modules/database/mysql/mysql_db.py:0:0: SyntaxError: invalid syntax (mysql_db.py, line 138) (in /root/ansible/test/runner/.tox/minimal-py35/bin/importer.py:82)
lib/ansible/modules/database/mysql/mysql_db.py:138:91: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.6 [explain] failed with 2 errors:

lib/ansible/modules/database/mysql/mysql_db.py:0:0: SyntaxError: invalid syntax (mysql_db.py, line 138) (in /root/ansible/test/runner/.tox/minimal-py36/bin/importer.py:82)
lib/ansible/modules/database/mysql/mysql_db.py:138:91: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.7 [explain] failed with 2 errors:

lib/ansible/modules/database/mysql/mysql_db.py:0:0: SyntaxError: invalid syntax (mysql_db.py, line 138) (in /root/ansible/test/runner/.tox/minimal-py37/bin/importer.py:82)
lib/ansible/modules/database/mysql/mysql_db.py:138:91: SyntaxError: invalid syntax

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/modules/database/mysql/mysql_db.py:165:33: W291 trailing whitespace

The test ansible-test sanity --test validate-modules [explain] failed with 2 errors:

lib/ansible/modules/database/mysql/mysql_db.py:0:0: E401 Python SyntaxError while parsing module
test/sanity/validate-modules/ignore.txt:569:1: A102 Remove since "lib/ansible/modules/database/mysql/mysql_db.py" passes "E210" test

The test ansible-test sanity --test yamllint [explain] failed with 1 error:

lib/ansible/modules/database/mysql/mysql_db.py:138:91: python-syntax-error invalid syntax (<unknown>, line 138)

click here for bot help

@jw34

This comment has been minimized.

jw34 commented Jun 25, 2018

fixed syntax error in f919ce48e27d1e66c84bffe078e02fa4330569ea

@ansibot

This comment has been minimized.

Contributor

ansibot commented Jun 25, 2018

The test ansible-test sanity --test pylint [explain] failed with 2 errors:

lib/ansible/modules/database/mysql/mysql_db.py:165:0: trailing-whitespace Trailing whitespace
lib/ansible/modules/database/mysql/mysql_db.py:352:70: undefined-variable Undefined variable 'no_data'

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/modules/database/mysql/mysql_db.py:165:33: W291 trailing whitespace

The test ansible-test sanity --test validate-modules [explain] failed with 2 errors:

lib/ansible/modules/database/mysql/mysql_db.py:0:0: E322 "no_data" is listed in the argument_spec, but not documented in the module
lib/ansible/modules/database/mysql/mysql_db.py:0:0: E325 argument_spec for "no_data" defines type="bool" but documentation does not

click here for bot help

@mattclay

This comment has been minimized.

Member

mattclay commented Jun 27, 2018

Traceback in integration tests:

Traceback (most recent call last):
  File "/tmp/ansible_85Kvoe/ansible_module_mysql_db.py", line 427, in <module>
    main()
  File "/tmp/ansible_85Kvoe/ansible_module_mysql_db.py", line 360, in main
    ssl_ca, single_transaction, quick, ignore_tables)
  File "/tmp/ansible_85Kvoe/ansible_module_mysql_db.py", line 163, in db_dump
    cmd += " --host=%s --port=%i" % (pipes.quote(host), port)
TypeError: %d format: a number is required, not NoneType
@ansibot

This comment has been minimized.

Contributor

ansibot commented Jul 5, 2018

@jw34 this PR contains the following merge commits:

Please rebase your branch to remove these commits.

click here for bot help

@ansibot

This comment has been minimized.

Contributor

ansibot commented Jul 5, 2018

The test ansible-test sanity --test pylint [explain] failed with 1 error:

lib/ansible/modules/database/mysql/mysql_db.py:171:0: trailing-whitespace Trailing whitespace

The test ansible-test sanity --test pep8 [explain] failed with 2 errors:

lib/ansible/modules/database/mysql/mysql_db.py:144:161: E501 line too long (161 > 160 characters)
lib/ansible/modules/database/mysql/mysql_db.py:171:33: W291 trailing whitespace

click here for bot help

@ansibot

This comment has been minimized.

Contributor

ansibot commented Jul 5, 2018

@jw34 this PR contains the following merge commits:

Please rebase your branch to remove these commits.

click here for bot help

@jw34 jw34 force-pushed the jw34:fr_41748_mysql_db_feature branch to 6ae3116 Jul 5, 2018

@defionscode

This comment has been minimized.

Contributor

defionscode commented Jul 10, 2018

shipit

@jorijinnall

This comment has been minimized.

Contributor

jorijinnall commented Oct 8, 2018

Here are some details about my test.
My environment

ansible 2.7.0.dev0 (fr_41748_mysql_db_feature 13ed4a5f68) last updated 2018/10/08 18:08:31 (GMT +200)
  config file = None
  configured module search path = ['/Users/jdelannoye/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/jdelannoye/Projects/Ansible/ansible/lib/ansible
  executable location = ./bin/ansible
  python version = 3.7.0 (default, Jun 29 2018, 20:13:53) [Clang 8.0.0 (clang-800.0.42.1)]

The host

vagrant@ubuntu:/tmp$ dpkg -l | grep "mysql-server "
ii  mysql-server                         5.7.23-0ubuntu0.16.04.1                    all          MySQL database server (metapackage depending on the latest version)
vagrant@ubuntu:/tmp$ lsb_release -d
Description:	Ubuntu 16.04.5 LTS
vagrant@ubuntu:/tmp$ python --version
Python 2.7.12

MySQL preparation :

mysql> create database test;
mysql> use test;
Database changed
mysql> create table test (test varchar(30));
Query OK, 0 rows affected (0.01 sec)
mysql> insert into test VALUE ("value test");
Query OK, 1 row affected (0.00 sec)

mysql> select * from test;
+------------+
| test       |
+------------+
| value test |
+------------+
1 row in set (0.00 sec)```

I ran this playbook : 

```- hosts: all
  become: yes
  tasks:
  - name: mysql get data
    mysql_db:
      state: dump
      name: test
      login_user: root
      login_password: XXXXXXX
      no_data: yes
      target: /tmp/dump.sql```

And then a SQL file without the data
@ansibot

This comment has been minimized.

Contributor

ansibot commented Nov 25, 2018

The test ansible-test sanity --test validate-modules [explain] failed with 1 error:

lib/ansible/modules/database/mysql/mysql_db.py:0:0: E309 version_added for new option (no_data) should be 2.8. Currently 2.7

click here for bot help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment