#1401
[Ansible] Loop
Loop with index & length to debug variables :
- name: "Debug" debug: msg="[{{item.0 +1}}/{{var_2_debug | length}}] {{item.1}} is {{ vars[item.1] | default('undefined') }}" with_indexed_items: "{{var_2_debug}}"
with :
var_2_debug: - "var_1" - "var_2" - "var_3"
{{item.0}} is the index of the item
{{item.1}} is the value of the item
vars[item.1] is an “eval” version of the item
Loop over files :
var_files_2_load: - "file1.yml" - "file2.yml" - name: "Load variables from files" include_vars: "{{item}}" with_items: "{{var_files_2_load}}"
Amazon Echo sur un Raspberry Pi, avec le mot clé de votre choix How To Install Linux, nginx, MySQL, PHP (LEMP) stack on CentOS 6
https://docs.ansible.com/ansible/playbooks_loops.html
with ;
Loop “for” basic
from 1 to 5
from 0 to 5