diff --git a/changelogs/fragments/66764-host-pattern-warning.yml b/changelogs/fragments/66764-host-pattern-warning.yml new file mode 100644 index 00000000000..df76073e0ef --- /dev/null +++ b/changelogs/fragments/66764-host-pattern-warning.yml @@ -0,0 +1,2 @@ +bugfixes: + - Fix incorrect "Could not match supplied host pattern" warning (https://github.com/ansible/ansible/issues/66764) diff --git a/lib/ansible/playbook/play.py b/lib/ansible/playbook/play.py index f84fff09e57..35dfc558c8e 100644 --- a/lib/ansible/playbook/play.py +++ b/lib/ansible/playbook/play.py @@ -53,7 +53,7 @@ class Play(Base, Taggable, CollectionSearch): """ # ================================================================================= - _hosts = FieldAttribute(isa='list', required=True, listof=string_types, always_post_validate=True) + _hosts = FieldAttribute(isa='list', required=True, listof=string_types, always_post_validate=True, priority=-1) # Facts _gather_facts = FieldAttribute(isa='bool', default=None, always_post_validate=True) diff --git a/test/integration/targets/include_import/empty_group_warning/playbook.yml b/test/integration/targets/include_import/empty_group_warning/playbook.yml new file mode 100644 index 00000000000..6da5b7c3f53 --- /dev/null +++ b/test/integration/targets/include_import/empty_group_warning/playbook.yml @@ -0,0 +1,13 @@ +--- +- hosts: localhost + gather_facts: false + tasks: + - name: Group + group_by: + key: test_{{ inventory_hostname }} + +- hosts: test_localhost + gather_facts: false + tasks: + - name: Print + import_tasks: tasks.yml diff --git a/test/integration/targets/include_import/empty_group_warning/tasks.yml b/test/integration/targets/include_import/empty_group_warning/tasks.yml new file mode 100644 index 00000000000..2fbad77337c --- /dev/null +++ b/test/integration/targets/include_import/empty_group_warning/tasks.yml @@ -0,0 +1,3 @@ +- name: test + debug: + msg: hello diff --git a/test/integration/targets/include_import/runme.sh b/test/integration/targets/include_import/runme.sh index 199cd472bc3..f72a6ebaddc 100755 --- a/test/integration/targets/include_import/runme.sh +++ b/test/integration/targets/include_import/runme.sh @@ -108,3 +108,6 @@ ansible-playbook valid_include_keywords/playbook.yml "$@" # https://github.com/ansible/ansible/issues/64902 ansible-playbook tasks/test_allow_single_role_dup.yml 2>&1 | tee test_allow_single_role_dup.out test "$(grep -c 'ok=3' test_allow_single_role_dup.out)" = 1 + +# https://github.com/ansible/ansible/issues/66764 +ANSIBLE_HOST_PATTERN_MISMATCH=error ansible-playbook empty_group_warning/playbook.yml