Repository: ansible/ansible

Issue:
start-at-task does not work with tasks inside an include within a role
##### ISSUE TYPE
- Bug Report
##### ANSIBLE VERSION

```
ansible 2.0.2.0
  config file = /tmp/ansible-test/ansible.cfg
  configured module search path = Default w/o overrides
```
##### CONFIGURATION

[defaults]
roles_path = roles
##### OS / ENVIRONMENT

Ubuntu 15.10 and/or 14.04
##### SUMMARY

The switch `--start-at-task` for `ansible-playbook` does not work when specifying a task name that is inside a _task file_ included in a role.
##### STEPS TO REPRODUCE

Executing this:
`ansible-playbook -i localhost, -c local playbook.yml --start-at-task="debug extra 2"`

It fails regadless the connection is local or not.

Here are the example playbook and role.:

playbook.yml

```

---

- name: Test playbook
  hosts: all

  roles:
    - { role: myrole }
```

roles/myrole/tasks/main.yml

```

---

- name: debug 1
  debug: msg=1

- name: debug 2
  debug: msg=3

- name: debug 3
  debug: msg=3

- include: extra.yml
```

roles/myrole/tasks/extra.yml

```

---

- name: debug extra 1
  debug: msg="extra 1"

- name: debug extra 2
  debug: msg="extra 2"

- name: debug extra 3
  debug: msg="extra 4"
```
##### EXPECTED RESULTS

Ansible should start running tasks from the task specified

```
PLAY [Test playbook] ***********************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [myrole : include] ********************************************************
included: /tmp/ansible-test/roles/myrole/tasks/extra.yml for localhost

TASK [myrole : debug extra 2] **************************************************
ok: [localhost] => {
    "msg": "extra 2"
}

TASK [myrole : debug extra 3] **************************************************
ok: [localhost] => {
    "msg": "extra 4"
}

PLAY RECAP *********************************************************************
localhost                  : ok=4    changed=0    unreachable=0    failed=0   
```
##### ACTUAL RESULTS

No task is run at all.

```
$ ansible-playbook -i localhost, -c local playbook.yml --start-at-task="debug extra 2" -vvvv
Using /tmp/ansible-test/ansible.cfg as config file
Loaded callback default of type stdout, v2.0

PLAYBOOK: playbook.yml *********************************************************
1 plays in playbook.yml

PLAY [Test playbook] ***********************************************************

PLAY RECAP *********************************************************************
```



Discussion:
+1


Resolving patch:
diff --git a/lib/ansible/playbook/helpers.py b/lib/ansible/playbook/helpers.py
--- a/lib/ansible/playbook/helpers.py
+++ b/lib/ansible/playbook/helpers.py
@@ -118,7 +118,8 @@ def load_list_of_tasks(ds, play, block=None, role=None, task_include=None, use_h
                     is_static = t.static
                 else:
                     is_static = C.DEFAULT_TASK_INCLUDES_STATIC or \
-                                (use_handlers and C.DEFAULT_HANDLER_INCLUDES_STATIC)
+                                (use_handlers and C.DEFAULT_HANDLER_INCLUDES_STATIC) or \
+                                (not templar._contains_vars(t.args['_raw_params']) and not t.loop)
 
                 if is_static:
                     if t.loop is not None:


Test patch: