我正在尝试在配置机器时从Github中提取特定的软件包并与Salt(无主机配置)一起安装。到目前为止,我已经做到了这样:
{% set pkg = {
'Ubuntu': 'https://github.com/some-package/releases/download/v1/some-package-v1-unknown-linux-gnu.deb',
}.get(grains.os) %}
curl -O -L {{ pkg }}:
cmd.run
dpkg -i some-pakage-v1-unknown-linux-gnu.deb:
cmd.run
现在,Salt确实有一个模块可以执行此操作,它称为pkgbuild.built。我尝试使用它,但没有成功。这是我目前所说的:
some-pakage-v1:
pkgbuild.built:
- runas: root
- results:
- some-package-v1-unknown-linux-gnu.deb
- dest_dir: /tmp/pkg
- spec: salt://pkg/salt/spec/some-package.spec
- tgt: ubuntu-18.04.1-x86_64
- sources:
- {{ pkg }}
我收到此错误:
ID: some-pakage-v1
Function: pkgbuild.built
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1913, in call
**cdata['kwargs'])
File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1898, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/states/pkgbuild.py", line 207, in built
ret['changes'] = __salt__[func](
File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1155, in __getitem__
func = super(LazyLoader, self).__getitem__(item)
File "/usr/lib/python2.7/dist-packages/salt/utils/lazy.py", line 104, in __getitem__
raise KeyError(key)
KeyError: 'pkgbuild.build'
Started: 18:29:57.051892
Duration: 9.644 ms
Changes:
答案 0 :(得分:1)
可能是您在缩进中弄错了吗?
根据文档,我希望这样:
some-pakage-v1:
pkgbuild.built:
- runas: root
- results:
- some-package-v1-unknown-linux-gnu.deb
- dest_dir: /tmp/pkg
- spec: salt://pkg/salt/spec/some-package.spec
- tgt: ubuntu-18.04.1-x86_64
- sources:
- {{ pkg }}
结果后的行必须缩进
如果仍然要安装.deb文件,为什么不安装pkg.installed规则?
some-package-v1:
pkg.installed:
- sources:
- some-package-v1: https://github.com/some-package/releases/download/v1/some-package-v1-unknown-linux-gnu.deb