Repository: ansible/ansible

Issue:
ERROR! 'import_plays' is not a valid attribute for a Play
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
* `import_plays`

##### ANSIBLE VERSION
```
ansible 2.5.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/ash/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
```

##### CONFIGURATION
```
PERSISTENT_CONNECT_TIMEOUT(/etc/ansible/ansible.cfg) = 30
```

##### OS / ENVIRONMENT
Ubuntu 16.04, 64 bits.

##### SUMMARY
Trying to import a play throws an unexpected error.

##### STEPS TO REPRODUCE
Run this bash commands to reproduce:
```
cd
mkdir import_plays_error
cd import_plays_error

echo '
---
- hosts: localhost
  roles:
    - {role: "foo", bar: "baz_1"}
- import_plays: ./plays/test.yml
' > index.yml

mkdir roles
ansible-galaxy init --init-path roles/ foo
echo '
---
# tasks file for foo
- name: foo task
  debug: msg={{bar}}
' > roles/foo/tasks/main.yml

mkdir plays
echo '
---
- hosts: localhost
  roles:
    - {role: "foo", bar: "baz_2"}
- import_plays: ./plays/test.yml
' > plays/test.yml

ansible-playbook -vvvv index.yml
```

##### EXPECTED RESULTS
I expected to have the play imported in the parent one.

##### ACTUAL RESULTS
This is the output given from the `ansible-playbook -vvvv index.yml` command:
```
ansible-playbook 2.5.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/ash/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
Parsed /etc/ansible/hosts inventory source with ini plugin
 [WARNING]: Could not match supplied host pattern, ignoring: all

 [WARNING]: provided hosts list is empty, only localhost is available

ERROR! 'import_plays' is not a valid attribute for a Play

The error appears to have been in '/home/ash/import_plays_error/index.yml': line 6, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

    - {role: "foo", bar: "baz_1"}
- import_plays: ./plays/test.yml
  ^ here
```



Discussion:
Maybe an error in the documentation.

-- here it's mentioned as `import_playbook`
[https://docs.ansible.com/ansible/latest/playbooks_reuse.html](https://docs.ansible.com/ansible/latest/playbooks_reuse.html#dynamic-vs-static)

-- where as here it's mentioned as `import_plays`
[https://docs.ansible.com/ansible/latest/playbooks_best_practices.html](https://docs.ansible.com/ansible/latest/playbooks_best_practices.html#top-level-playbooks-are-separated-by-role)
https://docs.ansible.com/ansible/latest/import_plays_module.html

If you change your code

    # - import_plays: ./plays/test.yml
    - import_playbook: ./plays/test.yml
it would do what you expect. (btw. you need as well to fix `plays/test.yml` before)
Alright, so I confirm that it seems to be a documentation issue, using `import_playbook` instead of `import_plays` works for me (of course, after fixing `plays/text.yml`^^). Thank you @SubOptimal!

Resolving patch:
diff --git a/lib/ansible/modules/utilities/logic/_include.py b/lib/ansible/modules/utilities/logic/_include.py
--- a/lib/ansible/modules/utilities/logic/_include.py
+++ b/lib/ansible/modules/utilities/logic/_include.py
@@ -20,7 +20,7 @@
 short_description: include a play or task list.
 deprecated:
     The include action was too confusing, dealing with both plays and tasks, being both dynamic and static.  This module will be removed in version 2.8.
-    As alternatives use include_tasks, import_plays, import_tasks.
+    As alternatives use include_tasks, import_playbook, import_tasks.
 description:
      - Includes a file with a list of plays or tasks to be executed in the current playbook.
      - Files with a list of plays can only be included at the top level, lists of tasks can only be included where tasks normally run (in play).
diff --git a/lib/ansible/modules/utilities/logic/import_plays.py b/lib/ansible/modules/utilities/logic/import_playbook.py
similarity index 93%
rename from lib/ansible/modules/utilities/logic/import_plays.py
rename to lib/ansible/modules/utilities/logic/import_playbook.py
--- a/lib/ansible/modules/utilities/logic/import_plays.py
+++ b/lib/ansible/modules/utilities/logic/import_playbook.py
@@ -16,7 +16,7 @@
 ---
 author:
     - "Ansible Core Team (@ansible)"
-module: import_plays
+module: import_playbook
 short_description: import a playbook.
 description:
      - Includes a file with a list of plays to be executed.
@@ -37,7 +37,7 @@
     - debug:
         msg: "play1"
 
-- import_plays: otherplays.yml
+- import_playbook: otherplays.yml
 
 
 - name: This DOES NOT WORK
@@ -47,7 +47,7 @@
         msg: task1
 
     - name: This failes because I'm inside a play already
-      import_plays: stuff.yml
+      import_playbook: stuff.yml
 """
 
 RETURN = """


Test patch: