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

3,726 views
Skip to first unread message

Daniel Osielczak

unread,
Mar 11, 2016, 11:38:05 AM3/11/16
to Ansible Project
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
---
- hosts: all
  tasks:
    - include: ensure_resolv_conf.yml tags=resolv_conf
    - include: ensure_hosts.yml tags=etc_hosts


The interesting part is, all of the playbooks included work perfectly when run individually.

Is there something I'm missing in the documentation or is Ansible 2 acctually still unstable at the moment?

Best regards,
Daniel

Matt Martz

unread,
Mar 11, 2016, 2:22:08 PM3/11/16
to ansible...@googlegroups.com
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.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/27d12b29-6084-4954-b065-808abe74c81a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net

Daniel Osielczak

unread,
Mar 13, 2016, 6:50:53 PM3/13/16
to Ansible Project
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
---
- hosts: all
  tasks:

  - name: ensure resolve.conf contents
    copy: src=resolv.conf dest=/etc/resolv.conf owner=root group=root mode=0644


I believe there is something particular about how the include statement works. Maybe I need to add a dummy task to the main.yml?

Best regards,
Daniel

einarc

unread,
Jun 1, 2016, 11:59:02 AM6/1/16
to Ansible Project
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.

einarc

unread,
Jun 1, 2016, 12:02:56 PM6/1/16
to Ansible Project
Hey,

It looks like we need to patch ansible



On Sunday, March 13, 2016 at 3:50:53 PM UTC-7, Daniel Osielczak wrote:

Johannes Kastl

unread,
Jun 1, 2016, 12:10:08 PM6/1/16
to ansible...@googlegroups.com
On 01.06.16 17:59 einarc wrote:

> 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"}

This error only says you should quote correctly:

hosts: '{{ host_ip }}'

Maybe it works if the variable is quoted.

Johannes

signature.asc

einarc

unread,
Jun 1, 2016, 12:14:18 PM6/1/16
to Ansible Project
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.

Daniel Osielczak

unread,
Jun 1, 2016, 6:37:39 PM6/1/16
to Ansible Project
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

Daniel Osielczak

unread,
Jun 1, 2016, 6:43:37 PM6/1/16
to Ansible Project
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

einarc

unread,
Jun 1, 2016, 7:57:48 PM6/1/16
to Ansible Project
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.

einarc

unread,
Jun 1, 2016, 7:59:56 PM6/1/16
to Ansible Project
Thank You, BTW!

Daniel Osielczak

unread,
Jun 2, 2016, 4:43:57 AM6/2/16
to ansible...@googlegroups.com
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

Daniel Osielczak

PGP Key:            4096R/3EC320D0
Fingerprint:      4268 54CD 50FF 5465 DFC3  EA59 4350 D3BC 3EC3 20D0

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/BjycVAVlUpI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.

To post to this group, send email to ansible...@googlegroups.com.

Saurabh Joshi

unread,
Aug 9, 2016, 11:28:52 AM8/9/16
to Ansible Project
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.

Daniel Osielczak

unread,
Aug 10, 2016, 2:35:30 AM8/10/16
to ansible...@googlegroups.com
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

Daniel Osielczak

PGP Key:            4096R/3EC320D0
Fingerprint:      4268 54CD 50FF 5465 DFC3  EA59 4350 D3BC 3EC3 20D0

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/BjycVAVlUpI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/bcfcd28e-3fa4-4355-a666-4bb263944d4c%40googlegroups.com.

Saurabh Joshi

unread,
Aug 10, 2016, 4:47:27 AM8/10/16
to Ansible Project
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

Thanks,
Saurabh.

On Friday, 11 March 2016 22:08:05 UTC+5:30, Daniel Osielczak wrote:
Reply all
Reply to author
Forward
0 new messages