如何使用安装了Salt pkg的模块安装本地rpm

时间:2019-02-13 15:09:47

标签: yum salt

我们有一些.rpm应用程序想要安装在CentOS 6和7机器上。机器无法访问互联网。我们如何编写一种状态来确保已安装该应用程序?这是我的代码:

Install Nessus Agent:
  pkg.installed:
    - name: NessusAgent
    - sources: '[{"NessusAgent": "salt:///root/NessusAgent-7.1.1-es{{ osmajorrelease }}.x86_64.rpm"}]'

运行状态时出现错误:

     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/site-packages/salt/state.py", line 1913, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1898, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python2.7/site-packages/salt/states/pkg.py", line 1617, in installed
                  if next(iter(list(x.keys()))) in targets]
              AttributeError: 'unicode' object has no attribute 'keys'

安装具有Salt状态的本地rpm软件包的正确方法是什么?

1 个答案:

答案 0 :(得分:0)

我通过重写“ sources”参数使其起作用:

Install Nessus Agent:
  pkg.installed:
    - name: NessusAgent
    - enable: True
    - sources:
      - NessusAgent: salt:///files/nessus/NessusAgent-7.1.1-es7.x86_64.rpm