| {#- |
| vim: syntax=jinja |
| -#} |
| {%- from "linux/map.jinja" import network with context -%} |
| # hosts(1) file managed by salt-minion(1) |
| # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN |
| |
| {%- set hosts = { |
| '127.0.0.1': [ |
| 'localhost' |
| ], |
| '127.0.1.1': [ |
| network.fqdn|default(grains.fqdn), |
| network.hostname|default(grains.nodename) |
| ], |
| '::1': [ |
| 'ip6-localhost', |
| 'ip6-loopback' |
| ], |
| 'fe00::0': [ |
| 'ip6-localnet', |
| 'ip6-mcastprefix' |
| ], |
| 'ff02::1': [ |
| 'ip6-allnodes' |
| ], |
| 'ff02::2': [ |
| 'ip6-allrouters' |
| ], |
| 'ff02::3': [ |
| 'ip6-allhosts' |
| ], |
| } -%} |
| {%- for name, host in host_dict.items() -%} |
| {%- for hname in host.names -%} |
| {%- if hname in hosts.get('127.0.1.1', []) -%} |
| {%- do hosts.pop('127.0.1.1') -%} |
| {%- endif %} |
| {%- endfor %} |
| {%- do hosts.update({host.address: host.names}) -%} |
| {%- endfor %} |
| {% for address, entries in hosts|dictsort %} |
| {%- if 'linux_hosts.fqdn_sort_filter' in salt.keys() %} |
| {%- set sorted_entries = salt['linux_hosts.fqdn_sort_filter'](entries) -%} |
| {%- else %} |
| {%- set sorted_entries = entries -%} |
| {%- endif %} |
| {{ address }} {{ sorted_entries|join(' ')|lower }} |
| {%- endfor %} |