Hey;

I copied what you have and am getting an error stating:

$ ansible-playbook prime_tasks.yaml --list-tasks
ERROR! 'include_tasks' is not a valid attribute for a Play

The entire playbook looks like:

---
- name: Main_play
  include_tasks: subtasks.yaml
  loop:
    - admins
    - ms1s
    - ms2s

With subtasks being just a straight debug:

---
- name: subtask1
  debug:
    msg: "running on {{inventory_hostname}}"

include_tasks was added in 2.4.4 and I'm running 2.7.7 so that should be 
good.  Looking at the docs for include_tasks, it looks like that has to be 
defined in the tasks section of the playbook.  The only way I was able to 
get this working is by changing it to:

---
- name: Main_play
  hosts: all

  tasks:
  - include_tasks: subtasks.yaml
    loop:
      - admins
      - ms1s
      - ms2s

but that kills the whole goal of what I'm trying to accomplish.  

$ ansible-playbook prime_tasks.yaml --list-tasks

playbook: prime_tasks.yaml

  play #1 (all): Main_play      TAGS: []
    tasks:
      include_tasks     TAGS: []


Did I misunderstand your reply?  

Thanks

Doug O'Leary

On Wednesday, March 6, 2019 at 12:15:22 PM UTC-6, Vladimir Botka wrote:
>
>
> On Wednesday, March 6, 2019 at 5:07:20 PM UTC+1, Doug OLeary wrote:
>>
>> [...]
>> I'd like to loop at the play level rather than the task level.
>>
>
>  To loop over a set of tasks put the tasks into a file *set-of-tasks.yml * 
> and use include_tasks
>
> - name: Loop tasks
>   include_tasks: set-of-tasks.yml
>    loop:
>     - admins
>     - ms1s
>          -  ms2s
>
>

-- 
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/931d67aa-9b31-4fd1-950a-9c2f4aa44944%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to