Skip to content
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

Fix hacking/test-module to allow running modules with pdb #23339

Merged
merged 2 commits into from Jun 28, 2017

Conversation

michael-dev2rights
Copy link

@michael-dev2rights michael-dev2rights commented Apr 6, 2017

SUMMARY

hacking/test-module fails if given a debugger to run - this fixes that

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

hacking/test-module

ANSIBLE VERSION
ansible 2.3.0.0 (ansible-d2r ff3dc4f1e7) last updated 2017/03/21 10:44:16 (GMT +100)
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/mikedd/dev/ansible/ansible-d2r/library']
  python version = 2.7.12 (default, Jul  1 2016, 15:12:24) [GCC 5.4.0 20160609]
ADDITIONAL INFORMATION

what I did:
run
hacking/test-module -m lib/ansible/modules/system/ping.py --debugger=(which pdb)

what I expected to happen:
module should be run under pdb

what actually happened:
hacking/test-module crashed.

extra information:
at one point in debugging somewhere in the system I also had to patch an "import pdb.pdb" statement to be simply "import pdb" not sure where that was though.

PROMPT> hacking/test-module -m lib/ansible/modules/system/ping.py --debugger=(which pdb)
* including generated source, if any, saving to: /home/mikedd/.ansible_module_generated
Traceback (most recent call last):
  File "hacking/test-module", line 266, in <module>
    main()
  File "hacking/test-module", line 260, in main
    rundebug(options.debugger, modfile, argspath, modname, module_style)
  File "hacking/test-module", line 235, in rundebug
    modfile, argspath = ansiballz_setup(modfile, modname)
TypeError: ansiballz_setup() takes exactly 3 arguments (2 given)


PROMPT> git checkout mdd-fix-test-module-pdb
Switched to branch 'mdd-fix-test-module-pdb'
PROMPT> hacking/test-module -m lib/ansible/modules/system/ping.py --debugger=(which pdb)
* including generated source, if any, saving to: /home/mikedd/.ansible_module_generated
* ansiballz module detected; extracted module source to: /home/mikedd/debug_dir
> /home/mikedd/debug_dir/ansible_module_ping.py(23)<module>()
-> ANSIBLE_METADATA = {'metadata_version': '1.0',
(Pdb) 

@ansibot ansibot added affects_2.4 This issue/PR affects Ansible v2.4 bugfix_pull_request needs_triage Needs a first human triage before being processed. labels Apr 6, 2017
@michael-dev2rights
Copy link
Author

also added a .gitignore fix because it currently doesn't ignore #autosave# files.

@nitzmahone nitzmahone removed the needs_triage Needs a first human triage before being processed. label Apr 8, 2017
@gundalow gundalow requested a review from abadger May 24, 2017 16:23
@gundalow
Copy link
Contributor

If this is the right way then it needs documenting on dev_guide

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label May 24, 2017
@akofink
Copy link

akofink commented Jun 28, 2017

This fix works for me. I couldn't get pdb working with the test-module without it. I agree that there needs to be a section in the dev_guide for 'Debugging your module'.

@abadger abadger merged commit 56d33a2 into ansible:devel Jun 28, 2017
@s-hertel
Copy link
Contributor

Also appreciating this, though it would be nice to not have to patch the debugger. Epdb requires a lot of patching.

abadger pushed a commit that referenced this pull request Jun 28, 2017
* Fix hacking/test-module to allow running modules with pdb

* add emacs autosave files to gitignore

(cherry picked from commit 56d33a2)
abadger pushed a commit that referenced this pull request Aug 8, 2017
* Fix hacking/test-module to allow running modules with pdb

* add emacs autosave files to gitignore

(cherry picked from commit 56d33a2)
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bugfix_pull_request labels Mar 6, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants