我需要在多台机器上使用salt stack来安装python的paramiko模块。
我查看了有关如何执行此操作的文档,但无法理解语法。
有人可以请逐行解释我在下面的代码片段中发生了什么:
python-pip: pkg.installed virtualenvwrapper: pip.installed: - require: - pkg: python-pip
另外,你可以添加一个示例代码片段,通过pip使用salt来安装多个python模块吗?
python-pip: # The name of the package this state installs, this must be unique in your salt states pkg.installed # The state (pkg) and action (installed) virtualenvwrapper: # The name of the package pip.installed: # The state (pip) and action (installed) - require: # Require means only install this if the following is already installed - pkg: python-pip # pkg python-pip which is mentioned earlier
编写第一部分的另一种方法是:
instaled python pip: pkg.installed: - name: python-pip
如果你想安装多个包:
installed python pip, paramiko and complete: pkg.installed: - pkgs: - python-pip - python-complete - python-paramiko
另外,paramiko是在点子:
paramiko: pip.installed
另外,要从pip安装多个东西:
install lots from pip: pip.installed: - names: - paramiko - boto3 - pycurl
请记住, 文档是你的朋友,但它们并不是详尽无遗,在freenode irc上的#salt也是一个很好的地方。
第一个块是通过像yum或apt-get这样的发行版软件包pipe理器来安装软件包python-pip
第二块是通过pip安装virtualenvwrapper像pip install virtualenvwrapper但它也说为了运行该命令,你需要安装包python-pip