Merge pull request #2622 from skvidal/playbook-start-at-task

implement --start-at-task option to hop to a specific task before starti...
pull/2649/merge
Michael DeHaan 12 years ago
commit 3e736eaf00

@ -75,6 +75,8 @@ def main(args):
help="do list all tasks that would be executed") help="do list all tasks that would be executed")
parser.add_option('--step', dest='step', action='store_true', parser.add_option('--step', dest='step', action='store_true',
help="one-step-at-a-time: confirm each task before running") help="one-step-at-a-time: confirm each task before running")
parser.add_option('--start-at-task', dest='start_at',
help="start the playbook with a task matching this name")
options, args = parser.parse_args(args) options, args = parser.parse_args(args)
@ -116,6 +118,8 @@ def main(args):
playbook_cb = callbacks.PlaybookCallbacks(verbose=utils.VERBOSITY) playbook_cb = callbacks.PlaybookCallbacks(verbose=utils.VERBOSITY)
if options.step: if options.step:
playbook_cb.step = options.step playbook_cb.step = options.step
if options.start_at:
playbook_cb.start_at = options.start_at
runner_cb = callbacks.PlaybookRunnerCallbacks(stats, verbose=utils.VERBOSITY) runner_cb = callbacks.PlaybookRunnerCallbacks(stats, verbose=utils.VERBOSITY)
pb = ansible.playbook.PlayBook( pb = ansible.playbook.PlayBook(

@ -21,6 +21,7 @@ import getpass
import os import os
import subprocess import subprocess
import random import random
import fnmatch
from ansible.color import stringc from ansible.color import stringc
cowsay = None cowsay = None
@ -461,7 +462,14 @@ class PlaybookCallbacks(object):
if is_conditional: if is_conditional:
msg = "NOTIFIED: [%s]" % name msg = "NOTIFIED: [%s]" % name
if hasattr(self, 'step') and self.step: if hasattr(self, 'start_at'):
if name == self.start_at or fnmatch.fnmatch(name, self.start_at):
# we found out match, we can get rid of this now
del self.start_at
if hasattr(self, 'start_at'): # we still have start_at so skip the task
self.skip_task = True
elif hasattr(self, 'step') and self.step:
resp = raw_input('Perform task: %s (y/n/c): ' % name) resp = raw_input('Perform task: %s (y/n/c): ' % name)
if resp.lower() in ['y','yes']: if resp.lower() in ['y','yes']:
self.skip_task = False self.skip_task = False

Loading…
Cancel
Save