Skip to content

Instantly share code, notes, and snippets.

@adamchainz
Created May 26, 2021 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamchainz/cb9bfc51160e30d803b08a7dbee9dbec to your computer and use it in GitHub Desktop.
Save adamchainz/cb9bfc51160e30d803b08a7dbee9dbec to your computer and use it in GitHub Desktop.
ansible loop with persistence of result from last
- debug:
msg: '{{ last|default("") }} -> {{ item }}'
- set_fact:
last: '{{ item }}'
- hosts: localhost
connection: local
gather_facts: no
vars:
mylist:
- a
- b
- c
tasks:
- include_tasks: inner.yml
loop: '{{ mylist }}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment