include not working

39 views
Skip to first unread message

Tcpip

unread,
Apr 13, 2018, 8:42:06 PM4/13/18
to Ansible Project
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???

Biswadip Dutta

unread,
Apr 16, 2018, 8:15:18 AM4/16/18
to ansible...@googlegroups.com
Hi,
I believe you should use import_playbook to add a playbook in another playbook. See here.

Regards,
Biswadip Dutta

--
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+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/a6e77380-cf49-472d-932a-228b2def9fe6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tcpip

unread,
Apr 16, 2018, 7:46:02 PM4/16/18
to Ansible Project
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. 

Regards,
Biswadip Dutta

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.

Biswadip Dutta

unread,
Apr 17, 2018, 4:20:36 AM4/17/18
to ansible...@googlegroups.com
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.

Also, conditionally adding playbooks is a feature request as per this from what I can find.

Maybe you can restructure 2.yml a bit. Check here for reference.

Regards,
Biswadip Dutta

To unsubscribe from this group and stop receiving emails from it, 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/90ae3f16-7a07-4a89-9279-5af66071d019%40googlegroups.com.

Tcpip

unread,
Apr 17, 2018, 5:17:44 AM4/17/18
to Ansible Project
Hello,

Thanks for your help I will check the reference.  but the  strange thing is I did playbooks the same way for server and I only have issue with this modules.

thanks

Regards,
Biswadip Dutta

Reply all
Reply to author
Forward
0 new messages