Skip to content

Instantly share code, notes, and snippets.

@adamchainz
Created May 26, 2021 19:54
Show Gist options
  • Save adamchainz/6e004731b5cbea0337e673d4d45c81bf to your computer and use it in GitHub Desktop.
Save adamchainz/6e004731b5cbea0337e673d4d45c81bf to your computer and use it in GitHub Desktop.
ansible example getting item from previous iteration of loop
- hosts: localhost
connection: local
gather_facts: no
vars:
mylist:
- a
- b
- c
tasks:
- debug:
msg: '{{ ansible_loop.previtem|default("") }}{{ item }}'
loop: '{{ mylist }}'
loop_control:
extended: yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment