Created
April 25, 2012 11:59
-
-
Save frimik/2489220 to your computer and use it in GitHub Desktop.
Foreman - Update hosts that moved between two subnets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* copy ipaddress facts onto the hosts where the old IPs were 10.100.* and the new IPs are now 10.6* */ | |
| update hosts h | |
| join | |
| fact_values fv ON (h.id = fv.host_id) | |
| join fact_names fn ON (fv.fact_name_id = fn.id) | |
| set h.ip=fv.value | |
| where | |
| h.ip LIKE '10.100.%' fn.name='ipaddress' | |
| AND fv.value LIKE '10.6%'; | |
| /* change subnets into the correct ones */ | |
| update hosts SET subnet_id=3 WHERE ip LIKE '10.61.0.%'; | |
| update hosts SET subnet_id=4 WHERE ip LIKE '10.61.1.%'; | |
| update hosts SET subnet_id=5 WHERE ip LIKE '10.61.2.%'; | |
| update hosts SET subnet_id=6 WHERE ip LIKE '10.61.3.%'; | |
| update hosts SET subnet_id=7 WHERE ip LIKE '10.61.4.%'; | |
| update hosts SET subnet_id=8 WHERE ip LIKE '10.61.5.%'; | |
| update hosts SET subnet_id=9 WHERE ip LIKE '10.61.6.%'; | |
| update hosts SET subnet_id=10 WHERE ip LIKE '10.61.7.%'; | |
| /* Warning: make sure subnet ids here are correct. */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment