在Salt Stack中,是否可以通过内存大小过滤minion,但指示内存大小必须大于或小于,而不是等于?因此,不是这样:
salt -C 'G@mem_total:993' test.ping我需要这样的东西:
salt -C 'G@mem_total > 993' test.ping发布于 2016-10-12 21:59:47
我担心您无法按原样使用targeting feature。
我想到的第一件事就是写一个custom grain。
如果您只在一个位置需要它,并且该值不经常更改,这可能是一种解决方法:
未经测试的示例
#!/usr/bin/env python
from psutil import virtual_memory
def categorize_memory():
grains = {}
mem = virtual_memory()
total_mem = mem.total
if total_mem < 1024 * 999:
grains['memory_category'] = 'low_mem_minion'
else:
grains['memory_category'] = 'high_mem_minion'
return grains然后像使用salt -C 'G@memory_category:high_mem_minion' test.ping一样使用它
从python中解析内存的代码取自Get total physical memory in Python
https://stackoverflow.com/questions/39996530
复制相似问题