how to clear unnecessary minion cache

7,275 views
Skip to first unread message

Tao Fan

unread,
Aug 14, 2013, 8:06:14 PM8/14/13
to salt-...@googlegroups.com
Hi all,

I have been experimenting Salt and put a lot of stuff in master file_roots/. Now I have deleted most of them but found they are still in minion cache/salt/minion/files/base/. I would like to know if minion is able to sync with master file_root and automatically delete the files/directories that is not on master? I don't want to do this manually, especially when having a whole bunch of minions.

Thanks in advance.


Tao

Tao Fan

unread,
Aug 14, 2013, 9:34:26 PM8/14/13
to salt-...@googlegroups.com
Just like to add that the stuff I put and deleted in master file_roots/ were not just sls files, but also source dir/files as well.

Ethan Erchinger

unread,
Aug 15, 2013, 2:14:08 PM8/15/13
to salt-...@googlegroups.com
# salt '*' cmd.run 'rm -rm /var/cache/salt/minion/files/base/*'
# salt '*' saltutil.sync_all

Tao Fan

unread,
Aug 15, 2013, 7:20:05 PM8/15/13
to salt-...@googlegroups.com
Hi Ethan,

Thanks for the response. I want to remove only the unnecessary files while keeping the others, because my minions have limited resources (limited hard drive space and CPU/memory) and are deployed remotely on 3G connection (unstable link, expensive and limited bandwidth). Also it would be good for future when I have some files pushed out but realise unnecessary.

But if there is no such a smart way. Your commands are the best bet for me.


Thanks.
Tao

--
Tao Fan
Taggle Systems Pty Ltd
Suite 201, National Innovation Centre, Australian Technology Park
4 Cornwallis Street, Eveleigh, NSW 2015 Australia


--
You received this message because you are subscribed to a topic in the Google Groups "Salt-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/salt-users/dEg0w1tdKp0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to salt-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Erik Johnson

unread,
Aug 16, 2013, 9:52:14 PM8/16/13
to salt-...@googlegroups.com
This would require a runner or module execution function to be added. It's definitely doable. I opened an issue on the tracker: https://github.com/saltstack/salt/issues/6759


--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Erik Johnson | Engineer

5272 South College Drive, Suite 301 | Murray, UT 84123
er...@saltstack.com | http://saltstack.com

Ethan Erchinger

unread,
Aug 17, 2013, 1:21:21 PM8/17/13
to salt-...@googlegroups.com
Try something like this...works in my testing.

{% set base = '/var/cache/salt/minion/files/base' %}
{% set files = salt['cmd.run']('cd /var/cache/salt/minion/files/base; find * -type f') %}
{% set basefiles = salt['cp.list_master']() %}

{% for file in files.split() %}
  {% if file not in basefiles %}
{{ base }}/{{ file}}:
    file.absent
  {% endif %}
{% endfor %}

Tao Fan

unread,
Aug 18, 2013, 8:29:13 PM8/18/13
to salt-...@googlegroups.com
Hi Ethan,

I am not as far as this complexity yet in my experimenting of salt but I will definitely try this after I understand how pillar and jinja works.

It seems your snippet deals with files only (salt['cmd.run']('cd /var/cache/salt/minion/files/base; find * -type f'). It should not be too hard to modify it to deal with directories as well.


Thank for your reply,

Tao 

--
Tao Fan
Taggle Systems Pty Ltd
Suite 201, National Innovation Centre, Australian Technology Park
4 Cornwallis Street, Eveleigh, NSW 2015 Australia


Reply all
Reply to author
Forward
0 new messages