Skip to content

Commit

Permalink
feat(hostname): add hostname to /etc/hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
noelmcloughlin committed Aug 31, 2021
1 parent 6ca33f2 commit acdb8f7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions hostsfile/hostname.sls
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

{%- if grains['os_family'] == 'RedHat' %}

etc-sysconfig-network:
hostsfile-etc-sysconfig-network:
cmd.run:
- name: echo -e "NETWORKING=yes\nHOSTNAME={{ hostname }}\n" > /etc/sysconfig/network
- unless: test -f /etc/sysconfig/network
Expand All @@ -33,7 +33,13 @@ etc-sysconfig-network:
- backup: false
{% endif %}
set-fqdn:
hostsfile-{{ fqdn }}-hosts-entry:
host.present:
- ip: {{ grains.fqdn_ip4 }}
- names:
- {{ fqdn }}
hostsfile-set-fqdn:
cmd.run:
{% if grains["init"] == "systemd" %}
- name: hostnamectl set-hostname {{ hostname }}
Expand Down

0 comments on commit acdb8f7

Please sign in to comment.