通过salt在/etc/zypp/zypp.conf中设置值

我想通过salt在/etc/zypp/zypp.conf中设置以下设置:

solver.allowVendorChange = true 

这个怎么做?

有一个zypper模块,但我没有办法更新上述设置:

https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.zypper.html

SaltStack中有通用的文​​件修改模块和状态。 例如,你可以使用file.replace :

 salt '*' file.replace /etc/zypp/zypp.conf pattern='solver.allowVendorChange = true' repl='solver.allowVendorChange = false' 

如果行根本不存在,则可以使用file.blockreplace将其附加到configuration中:

  file.blockreplace: - name: /etc/zypp/zypp.conf - marker_start: "#BLOCK TOP: Salt managed entry, do not edit!" - marker_end: "#BLOCK BOTTOM: End of Salt managed entry" - content: | solver.allowVendorChange = true - show_changes: True - append_if_not_found: True 

你应该可以使用file.sed来完成它:

 salt '*' file.sed /etc/zypp/zypp.conf '^(#|)\s*solver.allowVendorChange(.+)?$' 'solver.allowVendorChange = true'