Page tree
Skip to end of metadata
Go to start of metadata

Here are some notes on trials and tribulations for installing Centos via MAAS.

Simple out-of-the-box deployment use case

MAAS is supposed to have built-in support for Centos deployments, but there are some important assumptions:

  • Through the UI, MAAS only supports automatic IP assignment to the PXE interface (set the interface to "Auto"). See "Custom Network Config for Centos" below for a workaround.
  • Through the UI, MAAS only supports installation of Centos on the first found disk. See "Installing Centos on a 2nd disk" below for a workaround.

If you stick to those assumptions, you should be able to deploy Centos out of the box. But be aware - YMMV.

Using MAAS Curtin Preseed files

MAAS curtin ("Curt Installer") preseed files are needed for most of the workarounds below.

A minimal preseed file example you can use as a template. This file will create a sudo user named "maas" with password "maas", useful if you need to login via the console.

#cloud-config        
debconf_selections:
 maas: |
  {{for line in str(curtin_preseed).splitlines()}}
  {{line}}
  {{endfor}}

late_commands:
  maas: [wget, '--no-proxy', '{{node_disable_pxe_url}}', '--post-data', '{{node_disable_pxe_data}}', '-O', '/dev/null']
  10_adduser: ["curtin", "in-target", "--", "sh", "-c", "adduser maas"]
  20_addpwd: ["curtin", "in-target", "--", "sh", "-c", "echo 'maas:maas'| chpasswd"]
  30_addsudo: ["curtin", "in-target", "--", "sh", "-c", "usermod -aG wheel maas"]

showtrace: true
verbosity: 3

Custom Network Config for Centos

By default, MAAS will only deploy Centos with DHCP-assigned addresses, and only to interfaces that request DHCP addresses. To assign static addresses you need to add these lines to your preseed file in the "late_commands:" section, updated as needed for your network config. MAAS will apply these commands late in the deploy process, and they will be re-run (as part of rc.local) whenever the node reboots. Notes on this example:

  • it is designed for servers with three active interfaces: private/PXE (local only, non-routed), public (with default gateway), and admin (local only, non-routed)
  • it first creates "/etc/rc.local" if it doesn't exist, and adds several commands to it
    • creation of the interface config in /etc/sysconfig/network-scripts/ifcfg-<interface name> (e.g. as here "eno1", "eno3", "eno4"). Note you will need to update these commands for your specific interface names, subnets, gateways, etc
    • in this specific example, removes "/etc/sysconfig/network-scripts/ifcfg-eth0" which is somewhy created in the process and superfluous (there is no eth0 interface in this server example)
    •  restarts the network service, so the changes to the network scripts are applied
    • updates the default gateway (in this example the MAAS server is installing the servers over a non-routed PXE subnet, and when done leaves the servers with a default gateway set to the MAAS server's address on that subnet)
    • removes the default gateway set to the MAAS server's address
    • updates the DNS server (MAAS leaves itself as the DNS server)
    • sets rc.local to be executable
  • Note that upon deploy completion, the admin/PXE interface below will still be set to "dhcp" as rc.local is executed prior to completion of cloud-init. After rc.local, cloud-init sets the ifcfg file for the PXE interface. So to cause the intended config as below to be applied, you will need to reboot the server once after deployment, which will apply the config below (the part of cloud-init which sets the interface config runs only during deployment, or at least seems to).
  40_touch: ["curtin", "in-target", "--", "sh", "-c", "echo 'touch /etc/sysconfig/network' >>/etc/rc.local"]
  50_ifconfig_priv-pxe: ["curtin", "in-target", "--", "sh", "-c", "tee -a /etc/rc.local <<'EOG' \ncat <<EOF >/etc/sysconfig/network-scripts/ifcfg-eno1\nBOOTPROTO=static\nDEVICE=eno1\nHWADDR=b8:ca:3a:aa:bb:cc\nNM_CONTROLLED=no\nONBOOT=yes\nTYPE=Ethernet\nUSERCTL=no\nIPADDR=10.5.62.7\nPREFIX=24\nEOF\nEOG"]
  51_ifconfig_public: ["curtin", "in-target", "--", "sh", "-c", "tee -a /etc/rc.local <<'EOG' \ncat <<EOF >/etc/sysconfig/network-scripts/ifcfg-eno3\nBOOTPROTO=static\nDEVICE=eno3\nHWADDR=b8:ca:3a:aa:bb:dd\nNM_CONTROLLED=no\nONBOOT=yes\nTYPE=Ethernet\nUSERCTL=no\nIPADDR=206.148.3.200\nGATEWAY=206.148.0.193\nPREFIX=27\nEOF\nEOG"]
  52_ifconfig_admin: ["curtin", "in-target", "--", "sh", "-c", "tee -a /etc/rc.local <<'EOG' \ncat <<EOF >/etc/sysconfig/network-scripts/ifcfg-eno4\nBOOTPROTO=static\nDEVICE=eno4\nHWADDR=b8:ca:3a:aa:bb:ee\nNM_CONTROLLED=no\nONBOOT=yes\nTYPE=Ethernet\nUSERCTL=no\nIPADDR=10.5.61.7\nPREFIX=24\nEOF\nEOG"]
  53_ifconfig_del_eth0: ["curtin", "in-target", "--", "sh", "-c", "echo 'rm /etc/sysconfig/network-scripts/ifcfg-eth0' >>/etc/rc.local"]
  60_network: ["curtin", "in-target", "--", "sh", "-c", "echo 'systemctl restart network' >>/etc/rc.local"]
  70_defroute: ["curtin", "in-target", "--", "sh", "-c", "echo 'route add default gw 206.148.0.193' >>/etc/rc.local"]
  71_defroute: ["curtin", "in-target", "--", "sh", "-c", "echo 'route del default gw 10.5.62.254' >>/etc/rc.local"]
  80_dns: ["curtin", "in-target", "--", "sh", "-c", "echo 'sed -i s/10.5.62.254/8.8.8.8/g /etc/resolv.conf' >>/etc/rc.local"]
  99_chmod: ["curtin", "in-target", "--", "sh", "-c", "chmod +x /etc/rc.d/rc.local"]

Installing Centos on a 2nd disk

By default, MAAS only will deploy Centos on the first hard disk it finds. If you have a server with an SSD as sda, which isn't large enough compared to an HDD as sdb, then you will need the following to deploy Centos.

  1. Assuming you are deploying Centos 7.0, on the MAAS server create a curtin preseed file for your server, under /etc/maas/preseeds/curtin_userdata_centos_amd64_generic_centos70_<your server name in MAAS>, e.g. /etc/maas/preseeds/curtin_userdata_centos_amd64_generic_centos70_nuc-2
  2. Enter these lines, updated as needed for your target disk (this example is designed for a 1TB HDD). 
  3. See Successful 2nd disk Centos deployment example for an example Installation log output.

 

#cloud-config        
debconf_selections:
 maas: |
  {{for line in str(curtin_preseed).splitlines()}}
  {{line}}
  {{endfor}}

storage:
  version: 1
  config:
  - id: sdb
    type: disk
    ptable: msdos
    path: /dev/sdb
    name: maindisk
  - id: sdb-part1
    type: partition
    device: sdb
    size: 1GB
    flag: boot
  - id: sdb-part1-fs1
    type: format
    fstype: xfs
    label: boot
    volume: sdb-part1
  - id: sdb-part2
    type: partition
    device: sdb
    size: 800GB
  - id: sdb-part2-fs1
    type: format
    fstype: ext4
    label: centos7
    volume: sdb-part2
  - id: sdb-part2-fs1-mount0
    type: mount
    path: /
    device: sdb-part2-fs1
  - id: sdb-part3
    type: partition
    device: sdb
    size: 128GB
    label: swap
    flag: swap

 

 

  • No labels