O'Reilly logo

Salt Cookbook by Anirban Saha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Running commands

In this recipe, you will learn how to run simple shell commands on minions at the same time as fulfilling various conditions, making sure that the requirements are met, and creating dependencies between definitions based on the output of commands.

How to do it...

  1. Configure a Salt minion in the staging environment, and call it salt-minion. Create a new state in the staging environment called ruby by creating a directory called ruby in the base directory of the staging environment. Create the /opt/salt-cookbook/staging/ruby/init.sls file and edit it to have the following contents:
    install_rvm_key:
      cmd.run:
        - name: "gpg2 --keyserver hkp://keys.gnupg.net --recv- keys D39DC0E3"
        - shell: /bin/bash
     - unless: "stat /root/.gnupg/trustdb.gpg ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required