hostname:
  cmd.run:
    - name: hostname {{ grains['hostname'] }}.{{ grains['avahi-domain'] }}
  file.managed:
    - name: /etc/hostname
    - text: {{ grains['hostname'] }}.{{ grains['avahi-domain'] }}

hosts file:
  file.append:
    - name: /etc/hosts
    - text: "127.0.1.1 {{ grains['hostname'] }}.{{ grains['avahi-domain'] }} {{ grains['hostname'] }}"

avahi:
  pkg.installed:
    - name: avahi
  file.replace:
    - name: /etc/avahi/avahi-daemon.conf
    - pattern: "#domain-name=local"
    - repl: "domain-name={{ grains['avahi-domain'] }}"
  service.running:
    - name: avahi-daemon
    - require:
      - pkg: avahi
      - file: avahi
    - watch:
      - file: /etc/avahi/avahi-daemon.conf

hosts_file:
  file.append:
    - name: /etc/hosts
    - text: "127.0.1.1 {{ grains['hostname'] }}.{{ grains['avahi-domain'] }} {{ grains['hostname'] }}"

set_transient_hostname:
  cmd.run:
    - name: hostnamectl set-hostname {{ grains['hostname'] }}.{{ grains['avahi-domain'] }}
    - onlyif: hostnamectl

hostname:
  cmd.run:
    - name: hostname {{ grains['hostname'] }}.{{ grains['avahi-domain'] }}
  file.managed:
    - name: /etc/hostname
    - text: {{ grains['hostname'] }}.{{ grains['avahi-domain'] }}

avahi:
  pkg.installed:
    - name: avahi
  file.replace:
    - name: /etc/avahi/avahi-daemon.conf
    - pattern: "#domain-name=local"
    - repl: "domain-name={{ grains['avahi-domain'] }}"
  service.running:
    - name: avahi-daemon
    - require:
      - pkg: avahi
      - file: avahi
    - watch:
      - file: /etc/avahi/avahi-daemon.conf

Fix hostname setting for SLES 12
Fix hostname setting for SLES 12

moio/sumaform,MalloZup/sumaform,moio/sumaform,MalloZup/sumaform,MalloZup/sumaform,moio/sumaform,MalloZup/sumaform