How to deploy custom rpms on to salt-minion?

557 views Asked by At

I'm working on salt-stack for setting up multiple machines, I wanted to ask how can we deploy rpms(placed at a custom location in master) on to the minions? I already have an idea of how can we install packages using top.sls file and name of the package that needs to be installed on minions but what I'm looking for is to deploy my custom rpms on to the minions from master.

1

There are 1 answers

4
seshadri_c On

There are two ways to approach this:

Option 1:

Define the list of RPMs in a pillar file:

package_names:
  - custom-rpm1: custom-rpm1-2.6.1-2.el7.x86_64.rpm
  - custom-rpm2: custom-rpm2-release-el7-3.noarch.rpm
  - custom-rpm3: custom-rpm3-latest.noarch.rpm

Then in an SLS file:

install-rpm:
  pkg.installed:
  - sources: {{ pillar['package_names'] }}

Option 2:

Copy the directory containing the RPMs (salt://rpms in below example is relative to file_roots) to target machine and use rpm command to install (with wildcard):

copy-rpms-dir:
  file.recurse:
    - name: /tmp/rpms
    - source: salt://rpms

install-rpms:
  cmd.run:
    - name: rpm -ivh /tmp/rpms/*.rpm
    - success_retcodes:
      - 2

Installing with rpm command requires extra check for return codes as it returns non-zero (2) when RPM is already installed.