Skip to content

Instantly share code, notes, and snippets.

@leonkatz
Created April 14, 2017 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leonkatz/3ba86a15886074d8742270952f28ea4d to your computer and use it in GitHub Desktop.
Save leonkatz/3ba86a15886074d8742270952f28ea4d to your computer and use it in GitHub Desktop.
hostname_gist
{% set minion_id = grains['id'] %}
{% set host, domain = minion_id.split('.',1) %}
{% set this_ipv4 = salt['network.ipaddrs']()[0] %}
common.formula.hostname "Update my name {{ minion_id }}":
network.system:
- enabled: True
- hostname: {{ host }}
- apply_hostname: True
common.formula.hostname "/etc/hosts":
host.present:
- ip: {{ this_ipv4 }}
- names:
- {{ minion_id }}
- {{ host }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment