Sample deployment of a new server
=================================

In this section we describe the deployment of a new server from
scratch.
All the operations will be performed using `bob`, the command-line
client for interacting with `sysdb`.

The informations we need are:

  - the server name: ``logging-ra.psi.ch``
  - the server MAC address: ``23:3d:ef:33:11:22``
  - static or dynamic IP: ``static``
  - the OS installer: ``rhel79server``
  - the server role: ``role::logging_server``
  - the server environment in puppet: ``prod``
  - the sysdb environment: ``daas``
  - optional the group inside the sysdb environment (``default`` if not specified): ``logging``

On our laptop, where we have a local copy of `bob`, we first setup
some environment variables to have shorter commands: ::

  export PSI_BOB_URL=https://boot00-test.psi.ch/sysdb
  export PSI_BOB_USER=talamo_i

The $PSI_BOB_USER is needed because our local user is different from
the one on sysdb. It could also be specified on the command line or
let `bob` take the local username.
  
We then create a deployment environment::

  bob env add daas talamo_i daas-admins 'DaaS Cluster'
  
We add the node to the environment, specifing ``netboot`` as
the boot action ::

  bob node add logging-ra.psi.ch daas netboot

We setup its MAC address: ::

  bob node add-mac logging-ra.psi.ch 23:3d:ef:33:11:22
  
Next decide how the IP address is configured (``dhcp`` or ``static``): ::

  bob node set-attr syslog-ra.psi.ch network=static

And which installer is used: ::

  bob node set-attr syslog-ra.psi.ch ipxe_installer=rhel79server

And we finally setup the puppet role and puppet environment: ::
  
  bob node set-attr syslog-ra.psi.ch puppet_role=role::log_server
  bob node set-attr syslog-ra.psi.ch puppet_env=prod
  bob node set-attr syslog-ra.psi.ch puppet_group=logging


PXE server-side configuration
-----------------------------

In case the node is configured to use legacy BIOS mode (and
not UEFI mode) the following has to be run on the PXE server to make
the node boot the ipxe image:  ::

  cd /afs/psi.ch/service/linux/tftpboot/pxelinux.cfg/
  ln -sf lxprod logging-ra
  MAC='the::node::mac::address'
  MACFILENAME="01-`echo $MAC|tr 'A-Z' 'a-z'| sed 's/:/-/g'`"
  ln -sf logging-ra $MACFILENAME

Otherwise the node will boot with the old pxe configuration. In such
case is possible to boot ipxe typing `lxprod` on the PXE command line.
