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:
parent
cb389f6c31
commit
af44bd4ddd
5 changed files with 19 additions and 1 deletions
2
changelogs/fragments/68569-start-at-fix.yaml
Normal file
2
changelogs/fragments/68569-start-at-fix.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- Using --start-at-task would fail when it attempted to skip over tasks with no name.
|
|
@ -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
|
||||
|
|
1
test/integration/targets/play_iterator/aliases
Normal file
1
test/integration/targets/play_iterator/aliases
Normal file
|
@ -0,0 +1 @@
|
|||
shippable/posix/group4
|
10
test/integration/targets/play_iterator/playbook.yml
Normal file
10
test/integration/targets/play_iterator/playbook.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
- hosts: localhost
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name:
|
||||
debug:
|
||||
msg: foo
|
||||
- name: "task 2"
|
||||
debug:
|
||||
msg: bar
|
5
test/integration/targets/play_iterator/runme.sh
Executable file
5
test/integration/targets/play_iterator/runme.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eux
|
||||
|
||||
ansible-playbook playbook.yml --start-at-task 'task 2' "$@"
|
Loading…
Reference in a new issue