Last active
March 7, 2018 15:59
-
-
Save Rabattkarte/3723c00aef94400cf44fa95a2836748f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd /tmp/testdir/sites-enabled/ | |
$ touch 12098 dlij 0921 dpo 210983uj1m foo bar abc def | |
$ ls | |
0921 12098 210983uj1m abc bar def dlij dpo foo | |
$ salt-call state.apply remove_files_in_dir_except_list | |
local: | |
---------- | |
ID: file | |
Function: 0./tmp/testdir/sites-enabled/ | |
Name: remove files in dir | |
Result: True | |
Comment: Files cleaned from directory /tmp/testdir/sites-enabled | |
Started: 16:57:14.746713 | |
Duration: 5.838 ms | |
Changes: | |
---------- | |
removed: | |
- /tmp/testdir/sites-enabled/bar | |
- /tmp/testdir/sites-enabled/dlij | |
- /tmp/testdir/sites-enabled/210983uj1m | |
- /tmp/testdir/sites-enabled/12098 | |
- /tmp/testdir/sites-enabled/foo | |
- /tmp/testdir/sites-enabled/dpo | |
- /tmp/testdir/sites-enabled/0921 | |
Summary for local | |
------------ | |
Succeeded: 1 (changed=1) | |
Failed: 0 | |
------------ | |
Total states run: 1 | |
Total run time: 5.838 ms | |
$ ls | |
abc def |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
settings: | |
nginx: | |
sites: | |
- abc | |
- def |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% set wanted_sites = salt['pillar'].get('settings:nginx:sites') %} | |
remove files in dir: | |
file.directory: | |
- name: /tmp/testdir/sites-enabled/ | |
- clean: True | |
{% if wanted_sites is not none %} | |
- exclude_pat: E@({{ wanted_sites|join(')|(') }}) | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment