ansible - delete unmanaged files from directory?

前端 未结 7 1937
情深已故
情深已故 2021-01-30 06:38

I want to recursively copy over a directory and render all .j2 files in there as templates. For this I am currently using the following lines:

7条回答
  •  日久生厌
    2021-01-30 07:23

    I'd do it like this, assuming a variable defined as 'managed_files' up top that is a list.

    - shell: ls -1 /some/dir
      register: contents
    
    - file: path=/some/dir/{{ item }} state=absent
      with_items: contents.stdout_lines
      when: item not in managed_files
    

提交回复
热议问题