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

Setting and using variables in states

Variables are one of the most important features of any language or tool used to set user-defined data and manipulate it as and when required. In this recipe, you will learn how to set variables in Salt states and use the variables to do some advanced task.

How to do it...

  1. Configure a minion in the staging environment and create a pillar and state with the name user. In the minion, configure the following grain:
    server_type: db
  2. Edit the /opt/salt-cookbook/pillar/staging/user/init.sls file to have the following contents:
    app_user_list: optimus: uid: 7001 passwd: $1$Cf1V2QaF$.qyeAQ34CLqyvEnes7/VH1 bumblebee: uid: 7002 passwd: $1$KvbpASt.$L97XRqLVc0OaspatEE/n4/ db_user_list: megatron: uid: 7001 passwd: $1$8J9bAeG6$HMMV.EoMycJyLL.pb6kHj0 ...

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