Using Python functions in conditionals

Being based on Python, one of the biggest advantages of Salt is to be able to use a lot of Salt-specific features such as functions. In this recipe, you will learn how to use Python functions in Salt to manipulate data and make efficient use of them to configure our infrastructure.

How to do it...

  1. Configure two minions, one named stgdc1app01 and another named stgdc2app01.
  2. Run the following commands to get the grains with which we will be working in this recipe:
    [root@salt-master ~]# salt 'stgdc1app01' grains.item \ ip_interfaces hwaddr_interfaces
    stgdc1app01:
      hwaddr_interfaces: {'lo': '00:00:00:00:00:00', 'eth0': '00:0c:29:ef:d5:56', 'eth1': '00:0c:29:ef:d5:4c'}
     ip_interfaces: {'lo': ['127.0.0.1'], 'eth0': ...

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.