diff --git a/changelogs/fragments/68569-start-at-fix.yaml b/changelogs/fragments/68569-start-at-fix.yaml new file mode 100644 index 00000000000..df1675ebb91 --- /dev/null +++ b/changelogs/fragments/68569-start-at-fix.yaml @@ -0,0 +1,2 @@ +bugfixes: +- Using --start-at-task would fail when it attempted to skip over tasks with no name. diff --git a/lib/ansible/executor/play_iterator.py b/lib/ansible/executor/play_iterator.py index 0fdcb2fedcc..c06b232d2b6 100644 --- a/lib/ansible/executor/play_iterator.py +++ b/lib/ansible/executor/play_iterator.py @@ -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 diff --git a/test/integration/targets/play_iterator/aliases b/test/integration/targets/play_iterator/aliases new file mode 100644 index 00000000000..3005e4b26d0 --- /dev/null +++ b/test/integration/targets/play_iterator/aliases @@ -0,0 +1 @@ +shippable/posix/group4 diff --git a/test/integration/targets/play_iterator/playbook.yml b/test/integration/targets/play_iterator/playbook.yml new file mode 100644 index 00000000000..76100c6089c --- /dev/null +++ b/test/integration/targets/play_iterator/playbook.yml @@ -0,0 +1,10 @@ +--- +- hosts: localhost + gather_facts: false + tasks: + - name: + debug: + msg: foo + - name: "task 2" + debug: + msg: bar diff --git a/test/integration/targets/play_iterator/runme.sh b/test/integration/targets/play_iterator/runme.sh new file mode 100755 index 00000000000..9f30d9e7a2f --- /dev/null +++ b/test/integration/targets/play_iterator/runme.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -eux + +ansible-playbook playbook.yml --start-at-task 'task 2' "$@"