0

I'm starting up with Salt, which is a really great tool. I've been using it to provision Linode VMs. I can create a VM no problem, and get a private ip by setting: private_ip to True.

However I was wondering if there was a way to capture the (Linode) assigned private ip in a grain so I can then access it in a jinja template. Or if there is some other way to get hold of this information?

Many thanks in advance Bobby

bobbyr
  • 226
  • 1
  • 9

1 Answers1

0

I've not checked it on Linode environment, however I'm almost confident it's part of standard grains structure, e.g.

$salt-call grains.get 'ip_interfaces:eth0'
local:
    - 10.0.0.200

I think it's public_ips you would get issues with, since it would require cloud-vendor api calls to obtain public IP address.

leonardinius
  • 142
  • 1
  • 8
  • Hi, thanks, but when i provision a node, and immediately afterwards get the eth0 value, i get the public_ip value. What i'm trying to do is setup the private networking as part of the initial creation of the vm. It's easy enough to manually add the value to a pillar file before running my various setup formulas, but it would nice to automate the whole process – bobbyr Aug 12 '14 at 16:31
  • I'm afraid I don't understand your requirement/what you are trying to achieve here. I'm assuming - you invoke the same `salt-call grains.get 'ip_interfaces:eth0'` after initial rollout and get some IP address, which you would like to remember for later use. Then you install/enable private networking and `eth0` address changes afterwards. Am I correct so far? If so, you might remember the original IP address as follows, e.g. from shell `a=$(salt-call grains.get 'ip_interfaces:eth0' --out key | tail -n1); salt-call grains.setval original_ip $a` – leonardinius Aug 14 '14 at 07:16