Skip to content

Instantly share code, notes, and snippets.

@jgornick
Created May 19, 2015 12:49
Show Gist options
  • Save jgornick/fcee337c2806b91b94d9 to your computer and use it in GitHub Desktop.
Save jgornick/fcee337c2806b91b94d9 to your computer and use it in GitHub Desktop.

Revisions

  1. jgornick created this gist May 19, 2015.
    13 changes: 13 additions & 0 deletions ansible.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    ---
    - name: Capture files in path and register
    shell: >
    ls -1 /path/to/files
    register: files

    - name: Remove files except specified
    file:
    path: "/path/to/files/{{ item }}"
    state: absent
    with_items: files.stdout_lines
    when: >
    item not in list_of_files_to_keep