简体   繁体   English

使用Python的Minion状态的SaltStack差异

[英]SaltStack diff of minion state using Python

I am writing custom wrapper for SaltStack in python, I couldn't figure from the Salt documentation any way that I can get the diff of state of a minion. 我正在用Python为SaltStack编写自定义包装器,我无法从Salt文档中找到可以获取奴才状态差异的任何方式。

What I mean is when we run the state from CLI, it shows the diff in different colors and I am trying to show only the difference, not the whole. 我的意思是,当我们从CLI运行状态时,它以不同的颜色显示差异,而我试图仅显示差异而不是整体。

CLI command: CLI命令:

salt '*' state.highstate test=True

I figured from CLI it is possible using --state-verbose=False , is there any way to use the same flag with Python? 我从CLI --state-verbose=False可以使用--state-verbose=False ,是否可以将相同的标志用于Python?

Are you looking for the history of changes and want to store them in a database? 您是否正在寻找更改历史记录并将其存储在数据库中?

The matching page is this: https://docs.saltstack.com/en/latest/topics/jobs/job_cache.html 匹配的页面是这样的: https : //docs.saltstack.com/en/latest/topics/jobs/job_cache.html

The Salt Master maintains a job cache of all job executions which can be queried via the jobs runner. Salt Master维护所有作业执行的作业缓存,可以通过作业运行程序查询该作业。 This job cache is called the Default Job Cache. 该作业缓存称为默认作业缓存。

AFAIK there is no easy way to get a nice GUI which shows you the changes which are done during the last time. AFAIK没有简单的方法来获得一个不错的GUI,该GUI可以向您显示上次所做的更改。

Using the python client, you can just add "test=true" as a kwarg to your localclient.cmd(). 使用python客户端,您只需将“ test = true”作为kwarg添加到localclient.cmd()中。

https://docs.saltstack.com/en/2015.8/ref/clients/index.html#salt-s-client-interfaces https://docs.saltstack.com/zh-CN/2015.8/ref/clients/index.html#salt-s-client-interfaces

Does that solve the issue? 这样可以解决问题吗? If you need an example, I'll add one as soon as I get to my laptop. 如果您需要一个示例,我将在笔记本电脑上尽快添加一个示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM