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

Add debug strategy plugin #15125

Merged
merged 3 commits into from
Apr 8, 2016
Merged

Conversation

ks888
Copy link
Contributor

@ks888 ks888 commented Mar 23, 2016

ISSUE TYPE
  • Feature Pull Request
ANSIBLE VERSION
ansible 2.1.0 (add-debug-strategy-plugin db83400d71) last updated 2016/03/24 01:47:52 (GMT +900)
  lib/ansible/modules/core: (detached HEAD 7efc09ef08) last updated 2016/03/24 01:12:49 (GMT +900)
  lib/ansible/modules/extras: (detached HEAD 7f9cdc0350) last updated 2016/03/24 01:13:10 (GMT +900)
  config file =
  configured module search path = Default w/o overrides
SUMMARY

Add "debug" strategy. It enables you to invoke a debugger when a task is failed, and check several info, such as the value of a variable. Also, it is possible to update module arguments in the debugger, and run the failed task again with new arguments to consider how you can fix an issue.

There is a post about this strategy:
https://groups.google.com/forum/#!topic/ansible-project/IzjDLiIORlw

@sivel
Copy link
Member

sivel commented Mar 23, 2016

This should probably have some associated documentation included with it.

@bcoca bcoca added this to the 2.1.0 milestone Mar 23, 2016
@bcoca
Copy link
Member

bcoca commented Mar 23, 2016

We can get docs from the readme https://github.com/ks888/ansible-playbook-debugger

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 77c044c on ks888:add-debug-strategy-plugin into * on ansible:devel*.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling b75f48b on ks888:add-debug-strategy-plugin into * on ansible:devel*.

@ks888
Copy link
Contributor Author

ks888 commented Mar 24, 2016

@sivel @bcoca I've added usage document. It's a part of "Playbooks: Special Topics" and almost same as the original readme https://github.com/ks888/ansible-playbook-debugger, but written in reST.

@jpic
Copy link
Contributor

jpic commented Apr 5, 2016

Awesome !!! I just wanted to let you know it works for me:

$ cat test.yml 
- hosts: localhost
  connection: local
  strategy: debug
  gather_facts: no
  vars:
    var1: value1
  tasks:
    - name: wrong variable
      ping: data={{ wrong_var }}

$ ansible-playbook -i localhost, test.yml
PLAY [localhost] ***************************************************************

TASK [wrong variable] **********************************************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "'wrong_var' is undefined"}
Debugger invoked
(debug) p result
{'failed': True, 'msg': u"'wrong_var' is undefined"}
(debug) p task.args
{u'data': u'{{ wrong_var }}'}
(debug) redo
fatal: [localhost]: FAILED! => {"failed": true, "msg": "'wrong_var' is undefined"}
Debugger invoked
(debug) task.args['data'] = '{{ var1 }}'
(debug) redo
ok: [localhost]

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0   

Perhaps some tests would be nice to have.

@bcoca bcoca merged commit e4a6106 into ansible:devel Apr 8, 2016
self.result = result


class StrategyModule(linear.StrategyModule, StrategyBase):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I recently fixed the bug which made you have to inherit directly from StrategyBase. Try just leaving in linear.StrategyModule and see if it now works.

@ansibot ansibot added feature This issue/PR relates to a feature request. and removed feature_pull_request labels Mar 4, 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
feature This issue/PR relates to a feature request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants