creating 'location' fact
I'm relatively new to puppet and have a puppet server up and some agents deployed on some test nodes. We have servers in two different locations (at a colo facility and on campus). I'd like to be able to take actions in some of my classes based off of the location (e.g. either 'colo' or 'campus'). I can determine the location based upon the server IP address but i'm not sure how to actually put that into practice.
I'm reading up on hiera but definitely don't have my head wrapped around that yet. I'm thinking that I should somehow define in hiera the list of subnets in use in each of the two locations and associate those with the correct location.
For example, if my subnet to location mapping is this:
192.168.1.0/24, 192.168.2.0/24 => location = colo
192.168.3.0/24, 192.168.4.0/24 => location = campus
I'm not sure how to translate that into something useable inside my common.yaml. My common.yaml (/etc/puppetlabs/code/hieradata/common.yaml) currently looks like this:
#common.yaml
---
ntp::autoupdate: true
ntp::enable: true
ntp::servers:
- tick.gatech.edu
profile::puppet::runinterval: 600
How would I code that in common.yaml? Is this the best way to determine 'location' of a node? Any help is most appreciated.
Gene
Location mapping should be made via your network switches, not via IP-addresses. Where your computers are wired determine their location, not their addresses.
Thanks for the comment Kai. I was looking to determine the location of my nodes and the easiest way I could think of to do that was based upon the node's IP address. Based upon the subnet the node resides in, I can then set the appropriate root password. That was my goal.
Ah, OK, in that case, the approach lavaman suggested is sufficient.