Saltstack Official Linux Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
719B

  1. {%- from "linux/map.jinja" import network with context %}
  2. {%- if network.enabled %}
  3. {%- if grains.os_family in ['Arch', 'Debian'] %}
  4. linux_hostname_file:
  5. file.managed:
  6. - name: {{ network.hostname_file }}
  7. - source: salt://linux/files/hostname
  8. - template: jinja
  9. - user: root
  10. - group: root
  11. - mode: 644
  12. - watch_in:
  13. - cmd: linux_enforce_hostname
  14. {%- endif %}
  15. linux_enforce_hostname:
  16. cmd.wait:
  17. - name: hostname {{ network.hostname }}
  18. - unless: test "$(hostname)" = "{{ network.hostname }}"
  19. {#
  20. linux_hostname_hosts:
  21. host.present:
  22. - ip: {{ grains.ip4_interfaces[network.get('default_interface', 'eth0')][0] }}
  23. - names:
  24. - {{ network.fqdn }}
  25. - {{ network.hostname }}
  26. #}
  27. {%- endif %}