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

Using iterations in states

The need to do the same task repeatedly for a number of entities of the same type is a very basic requirement of any role in an organization. To achieve this, languages and tools provide us with the feature of iterations, simply known as loops. In this recipe, you will learn how to apply iterations in our configuration.

How to do it...

  1. We will use the same minion as the previous recipe. Modify the user pillar, that is, edit /opt/salt-cookbook/pillar/staging/user/init.sls to have the following contents:
    dev_user_list:
      optimus:
        uid: 7001
        passwd: '$1$Dw1TxMI7$pmeYTdmz.rlunqPd7JELR.'
      bumblebee:
        uid: 7002
        passwd: '$1$ZHUeIAfq$6sJl9rHVDX2UjBH1KrPZP1'
      ironhide:
        uid: 7003
        passwd: '$1$rcJAiq7y$bJzv3HzVTbeQlA3cIu1Gb1'
  2. Edit /opt/salt-cookbook/staging/user/init.sls ...

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