在 SLS 'apt-upgrade' 中找到的状态 'pkg.upgrade' 不可用
State 'pkg.upgrade' found in SLS 'apt-upgrade' is unavailable
我正在尝试构建一个 SLS 文件,该文件将在 Ubuntu 系统上执行 apt-get upgrade
调用。我运行处于无主模式
直接从命令行调用它有效:
$ salt-call --local pkg.upgrade
[INFO ] Executing command 'apt-get -q update' in directory '/root'
[INFO ] Executing command "dpkg-query --showformat='${Status} ${Package} ${Version} ${Architecture}\n' -W" in directory '/root'
[INFO ] Executing command ['apt-get', '-q', '-y', '-o', 'DPkg::Options::=--force-confold', '-o', 'DPkg::Options::=--force-confdef', 'dist-upgrade'] in directory '/root'
[INFO ] Executing command "dpkg-query --showformat='${Status} ${Package} ${Version} ${Architecture}\n' -W" in directory '/root'
但是,从 SLS 文件(YAML 格式)发出的相同调用不起作用:
# top.sls
base:
'*':
- apt-upgrade
# apt-upgrade.sls
apt-upgrade:
pkg:
- upgrade
$ salt-call --local state.highstate
# ...
ID: apt-upgrade
Function: pkg.upgrade
Result: False
Comment: State 'pkg.upgrade' found in SLS 'apt-upgrade' is unavailable
Started:
Duration:
Changes:
你遇到的问题是你没有理解execution modules and state modules之间的区别。
pkg.upgrade 存在于 salt.modules.aptpkg execution module. Thus you can call it from the salt-call
command. To use it from a state file however, you'll have to use the module.run 状态。
或者更好的是,您可以查看是否在 salt.states.pkg 中找到了有用的东西并改用它。
我正在尝试构建一个 SLS 文件,该文件将在 Ubuntu 系统上执行 apt-get upgrade
调用。我运行处于无主模式
直接从命令行调用它有效:
$ salt-call --local pkg.upgrade
[INFO ] Executing command 'apt-get -q update' in directory '/root'
[INFO ] Executing command "dpkg-query --showformat='${Status} ${Package} ${Version} ${Architecture}\n' -W" in directory '/root'
[INFO ] Executing command ['apt-get', '-q', '-y', '-o', 'DPkg::Options::=--force-confold', '-o', 'DPkg::Options::=--force-confdef', 'dist-upgrade'] in directory '/root'
[INFO ] Executing command "dpkg-query --showformat='${Status} ${Package} ${Version} ${Architecture}\n' -W" in directory '/root'
但是,从 SLS 文件(YAML 格式)发出的相同调用不起作用:
# top.sls
base:
'*':
- apt-upgrade
# apt-upgrade.sls
apt-upgrade:
pkg:
- upgrade
$ salt-call --local state.highstate
# ...
ID: apt-upgrade
Function: pkg.upgrade
Result: False
Comment: State 'pkg.upgrade' found in SLS 'apt-upgrade' is unavailable
Started:
Duration:
Changes:
你遇到的问题是你没有理解execution modules and state modules之间的区别。
pkg.upgrade 存在于 salt.modules.aptpkg execution module. Thus you can call it from the salt-call
command. To use it from a state file however, you'll have to use the module.run 状态。
或者更好的是,您可以查看是否在 salt.states.pkg 中找到了有用的东西并改用它。