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.
On Sunday, March 13, 2016 at 3:50:53 PM UTC-7, Daniel Osielczak wrote:
>
> 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
>
> W dniu piątek, 11 marca 2016 20:22:08 UTC+1 użytkownik Matt Martz napisał:
>>
>> 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.
>>
>> On Fri, Mar 11, 2016 at 10:35 AM, Daniel Osielczak <[email protected]>
>> wrote:
>>
>>> 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
>>>
>>> --
>>> 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 [email protected].
>>> To post to this group, send email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/27d12b29-6084-4954-b065-808abe74c81a%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/ansible-project/27d12b29-6084-4954-b065-808abe74c81a%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Matt Martz
>> @sivel
>> sivel.net
>>
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/663492f4-ee0f-4048-89a6-c7bcbe5af7f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.