fgci-org / fgci-ansible

:microscope: Collection of the Finnish Grid and Cloud Infrastructure Ansible playbooks
MIT License
54 stars 18 forks source link

set a static hostname #177

Open martbhell opened 7 years ago

martbhell commented 7 years ago

Maybe we should set a static hostname? What is the preferred/recommended method from RedHat?

On test system compute nodes:

$ cat /etc/hostname
localhost.localdomain

$ hostnamectl
   Static hostname: localhost.localdomain
Transient hostname: io4.int.fgci.csc.fi
         Icon name: computer-server
           Chassis: server
        Machine ID: 0DHERE
           Boot ID: cDHERE
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-514.2.2.el7.x86_64
      Architecture: x86-64
martbhell commented 7 years ago

Setting a good one in "static" means that the server has a good hostname before DHCP. This can be observed by running "journalctl -b 0" (journal of the last boot).

Without dhcp probably the network init script sets it while getting the info from "ipcalc --silent --hostname $IPADDR" during bootup.

before:

# hostnamectl status
   Static hostname: localhost.localdomain
Transient hostname: io2.int.fgci.csc.fi

command:

hostnamectl set-hostname --static io2.int.fgci.csc.fi

after:

# hostnamectl status
   Static hostname: io2.int.fgci.csc.fi

and after a reboot:

# hostnamectl 
   Static hostname: io2.int.fgci.csc.fi
         Icon name: computer-server
           Chassis: server

There is an ansible hostname module 1 which seems 2 to run hostnamectl --pretty --static and --transient . Should probably use that. Which role to add this to though?

martbhell commented 7 years ago

A benefit of setting a static hostname: "ibnetdiscover" has the hostname of the node