From 9b28f1f5d931b727f2a06270314f2c2a8a5494bb Mon Sep 17 00:00:00 2001 From: Vasili Date: Fri, 14 Feb 2020 23:50:52 +0200 Subject: [PATCH] Fix incorrect "Could not match supplied host pattern" warning (#66764) (#67432) --- changelogs/fragments/66764-host-pattern-warning.yml | 2 ++ lib/ansible/playbook/play.py | 2 +- .../include_import/empty_group_warning/playbook.yml | 13 +++++++++++++ .../include_import/empty_group_warning/tasks.yml | 3 +++ test/integration/targets/include_import/runme.sh | 3 +++ 5 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/66764-host-pattern-warning.yml create mode 100644 test/integration/targets/include_import/empty_group_warning/playbook.yml create mode 100644 test/integration/targets/include_import/empty_group_warning/tasks.yml 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