summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Doran <sdoran@redhat.com>2021-02-07 01:52:15 -0500
committerGitHub <noreply@github.com>2021-02-07 00:52:15 -0600
commite9c6b382eaa90f806801a32f894411cc60dd359d (patch)
tree01629f63d54784dcc2d4692dc2e54b623cc282bc
parent3eafe0f255727dbf3283fd5d774ea7503a81adf6 (diff)
downloadansible-e9c6b382eaa90f806801a32f894411cc60dd359d.tar.gz
[stable-2.10] import_playbook - change additional params to deprecation (#72987) (#73015)
I incorrectly recommended this be set as a warning when it should have been a deprecation. * Fix deprecation sanity test to not required a collection name when not inside a collection (cherry picked from commit 8e022ef00a) Co-authored-by: Sam Doooran <sdoran@redhat.com>
-rw-r--r--changelogs/fragments/72745-import_playbook-deprecation-extra-params.yml2
-rw-r--r--changelogs/fragments/ansible-test-sanity-deprecation-collection-name.yml2
-rw-r--r--lib/ansible/modules/import_playbook.py4
-rw-r--r--lib/ansible/playbook/playbook_include.py3
-rwxr-xr-xtest/integration/targets/include_import/runme.sh2
-rw-r--r--test/lib/ansible_test/_data/sanity/pylint/plugins/deprecated.py2
6 files changed, 12 insertions, 3 deletions
diff --git a/changelogs/fragments/72745-import_playbook-deprecation-extra-params.yml b/changelogs/fragments/72745-import_playbook-deprecation-extra-params.yml
new file mode 100644
index 0000000000..7d23f674cf
--- /dev/null
+++ b/changelogs/fragments/72745-import_playbook-deprecation-extra-params.yml
@@ -0,0 +1,2 @@
+bugfixes:
+ - import_playbook - change warning about extra parameters to deprecation (https://github.com/ansible/ansible/issues/72745)
diff --git a/changelogs/fragments/ansible-test-sanity-deprecation-collection-name.yml b/changelogs/fragments/ansible-test-sanity-deprecation-collection-name.yml
new file mode 100644
index 0000000000..7cd993e110
--- /dev/null
+++ b/changelogs/fragments/ansible-test-sanity-deprecation-collection-name.yml
@@ -0,0 +1,2 @@
+bugfixes:
+ - ansble-test - only require a collection name in deprecation warnings when necessary (https://github.com/ansible/ansible/pull/72987)
diff --git a/lib/ansible/modules/import_playbook.py b/lib/ansible/modules/import_playbook.py
index 51ef23fae4..767a8a450f 100644
--- a/lib/ansible/modules/import_playbook.py
+++ b/lib/ansible/modules/import_playbook.py
@@ -42,6 +42,10 @@ EXAMPLES = r'''
- name: Include a play after another play
import_playbook: otherplays.yaml
+- name: Set variables on an imported playbook
+ import_playbook: otherplays.yml
+ vars:
+ service: httpd
- name: This DOES NOT WORK
hosts: all
diff --git a/lib/ansible/playbook/playbook_include.py b/lib/ansible/playbook/playbook_include.py
index 4aeecb1eda..01c9803102 100644
--- a/lib/ansible/playbook/playbook_include.py
+++ b/lib/ansible/playbook/playbook_include.py
@@ -150,7 +150,8 @@ class PlaybookInclude(Base, Conditional, Taggable):
else:
new_ds['import_playbook'] = items[0].strip()
if len(items) > 1:
- display.warning('Additional parameters in import_playbook statements are not supported. This will be an error in version 2.14')
+ display.deprecated("Additional parameters in import_playbook statements are deprecated. "
+ "Use 'vars' instead. See 'import_playbook' documentation for examples.", version='2.14')
# rejoin the parameter portion of the arguments and
# then use parse_kv() to get a dict of params back
params = parse_kv(" ".join(items[1:]))
diff --git a/test/integration/targets/include_import/runme.sh b/test/integration/targets/include_import/runme.sh
index 28115a5bb6..68b12a1f17 100755
--- a/test/integration/targets/include_import/runme.sh
+++ b/test/integration/targets/include_import/runme.sh
@@ -17,7 +17,7 @@ ansible -m include_role -a name=role1 localhost
## Import (static)
# Playbook
-test "$(ansible-playbook -i ../../inventory playbook/test_import_playbook.yml "$@" 2>&1 | grep -c '\[WARNING\]: Additional parameters in import_playbook')" = 1
+test "$(ANSIBLE_DEPRECATION_WARNINGS=1 ansible-playbook -i ../../inventory playbook/test_import_playbook.yml "$@" 2>&1 | grep -c '\[DEPRECATION WARNING\]: Additional parameters in import_playbook')" = 1
ANSIBLE_STRATEGY='linear' ansible-playbook playbook/test_import_playbook_tags.yml -i inventory "$@" --tags canary1,canary22,validate --skip-tags skipme
diff --git a/test/lib/ansible_test/_data/sanity/pylint/plugins/deprecated.py b/test/lib/ansible_test/_data/sanity/pylint/plugins/deprecated.py
index c88e5e5ae1..c06059c403 100644
--- a/test/lib/ansible_test/_data/sanity/pylint/plugins/deprecated.py
+++ b/test/lib/ansible_test/_data/sanity/pylint/plugins/deprecated.py
@@ -233,7 +233,7 @@ class AnsibleDeprecatedChecker(BaseChecker):
this_collection = collection_name == (self.collection_name or 'ansible.builtin')
if not this_collection:
self.add_message('wrong-collection-deprecated', node=node, args=(collection_name,))
- else:
+ elif self.collection_name is not None:
self.add_message('ansible-deprecated-no-collection-name', node=node)
if date: