使用 Salt-Stack 成功安装 Artifactory RPM

Successfully Install Artifactory RPM using Salt-Stack

我正在致力于使用 Salt Stack 完全自动化一些事情。我目前正在通过 Salt Stack 使用 RPM 安装 Artifactory v5.3.2。我能够安装它并正常工作,但开始从 salt 堆栈中收到误报错误。

目前 运行 CentOS Linux release 7.3.1611 (Core) 使用来自 here. According to Artifactory documentation; they recommend using yum to install the rpm package. Installing Artifactory OSS from an RPM disribution 的无主盐栈(仅用于测试目的)。

我知道有两个用于类似用例的盐公式,但是,这些对于我们的需求来说过于复杂了。我试图 post 他们的两个网址,但没有足够的 saltstack 声誉来允许我这样做。

下载 rpm 并将其放入正确的目录后.. 在第一次尝试安装时使用此 salt 堆栈配置无法正常工作:

jfrog-artifactory-oss.noarch:
  pkg.installed:
    - source: salt://path/conf/jfrog-artifactory-oss-5.3.2.rpm

返回如下错误消息:

ID: jfrog-artifactory-oss.noarch
Function: pkg.installed
  Result: False
 Comment: Error occurred installing package(s). Additional info follows:`

         errors:
              - Running scope as unit run-2994.scope.
                Loaded plugins: fastestmirror
                Loading mirror speeds from cached hostfile
                 * base: mirror.steadfast.net
                 * epel: mirror.steadfast.net
                 * extras: repo.us.bigstepcloud.com
                 * updates: mirrors.lga7.us.voxel.net
                No package jfrog-artifactory-oss available.
                Error: Nothing to do
 Started: 15:51:12.374898
Duration: 11271.36 ms
 Changes:

将此配置用于盐:

jfrog-artifactory-oss.noarch:
  cmd.run:
    - name: yum install -y /srv/salt/prod/path/conf/jfrog-artifactory-oss-5.3.2.rpm

第一次有效,但第二次 运行 它使用这种格式 returns 出现如下错误:

          stderr:
              Error: Nothing to do
          stdout:
              Loaded plugins: fastestmirror
              Examining /srv/salt/prod/path/conf/jfrog-artifactory-oss-5.3.2.rpm: jfrog-artifactory-oss-5.3.2-50047.noarch
              /srv/salt/prod/path/conf/jfrog-artifactory-oss-5.3.2.rpm: does not update installed package.

现在,不要让事情变得混乱.. 如果我安装了 artifactory,然后我恢复到使用 pkg.installed 方法安装它的第一种方法,事情会按预期工作,返回一条成功消息说'所有指定的软件包都已安装'。

通常,此误报是由于未在盐状态文件中使用正确的包名称引起的,因此 运行 yum list installed returns jfrog-artifactory-oss.noarch 确保我正在使用盐状态下的正确命名。

无论是否更新包,我都希望能成功完成这项工作;无需使用提供的盐配方使我们的设置过于复杂。

任何 help/advice 将不胜感激。

Artifactory RPM 可以使用 yum 存储库和直接 rpm 安装。就我个人而言,我建议使用 yum 方式,因为它使以后的更新更容易。

回答您关于使用 masterless 设置的问题 - 这两个选项在 masterless 以及 master-minion 设置中都可以正常使用。

还有一个旁注。默认情况下 pkg.installed 将尝试使用 OS 原生的包管理器(yum/rpm 在 RedHat/CentOS 的情况下)。在大多数情况下,安装包时你应该使用它而不是直接调用 yumrpm

使用 yum

我们应该做的第一件事是获取有关 yum 存储库的 .repo 文件存储信息。不幸的是,documentation points to the repository with pro version of Artifactory. As we are interested in OSS - we should use a different one

中提到的那个

要设置它,我们将首先使用以下内容制作 .repo 文件:

[bintray--jfrog-artifactory-rpms]
name=bintray--jfrog-artifactory-rpms
baseurl=http://jfrog.bintray.com/artifactory-rpms
gpgcheck=0
repo_gpgcheck=0
enabled=1

现在我们应该使用盐来配置 yum 以使用这个 .repo 文件并从这个存储库安装 Artifactory。假设 yum 配置文件位于 files/jfrog-artifactory.repo 下的 salt 树中,Salt 配置将如下所示:

/etc/yum.repos.d/artifactory.repo:
  file.managed:
    - source: salt://files/jfrog-artifactory.repo

jfrog-artifactory-oss:
  pkg.installed:
     - require:
       - file: /etc/yum.repos.d/artifactory.repo
     - fromrepo: bintray--jfrog-artifactory-rpms

-fromrepo 选项将确保使用特定的 yum 存储库安装软件包,以防其他人可用。

使用 RPM

也可以将 Artifactory RPM 直接下载到您的 Salt 配置并从那里安装。为此,我使用了以下 RPM 文件:https://bintray.com/jfrog/artifactory-rpms/download_file?file_path=jfrog-artifactory-oss-5.3.2.rpm。假设文件下载到您的 Salt 树的 files/jfrog-artifactory-oss-5.3.2.rpm 中,安装此包的状态将如下所示:

jfrog-package:
  pkg.installed:
    - sources:
      - jfrog-artifactory-oss: salt://files/jfrog-artifactory-oss-5.3.2.rpm

请注意,-sources 部分是键值对列表,其中键是包的名称,值是 RPM 文件的路径。顶级jfrog-package只是一个标签