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 [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):
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:
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
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.
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.
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ł:
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.
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
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