diff --git a/cdist/conf/type/__hostname/gencode-remote b/cdist/conf/type/__hostname/gencode-remote index e3f1bee4..973d1d97 100755 --- a/cdist/conf/type/__hostname/gencode-remote +++ b/cdist/conf/type/__hostname/gencode-remote @@ -20,17 +20,28 @@ # along with cdist. If not, see . # -if [ -f "$__object/parameter/name" ]; then - name_should="$(cat "$__object/parameter/name")" -else - name_should="${__target_host%%.*}" -fi - os=$(cat "$__global/explorer/os") name_running=$(cat "$__global/explorer/hostname") name_config=$(cat "$__object/explorer/persistent_hostname") has_hostnamectl=$(cat "$__object/explorer/has_hostnamectl") + +if [ -f "$__object/parameter/name" ]; then + name_should="$(cat "$__object/parameter/name")" +else + case $os in + # RedHat-derivatives and BSDs + centos|fedora|redhat|scientific|freebsd|netbsd|openbsd) + # Hostname is FQDN + name_should="${__target_host}" + ;; + *) + # Hostname is only first component of FQDN + name_should="${__target_host%%.*}" + ;; + esac +fi + ################################################################################ # Check if the hostname is already correct # diff --git a/cdist/conf/type/__hostname/manifest b/cdist/conf/type/__hostname/manifest index 5d9eeeeb..699f3e93 100755 --- a/cdist/conf/type/__hostname/manifest +++ b/cdist/conf/type/__hostname/manifest @@ -24,16 +24,16 @@ os=$(cat "$__global/explorer/os") if [ -f "$__object/parameter/name" ]; then name_should="$(cat "$__object/parameter/name")" else - case "$os" in - # RedHat-derivatives and BSDs - centos|fedora|redhat|scientific|freebsd|netbsd|openbsd) - # Hostname is FQDN - name_should="${__target_host}" - ;; - *) - # Hostname is only first component of FQDN - name_should="${__target_host%%.*}" - ;; + case $os in + # RedHat-derivatives and BSDs + centos|fedora|redhat|scientific|freebsd|netbsd|openbsd) + # Hostname is FQDN + name_should="${__target_host}" + ;; + *) + # Hostname is only first component of FQDN + name_should="${__target_host%%.*}" + ;; esac fi