Apply with_items on multiple tasks

后端 未结 2 488
醉话见心
醉话见心 2021-01-03 20:19

Is it possible to apply a list of items to multiple tasks in an Ansible playbook? To give an example:

- name: download and execute
  hosts: server1
  tasks:
         


        
2条回答
  •  情书的邮戳
    2021-01-03 20:46

    You have the possibility to define a yaml list in a variables file:

    ---
    myfiles:
    - "file1.sh"
    - "file2.sh"
    ...
    

    and then you can use

    with_items: "{{ myfiles }}"
    

    in the task.

提交回复
热议问题