salt-projectaerospike

How to check that package is not present on server in SaltStack state file?


I am trying to automate an Aerospike database installation using saltstack version 2015.5.2 on an Ubuntu machine.

The following is the process of manual installation that I want to automate. (I'll only mention the key steps to keep it simple)

  1. Download Aerospike

    wget -O aerospike.tgz http://aerospike.com/download/server/latest/artifact/ubuntu12

  2. extract the contents of the package

    tar -xvf aerospike.tgz

  3. Install Aerospike Server & Tools

    cd aerospike-server-community-3.5.15-ubuntu12.04 ./asinstall

  4. Start Aerospike

    /etc/init.d/aerospike start

Step 3 performs the actual installation which includes installation of 2 packages: aerospike-server-community and aerospike-tools.

Now in the saltstack state file I want to check if both the packages are already present on server, and in that case do not execute the ./asinstall command in step 3.

How can I involve that condition in my automated process?


Solution

  • I recommend you read requisites in salt before going on because you can find many interesting things there.

    Furthermore,what you really need, in my opinion is: UNLESS, because if you already have these packages on your system they should not be installed. Unless can be used together with the pkg keyword, but for you the rpm -q package_name might work just as well.

    It should look something like this:

    start_process:
      cmd.run:
        - name: 'write here your command'
        - unless:
          - rpm -q package1 package2