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 ...

Get Salt Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.