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...
- Configure two minions, one named
stgdc1app01
and another namedstgdc2app01
. - 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': ['192.168.0.2'], 'eth1': ['192.168.29.128']} [root@salt-master ~]# salt 'stgdc2app01' grains.item \ ip_interfaces...