Issue
Recently I was working on project where I needed to get the default active ethernet interface using SaltStack. Finding the default interface is quite important when it comes to configuring networks or applications.
I wanted something similar to route | grep 'default' | awk '{print $8}'
which returns the name of the default interface. Of course I want the same result but using saltstack so I can use the returned value to configure some files. In my case It I needed to configure listener interface on applications.
Solution
The solution was very simple and clean using salt. This is what I run
The command above is equivalent to
To utilize the command on your sls files you can save the output of the command into a variable.
Comments