You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
notpeter opened this issue
Sep 2, 2015
· 5 comments
Labels
Featurenew functionality including changes to functionality and code refactors, etc.GrainsP3Priority 3PlatformRelates to OS, containers, platform-based utilities like FS, system based apps
It'd be really nice if salt exposed a dns_server grain, maybe with the simple form of:
dns_servers:
- 10.0.0.2
- 8.8.8.8
On unixes this this can be sourced from /etc/resolv.conf, with one line per name server with one of these two variants: nameserver 8.8.8.8 nameserver 2001:4860:4860::8844 (still quite rare, even in ipv6 deployments)
On windows the FIXED_INFO struct returned from GetNetworkParams includes the list of currently configured DNS servers.
The text was updated successfully, but these errors were encountered:
notpeter
changed the title
network config grains: DNS servers and more
network config grains: DNS servers
Sep 2, 2015
You can write your own grain to do that. Start for example, from :
#!/usr/bin/env python''' Very basic grain to return dns configuration. It only works in *nix It does not yet work with "new style" desktop configurations that use a local instance of dnsmasq (it will return 127.0.0.1 as the nameserver)'''from __future__ importabsolute_importimportreimportsalt.utilsdefdns_configuration():
grains={}
ifsalt.utils.is_windows():
returngrainselse:
try:
withsalt.utils.fopen('/etc/resolv.conf', 'r') as_fh:
relevant_lines=[ l.strip() forlin_fh.readlines() ifnotre.match('^\s*#.*$',l) ]
dns_servers=[ matches.group(1) formatchesin [ re.match('^\s*nameserver\s+([.\w]+).*',s) forsinrelevant_lines ] ifmatches ]
search_domains_lines=[lforlinrelevant_linesifre.match('^\s*search\s+\w+.*',l)]
iflen(search_domains_lines) >0:
search_domains=re.split('\s+',search_domains_lines[-1:][0])[1:]
else:
search_domains=[]
exceptIOError:
returngrainsgrains['dns_servers']=dns_serversgrains['dns_search_domains']=search_domainsreturngrains
justinta
added
Feature
new functionality including changes to functionality and code refactors, etc.
Grains
Platform
Relates to OS, containers, platform-based utilities like FS, system based apps
P3
Priority 3
labels
Sep 3, 2015
Featurenew functionality including changes to functionality and code refactors, etc.GrainsP3Priority 3PlatformRelates to OS, containers, platform-based utilities like FS, system based apps
It'd be really nice if salt exposed a dns_server grain, maybe with the simple form of:
On unixes this this can be sourced from /etc/resolv.conf, with one line per name server with one of these two variants:
nameserver 8.8.8.8
nameserver 2001:4860:4860::8844
(still quite rare, even in ipv6 deployments)On windows the FIXED_INFO struct returned from GetNetworkParams includes the list of currently configured DNS servers.
The text was updated successfully, but these errors were encountered: