I'm a newbie to saltstack, want to find the public hostname of an instance and assign it to a variable and need that hostname in a conf file.
sudo salt minion-name cmd.run 'curl http://169.25.19.24/latest/meta-data/public-hostname'
above cmd provides me public hostname, want to replicate this in state.sls file.
The below cmd works but unable to specify a minion, maybe I'm doing some syntax issue, not sure.
{% set hostname = salt['cmd.run']('curl -s http://169.25.19.24/latest/meta-data/public-hostname') %}
Kindly let me know a way or am I in the wrong path.
Salt states are executed from the minion. So whatever minion you apply this to, that's the minion it will run on.