# step through a playbook

**URL:** <https://forum.ansible.com/t/step-through-a-playbook/12327>\
**Category:** Ansible Project\
**Created:** [February 10, 2013, 6:35pm UTC](https://forum.ansible.com/t/step-through-a-playbook/12327 "2013-02-10T18:35:37Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Seth\_Vidal](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@Seth\_Vidal](https://forum.ansible.com/u/Seth_Vidal)\
**Post date:** [February 10, 2013, 6:35pm UTC](https://forum.ansible.com/t/step-through-a-playbook/12327/1 "2013-02-10T18:35:37Z")

</div>

I had an idea for a feature when I was debugging an old playbook on a new type of host.

I would love to be able to do per-action confirmation before execution for a playbook.

something like:

ansible-playbook --ask myplaybook.yml

and then have it ask for a 'y/n' before every action it will take. So I can step around a known problem, for example.

Is that completely ridiculous or something folks might find useful? Seems like it would only require a pre-execution callback of some kind - which I'm not sure we have yet - but might be do-able.

-sv

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 10, 2013, 6:42pm UTC](https://forum.ansible.com/t/step-through-a-playbook/12327/2 "2013-02-10T18:42:36Z")

</div>

I like having the option, what do others think? (I'm tentatively  
thinking this is called --step-through)

This could possibly be implemented by interlacing calls to the pause  
module between tasks, not sure if that's the easiest route though.

---

<div class="post-metadata">

**Author:** ![jpmens1](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@jpmens1](https://forum.ansible.com/u/jpmens1)\
**Post date:** [February 10, 2013, 7:41pm UTC](https://forum.ansible.com/t/step-through-a-playbook/12327/3 "2013-02-10T19:41:13Z")

</div>

> something like:
> 
> ansible-playbook --ask myplaybook.yml
> 
> and then have it ask for a 'y/n' before every action it will take.  
> So I can step around a known problem, for example.

Incredibly useful, for beginners and for debugging. Yes, please!

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-JP

---

<div class="post-metadata">

**Author:** ![Ahmad\_Khayyat](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@Ahmad\_Khayyat](https://forum.ansible.com/u/Ahmad_Khayyat)\
**Post date:** [February 11, 2013, 12:08am UTC](https://forum.ansible.com/t/step-through-a-playbook/12327/4 "2013-02-11T00:08:55Z")

</div>

Strongly agree. This would be very useful.  
I suggest to call the option --step.

---

<div class="post-metadata">

**Author:** ![fdavis](https://avatars.discourse-cdn.com/v4/letter/f/a698b9/32.png) [@fdavis](https://forum.ansible.com/u/fdavis)\
**Post date:** [February 12, 2013, 11:05pm UTC](https://forum.ansible.com/t/step-through-a-playbook/12327/5 "2013-02-12T23:05:38Z")

</div>

+1

---

<div class="post-metadata">

**Author:** ![Seth\_Vidal](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@Seth\_Vidal](https://forum.ansible.com/u/Seth_Vidal)\
**Post date:** [March 11, 2013, 4:41am UTC](https://forum.ansible.com/t/step-through-a-playbook/12327/6 "2013-03-11T04:41:07Z")

</div>

I've implemented this and  
here's a Pull request for  
it.

[https://github.com/ansible/ansible/pull/2354](https://github.com/ansible/ansible/pull/2354)

I implemented it in the simplest way I could think of - as always I'm  
willing to be told that this way was not a good idea 🙂

-sv

---

<div class="post-metadata">

**Author:** ![Asad\_Khan](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@Asad\_Khan](https://forum.ansible.com/u/Asad_Khan)\
**Post date:** [March 13, 2013, 8:23pm UTC](https://forum.ansible.com/t/step-through-a-playbook/12327/7 "2013-03-13T20:23:54Z")

</div>

Very useful, not just for debug, but even for certain sensitive deployments

---

<div class="post-metadata">

**Author:** ![Seth\_Vidal](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@Seth\_Vidal](https://forum.ansible.com/u/Seth_Vidal)\
**Post date:** [March 14, 2013, 8:35pm UTC](https://forum.ansible.com/t/step-through-a-playbook/12327/8 "2013-03-14T20:35:50Z")

</div>

Michael mentioned something to me today that might be worth trying to  
do.

if we number each task in a playbook sequentially (starting from 1).

we could do something like

ansible-playbook --step --start-from 23 someplaybook.yml

which would skip the first 22 actions and start on #23 stepping through  
them.

almost like breakpoints 😉

-sv

---

<div class="post-metadata">

**Author:** ![jpmens1](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@jpmens1](https://forum.ansible.com/u/jpmens1)\
**Post date:** [March 14, 2013, 8:51pm UTC](https://forum.ansible.com/t/step-through-a-playbook/12327/9 "2013-03-14T20:51:36Z")

</div>

> if we number each task in a playbook sequentially (starting from 1).
> 
> we could do something like
> 
> ansible-playbook --step --start-from 23 someplaybook.yml
> 
> which would skip the first 22 actions and start on #23 stepping through  
> them.
> 
> almost like breakpoints 😉

I want that! Thinking that numbering is ok, but how about adding a  
label?

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- name: do something  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;action: shell echo foo  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;label: debug1

I could add a label when I want to start breakpointing:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ansible-playbook --start-from debug1 someplaybook.yml

Anyhow, breakpoints would really be nice to have!

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-JP

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [March 14, 2013, 9:09pm UTC](https://forum.ansible.com/t/step-through-a-playbook/12327/10 "2013-03-14T21:09:17Z")

</div>

soo name: as a label? tags may also work.

---

<div class="post-metadata">

**Author:** ![jpmens1](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@jpmens1](https://forum.ansible.com/u/jpmens1)\
**Post date:** [March 14, 2013, 9:19pm UTC](https://forum.ansible.com/t/step-through-a-playbook/12327/11 "2013-03-14T21:19:17Z")

</div>

> soo name: as a label? tags may also work.

name: contains (can contain) white space. Difficult, no?

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-JP

---

<div class="post-metadata">

**Author:** ![Seth\_Vidal](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@Seth\_Vidal](https://forum.ansible.com/u/Seth_Vidal)\
**Post date:** [March 14, 2013, 9:25pm UTC](https://forum.ansible.com/t/step-through-a-playbook/12327/12 "2013-03-14T21:25:29Z")

</div>

feels like a label HAS to be unique.

a tag could be a group of things (or more like a tag on a picture, like  
in flickr)

labels == unique to the action  
tags == groups of actions or of plays, etc

-sv

---

<div class="post-metadata">

**Author:** ![kahlil.hodgson](https://avatars.discourse-cdn.com/v4/letter/k/b9bd4f/32.png) [@kahlil.hodgson](https://forum.ansible.com/u/kahlil.hodgson)\
**Post date:** [March 14, 2013, 11:53pm UTC](https://forum.ansible.com/t/step-through-a-playbook/12327/13 "2013-03-14T23:53:12Z")

</div>

Would be tempted to call it 'breakpoint' since that its what its being used for.

K

---

<div class="post-metadata">

**Author:** ![Seth\_Vidal](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@Seth\_Vidal](https://forum.ansible.com/u/Seth_Vidal)\
**Post date:** [March 14, 2013, 11:59pm UTC](https://forum.ansible.com/t/step-through-a-playbook/12327/14 "2013-03-14T23:59:55Z")

</div>

yah - but I can imagine it being used for other things not just  
debugging.

\<shrug\>

@mdehaan - you have a suggestion on if this is all crackrock?

-sv

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [March 15, 2013, 12:02am UTC](https://forum.ansible.com/t/step-through-a-playbook/12327/15 "2013-03-15T00:02:08Z")

</div>

The number requires a playbook run to know what number to use. This  
makes it fine in some cases but harder in others.

I'd say take a name (or even a fnmatch), it's not like you can't quote  
it, and start running on the first name that matches.

(BTW, assume it is implied but --start-at-task should not require --step)

---

<div class="post-metadata">

**Author:** ![kahlil.hodgson](https://avatars.discourse-cdn.com/v4/letter/k/b9bd4f/32.png) [@kahlil.hodgson](https://forum.ansible.com/u/kahlil.hodgson)\
**Post date:** [March 15, 2013, 12:38am UTC](https://forum.ansible.com/t/step-through-a-playbook/12327/16 "2013-03-15T00:38:47Z")

</div>

Using 'name' avoids adding new syntax and having to explain to users what the difference between a 'name' and a 'label' is. Using 'name' also means '--start-at-task' can be used on an unmodified playbook. Plus I'd generally think task names are likely to be unique across a playbook run (or at least that would be a best practice). Can think of a case where it makes much sense to use the same name twice -- it would make interpreting the output a bit tricky.

K

---

<div class="post-metadata">

**Author:** ![Seth\_Vidal](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@Seth\_Vidal](https://forum.ansible.com/u/Seth_Vidal)\
**Post date:** [March 15, 2013, 1:16am UTC](https://forum.ansible.com/t/step-through-a-playbook/12327/17 "2013-03-15T01:16:57Z")

</div>

names are not actually required, are they?

what does ansible stick in there when a name is not specified? Just the  
last name?

-sv

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [March 15, 2013, 1:22am UTC](https://forum.ansible.com/t/step-through-a-playbook/12327/18 "2013-03-15T01:22:42Z")

</div>

names are not required.

Ansible sticks in the task command line, with global variable  
substitution, but not inventory variable substitution.

Also, if you are using the short or complex variable forms, it's hard  
to guess what that string is, true.

--Michael

---

<div class="post-metadata">

**Author:** ![Seth\_Vidal](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@Seth\_Vidal](https://forum.ansible.com/u/Seth_Vidal)\
**Post date:** [March 15, 2013, 5:26am UTC](https://forum.ansible.com/t/step-through-a-playbook/12327/19 "2013-03-15T05:26:36Z")

</div>

So that means if you want to use --start-from you need to give an  
action a name?

I wonder how an unnamed action shows up in --step with a complex  
variable form.

bet that's a treat to see...

oh well - simple fix for the person who complains - put in a name.

-sv

---

<div class="post-metadata">

**Author:** ![Dag\_Wieers](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@Dag\_Wieers](https://forum.ansible.com/u/Dag_Wieers)\
**Post date:** [March 15, 2013, 11:26am UTC](https://forum.ansible.com/t/step-through-a-playbook/12327/20 "2013-03-15T11:26:08Z")

</div>

I'd go for using fnmatch on name (or action if name is absent) if people want to step through (and using breakpoints) they can add something unique to the name if they really want to have a guaranteed single breakpoint.

The clear benefit is that if you want to e.g. debug an NTP related issue, there's a high chance that using 'ntp' in the fnmatch will simply do the right thing out of the box.

In this case I would even go for a case-insensitive match.
