Fix --start-at-task when skipping tasks with no name (#68951)

Using --start-at-task on a playbook with tasks with no name would fail
if those unnamed tasks were encountered before the targetted start task.
This commit is contained in:
David Shrewsbury 2020-04-21 03:39:17 -04:00 committed by GitHub
parent cb389f6c31
commit af44bd4ddd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 1 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- Using --start-at-task would fail when it attempted to skip over tasks with no name.

View file

@ -201,7 +201,7 @@ class PlayIterator:
(s, task) = self.get_next_task_for_host(host, peek=True)
if s.run_state == self.ITERATING_COMPLETE:
break
if task.name == play_context.start_at_task or fnmatch.fnmatch(task.name, play_context.start_at_task) or \
if task.name == play_context.start_at_task or (task.name and fnmatch.fnmatch(task.name, play_context.start_at_task)) or \
task.get_name() == play_context.start_at_task or fnmatch.fnmatch(task.get_name(), play_context.start_at_task):
start_at_matched = True
break

View file

@ -0,0 +1 @@
shippable/posix/group4

View file

@ -0,0 +1,10 @@
---
- hosts: localhost
gather_facts: false
tasks:
- name:
debug:
msg: foo
- name: "task 2"
debug:
msg: bar

View file

@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -eux
ansible-playbook playbook.yml --start-at-task 'task 2' "$@"