import_playbook - change additional params to deprecation (#72987)

* import_playbook - change additional params to deprecation

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
This commit is contained in:
Sam Doooran 2020-12-17 14:14:58 -05:00 committed by GitHub
parent dbc2c996ab
commit 8e022ef00a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 3 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- import_playbook - change warning about extra parameters to deprecation (https://github.com/ansible/ansible/issues/72745)

View file

@ -42,6 +42,10 @@ EXAMPLES = r'''
- name: Include a play after another play - name: Include a play after another play
import_playbook: otherplays.yaml import_playbook: otherplays.yaml
- name: Set variables on an imported playbook
import_playbook: otherplays.yml
vars:
service: httpd
- name: This DOES NOT WORK - name: This DOES NOT WORK
hosts: all hosts: all

View file

@ -172,7 +172,8 @@ class PlaybookInclude(Base, Conditional, Taggable):
else: else:
new_ds['import_playbook'] = items[0].strip() new_ds['import_playbook'] = items[0].strip()
if len(items) > 1: 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 # rejoin the parameter portion of the arguments and
# then use parse_kv() to get a dict of params back # then use parse_kv() to get a dict of params back
params = parse_kv(" ".join(items[1:])) params = parse_kv(" ".join(items[1:]))

View file

@ -17,7 +17,7 @@ ansible -m include_role -a name=role1 localhost
## Import (static) ## Import (static)
# Playbook # 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 ANSIBLE_STRATEGY='linear' ansible-playbook playbook/test_import_playbook_tags.yml -i inventory "$@" --tags canary1,canary22,validate --skip-tags skipme

View file

@ -242,7 +242,7 @@ class AnsibleDeprecatedChecker(BaseChecker):
this_collection = collection_name == (self.collection_name or 'ansible.builtin') this_collection = collection_name == (self.collection_name or 'ansible.builtin')
if not this_collection: if not this_collection:
self.add_message('wrong-collection-deprecated', node=node, args=(collection_name,)) 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) self.add_message('ansible-deprecated-no-collection-name', node=node)
if date: if date: