I understand the problem now. You are trying to include a playbook under
the tasks level which is not allowed. A file with only tasks are allowed to
be included under tasks. See here
<http://docs.ansible.com/ansible/2.3/playbooks_roles.html#task-include-files-and-encouraging-reuse>
.

Also, conditionally adding playbooks is a feature request as per this
<https://github.com/ansible/ansible/issues/34281> from what I can find.

Maybe you can restructure 2.yml a bit. Check here
<http://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html#conditional-imports>
for
reference.

Regards,
Biswadip Dutta

On Tue, Apr 17, 2018 at 5:16 AM, Tcpip <juraj.pa...@gmail.com> wrote:

> Hello,
>
> I test it but still the same issue, maybe is the wrong way, the idea is if
> the value es greater then run the other playbook.
>
> thanks.
>
> On Monday, April 16, 2018 at 9:15:18 AM UTC-3, Biswadip Dutta wrote:
>>
>> Hi,
>> I believe you should use import_playbook to add a playbook in another
>> playbook. See here
>> <https://docs.ansible.com/ansible/2.4/playbooks_reuse_includes.html>.
>>
>> Regards,
>> Biswadip Dutta
>>
>> On Sat, Apr 14, 2018 at 6:12 AM, Tcpip <juraj...@gmail.com> wrote:
>>
>>> Hi all
>>>
>>> I have the following playbook
>>>
>>> !
>>> ---
>>>
>>>
>>>
>>> - hosts: lab
>>>   gather_facts: true
>>>   connection: local
>>>   vars:
>>>     creds:
>>>       host: "{{ ansible_host }}"
>>>       username: cisco
>>>       password: cisco
>>>
>>>   tasks:
>>>     - name: ios_facts
>>>       ios_facts:
>>>          provider: "{{ creds }}"
>>>       register: iosfacts
>>>
>>>     - name: interface description
>>>       ios_config:
>>>         provider: "{{ creds }}"
>>>         lines:
>>>           - description test interface
>>>         parents: "interface {{ item.key }}"
>>>       with_dict: "{{ iosfacts.ansible_facts.ansible_net_interfaces }}"
>>>       when: item.value.bandwidth >= 1000000
>>>
>>>     - name: new task
>>>       include: 2.yml
>>>       with_dict: "{{ iosfacts.ansible_facts.ansible_net_interfaces }}"
>>>       when: item.value.bandwidth <= 1000000
>>>
>>> !!!!!!
>>> And I get this error
>>>
>>>     "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 '/home/playbooks/varios/2.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: lab\n  ^ here\n\n\nThe
>>> error appears to have been in '/home/playbooks/varios/2.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: lab\n  ^
>>> here\n"
>>>
>>> If I execute the playbook 2.yml in stand alone it works, if I add it to
>>> my other playbook i get errors.
>>>
>>> Any ideas???
>>>
>>> --
>>> 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/ms
>>> gid/ansible-project/a6e77380-cf49-472d-932a-228b2def9fe6%
>>> 40googlegroups.com
>>> <https://groups.google.com/d/msgid/ansible-project/a6e77380-cf49-472d-932a-228b2def9fe6%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> 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-project+unsubscr...@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/90ae3f16-7a07-4a89-9279-5af66071d019%40googlegroups.
> com
> <https://groups.google.com/d/msgid/ansible-project/90ae3f16-7a07-4a89-9279-5af66071d019%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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-project+unsubscr...@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/CAEC%3DuXkfRtzHdtnBy%2B1F%3DLgAY5cP2KGyyx%2BoK4ZWTUpzZUnrWw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to