# Ansible 2.0.0.2 main.yml fails with "ERROR! no action detected in task"

**URL:** <https://forum.ansible.com/t/ansible-2-0-0-2-main-yml-fails-with-error-no-action-detected-in-task/20844>\
**Category:** Ansible Project\
**Created:** [March 11, 2016, 4:35pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-main-yml-fails-with-error-no-action-detected-in-task/20844 "2016-03-11T16:35:54Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Osielczak](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Daniel\_Osielczak](https://forum.ansible.com/u/Daniel_Osielczak)\
**Post date:** [March 11, 2016, 4:35pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-main-yml-fails-with-error-no-action-detected-in-task/20844/1 "2016-03-11T16:35:54Z")

</div>

Hi,

I’m setting up an Ansible 2 environemnt and stumbled upon a problem:

when I run main.yml (either as a separate playbook or using the main site.yml) I get an error “ERROR! no action detected in task”:

`

[root@install-test7 ansible]# ansible-playbook roles/dns/tasks/main.yml -vvv  
Using /etc/ansible/ansible.cfg as config file  
1 plays in roles/dns/tasks/main.yml

PLAY \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [setup] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
…  
ok: [www-test7]

TASK [include] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /etc/ansible/roles/dns/tasks/main.yml:4  
fatal: [www-test7]: FAILED! =\> {“failed”: true, “reason”: “ERROR! no action detected in task\n\nThe error appears to have been in ‘/etc/ansible/roles/dns/tasks/ensure\_resolv\_conf.yml’: line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n—\n- hosts: all\n ^ here\n”}

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
www-test7 : ok=1 changed=0 unreachable=0 failed=1

`

The playbook is pretty simple (have already tried different ways to write it, fail everytime):

`

[root@install-test7 ansible]# cat roles/dns/tasks/main.yml

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [March 11, 2016, 7:13pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-main-yml-fails-with-error-no-action-detected-in-task/20844/2 "2016-03-11T19:13:15Z")

</div>

Per that error you have an error in ensure\_resolv\_conf.yml:

The error appears to have been in ‘/etc/ansible/roles/dns/tasks/ensure\_resolv\_conf.yml’: line 2, column 3

You showed us you are doing an `include` on “ensure\_resolv\_conf.yml” but did not show us the contents of that file. We would need to see that file.

---

<div class="post-metadata">

**Author:** ![Daniel\_Osielczak](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Daniel\_Osielczak](https://forum.ansible.com/u/Daniel_Osielczak)\
**Post date:** [March 13, 2016, 10:50pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-main-yml-fails-with-error-no-action-detected-in-task/20844/3 "2016-03-13T22:50:53Z")

</div>

Hi Matt,

thanks for quick answer. As already mentioned, I don’t belive this to be a problem with this playbook, as it runs without any problems when called explicitly. I will attach it anyway, of course:

`

[root@install-test7 ~]# cat /etc/ansible/roles/dns/tasks/ensure\_resolv\_conf.yml

---

<div class="post-metadata">

**Author:** ![ecoutin\_boingo](https://avatars.discourse-cdn.com/v4/letter/e/ac91a4/32.png) [@ecoutin\_boingo](https://forum.ansible.com/u/ecoutin_boingo)\
**Post date:** [June 1, 2016, 3:59pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-main-yml-fails-with-error-no-action-detected-in-task/20844/4 "2016-06-01T15:59:02Z")

</div>

I’m having the exact same problem on 2.0.1. In my case I’m including a playbook from the main.yml file of a role. Is that what you’re doing?  
It doesn’t matter what you put in the hosts variable even if it is in jinja format it won’t work:  
Option 1:  
`  
main.yaml

- include:auxiliary\_playbook.yml  
vars:  
host\_ip: {some\_vm.ip}

auxiliary\_playbook.yml

hosts: {{host\_ip}}

Error:  
fatal: [localhost]: FAILED! =\> {“failed”: true, “reason”: “Syntax Error while loading YAML.\n\n\nThe error appears to have been in ‘/path\_to/auxiliary\_playbook.yml’: line 1, column 11, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- hosts: {{host\_ip}}\n ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes. Always quote template expression brackets when they\nstart a value. For instance:\n\n with\_items:\n - {{ foo }}\n\nShould be written as:\n\n with\_items:\n - "{{ foo }}"\n”}

`

Option 2:

`  
main.yaml

- include:auxiliary\_playbook.yml

auxiliary\_playbook.yml

hosts: tag\_Name\_my\_vm

Error:  
fatal: [localhost]: FAILED! =\> {“failed”: true, “reason”: “no action detected in task. This often indicates a misspelled module name, or incorrect module path.\n\nThe error appears to have been in ‘/path\_to/auxiliary\_playbook.yml’: line 1, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- hosts:\n ^ here\n”}

`

Both options work if they are run independently from the include.

---

<div class="post-metadata">

**Author:** ![ecoutin\_boingo](https://avatars.discourse-cdn.com/v4/letter/e/ac91a4/32.png) [@ecoutin\_boingo](https://forum.ansible.com/u/ecoutin_boingo)\
**Post date:** [June 1, 2016, 4:02pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-main-yml-fails-with-error-no-action-detected-in-task/20844/5 "2016-06-01T16:02:56Z")

</div>

Hey,

It looks like we need to patch ansible

[https://github.com/ansible/ansible/issues/15715](https://github.com/ansible/ansible/issues/15715)

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [June 1, 2016, 4:10pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-main-yml-fails-with-error-no-action-detected-in-task/20844/6 "2016-06-01T16:10:00Z")

</div>

This error only says you should quote correctly:

hosts: '{{ host\_ip }}'

Maybe it works if the variable is quoted.

Johannes

---

<div class="post-metadata">

**Author:** ![ecoutin\_boingo](https://avatars.discourse-cdn.com/v4/letter/e/ac91a4/32.png) [@ecoutin\_boingo](https://forum.ansible.com/u/ecoutin_boingo)\
**Post date:** [June 1, 2016, 4:14pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-main-yml-fails-with-error-no-action-detected-in-task/20844/7 "2016-06-01T16:14:18Z")

</div>

My bad, I tried to edit my original post and add the quotes, it doesn’t matter whether you include them or not. The problem is a combination of the include and hosts statements. The ansible github page says this is patched in 2.1, see my previous post.

---

<div class="post-metadata">

**Author:** ![Daniel\_Osielczak](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Daniel\_Osielczak](https://forum.ansible.com/u/Daniel_Osielczak)\
**Post date:** [June 1, 2016, 10:37pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-main-yml-fails-with-error-no-action-detected-in-task/20844/8 "2016-06-01T22:37:39Z")

</div>

Hi,

if I remember correctly, I was never able to fix the problem and ended up using a workaround. I will try to get the environment back online to see what it was exactly but I remember it wasn’t pretty.

BR,  
Daniel

W dniu środa, 1 czerwca 2016 17:14:18 UTC+1 użytkownik einarc napisał:

---

<div class="post-metadata">

**Author:** ![Daniel\_Osielczak](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Daniel\_Osielczak](https://forum.ansible.com/u/Daniel_Osielczak)\
**Post date:** [June 1, 2016, 10:43pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-main-yml-fails-with-error-no-action-detected-in-task/20844/9 "2016-06-01T22:43:37Z")

</div>

Found the bug report I filed back then. As you can see, this type of include is unsupported:

[https://github.com/ansible/ansible/issues/15119](https://github.com/ansible/ansible/issues/15119)

W dniu środa, 1 czerwca 2016 23:37:39 UTC+1 użytkownik Daniel Osielczak napisał:

---

<div class="post-metadata">

**Author:** ![ecoutin\_boingo](https://avatars.discourse-cdn.com/v4/letter/e/ac91a4/32.png) [@ecoutin\_boingo](https://forum.ansible.com/u/ecoutin_boingo)\
**Post date:** [June 1, 2016, 11:57pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-main-yml-fails-with-error-no-action-detected-in-task/20844/10 "2016-06-01T23:57:48Z")

</div>

Agreed,

Spent sometime banging my head just to get to version 2.1 using pip but that didn’t fix the issue. Trying other workarounds like these did not work either. What really bothers me is how CRYPTIC ansible error messages are. I would have to look at the Python code flow and debug it to realize what’s really going one. Not to mention the inconsistencies in documentation vs. examples and so on. It looks like I’m going to have to use a different flow then.

---

<div class="post-metadata">

**Author:** ![ecoutin\_boingo](https://avatars.discourse-cdn.com/v4/letter/e/ac91a4/32.png) [@ecoutin\_boingo](https://forum.ansible.com/u/ecoutin_boingo)\
**Post date:** [June 1, 2016, 11:59pm UTC](https://forum.ansible.com/t/ansible-2-0-0-2-main-yml-fails-with-error-no-action-detected-in-task/20844/11 "2016-06-01T23:59:55Z")

</div>

Thank You, BTW!

---

<div class="post-metadata">

**Author:** ![Daniel\_Osielczak](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Daniel\_Osielczak](https://forum.ansible.com/u/Daniel_Osielczak)\
**Post date:** [June 2, 2016, 8:43am UTC](https://forum.ansible.com/t/ansible-2-0-0-2-main-yml-fails-with-error-no-action-detected-in-task/20844/12 "2016-06-02T08:43:50Z")

</div>

Went trough exact the same process (debugging, looking for a consistent documentation and so on). I will try update you, on what solution did I used, later on

---

<div class="post-metadata">

**Author:** ![Saurabh\_Joshi](https://avatars.discourse-cdn.com/v4/letter/s/aca169/32.png) [@Saurabh\_Joshi](https://forum.ansible.com/u/Saurabh_Joshi)\
**Post date:** [August 9, 2016, 9:37am UTC](https://forum.ansible.com/t/ansible-2-0-0-2-main-yml-fails-with-error-no-action-detected-in-task/20844/13 "2016-08-09T09:37:49Z")

</div>

Hi Daniel,

Did you come across any solution to this issue?  
I am stuck with same situation where I have an

`

- name: Invoking administrator playbook.  
include: administrator.yml  
`

and administrator.yml has

`

- hosts: myHost  
roles:
- { role: my\_modules }  
tasks:
- name: “Gather facts.”  
`  
Using ansible 2.1.0.0.

Please share the workaround in case you have got one.

Thanks,  
Saurabh.

---

<div class="post-metadata">

**Author:** ![Daniel\_Osielczak](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Daniel\_Osielczak](https://forum.ansible.com/u/Daniel_Osielczak)\
**Post date:** [August 10, 2016, 6:35am UTC](https://forum.ansible.com/t/ansible-2-0-0-2-main-yml-fails-with-error-no-action-detected-in-task/20844/14 "2016-08-10T06:35:21Z")

</div>

Hi Saurabh,

I was told that this is not a bug, but a feature of Ansible 2.x

I ended up rewriting the whole thing.

Sorry I couldn’t help more.

Best regards,  
Dan

---

<div class="post-metadata">

**Author:** ![Saurabh\_Joshi](https://avatars.discourse-cdn.com/v4/letter/s/aca169/32.png) [@Saurabh\_Joshi](https://forum.ansible.com/u/Saurabh_Joshi)\
**Post date:** [August 10, 2016, 8:47am UTC](https://forum.ansible.com/t/ansible-2-0-0-2-main-yml-fails-with-error-no-action-detected-in-task/20844/15 "2016-08-10T08:47:27Z")

</div>

Hi Daniel,

I figured a workaround (it’s sort of ugly), thanks anyways.  
But just to let you know this email chain was mentioned in one of Ansible’s open defect - [ansible/issues/15715](https://github.com/ansible/ansible/issues/15715)

Thanks,  
Saurabh.
