Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Ansible for OS autoinstall


The project goal is to provide a flexible and as simple as possible configuration tool for unattended OS installation via network for various linux distributions. It was designed to setup dozen of production and other servers and can be used by professional system administrators or for development/testing/education purposes. The playbook contains ready to use installation templates for various distributions.

A copy of a OS distribution itself is not required(!) and with the supplied default configuration an OS installation will be performed via internet from site. However if you are going to setup dozens of servers it's highly recommended to make and configure a local mirror for the required OS.


Templates for unattended installation included in the playbook:

  • CentOS 6-7
  • Fedora 24-26
  • Debian Wheezy, Jessie, Stretch
  • Ubunty Trusty, Xenial, Bionic
  • OpenSuse 12.*, 13.*
  • (OpenSuse)Leap 41.*, 42.*, 15.0

Other distributions which support kickstart/preseed/autoyast can be easily added.

The playbook generates pxe boot and EFI grub menu files, so if you setup pxe boot environment(briefly described at the end) you'll have a convenient way to manage servers installation.

The playbook supports any number of an OS configurations so if you have several groups of servers with different configuration you can describe it in separate autoinstall 'receipt' files.


The playbook is not supposed to cover setup for network boot services environment but focused on providing a ‘framework’ for generation autoinstall files for various distributions.

In the order to effectively use the playbook for your particular purposes you have to understand the principles of Linux network boot and have a base knowledge about autoinstall files for the required OS:


Ansible version >=

In the order to perform install you need working PXE boot environment services:

  • dhcp: network boot ip address configuration
  • tftp: pxe/efi image serving
  • http: serve autoinstall (kickstart/preseed/autoyast) files


Playbook structure

Global configuration variables defined at site_vars.yml Templates for autoinstall files at templates/ks , templates/preseed and templates/yast directories.

The configuration is performed via hosts file and autoinstall files customization.

Host variables

Networking parameters

If ip is not specified, DHCP will be used

  • ip : ip address of the host
  • mac : mac address of the interface. if supplied, the host will not be shown in default menu but only menu for host will be displayed
  • netmask : netmask of network
  • gateway : default network gateway
  • hostname : inventory host record
  • domain : host domain
  • nameservers : list of DNS servers
  • netargs : additional parameters to configure network. as an example for kickstart bonding: netargs='--bondopts=miimon=100,mode=1 --bondslaves=eth0,eth1'
  • bootargs : additional boot parameters. as for previous example it's required to add: bootargs='linux bond=bond0:eth0,eth1:mode=1'

OS parameters

Autoinstall file location and name convention: templates/<ks|preseed|yast>/<os>.<osver>[.type].cfg.j2 as an instance centos.7.cfg.j2

  • drive : block device to use for partition excluding /dev/ ( sda | hda | vda ). Default: sda
  • os : the name of OS
  • osver : OS version
  • type : a custom variant for installation
  • rootpw : encrypted root password. default password is root

Menu parameters

  • menu : all hosts with the same menu will be grouped and shown on the second level menu items

Inventory groups

A host must belong to at least one of the groups:

  • ks : the group for kickstart
  • preseed : the group for preseed
  • yast : the group for autoyast

The group is used to identify the type of autoinstall.


ansible-playbook -i hosts site.yaml

See also example hosts & site_vars.yml

An example to setup network boot services for CentOS 7

# configure epel release
yum install

# install required packages
yum install syslinux-tftpboot tftp-server dhcp xinetd nginx 

# if you are going to use UEFI boot, you need to put grub2 efi loader, as an instance
mkdir -p /var/lib/tftpboot/efi.cfg
curl > /var/lib/tftpboot/efi.cfg/grubx64.efi 

# provide minimal dhcp configuration
cat <<'EOF' > /etc/dhcp/dhcpd.conf
allow unknown-clients;
default-lease-time 1800;
max-lease-time 7200;
option arch code 93 = unsigned integer 16; # RFC4578
set pxetype = option arch;

subnet netmask {
  option broadcast-address;
  option domain-name-servers;
  option domain-name localdomain;
  default-lease-time 1800;
  max-lease-time 7200;
  option netbios-name-servers;
  option routers;
  class "pxeclients" {
    match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
    if pxetype=00:09 or pxetype=00:07 {
      filename "efi.cfg/grubx64.efi";
    } else {
      filename "gpxelinux.0";

# configure nginx to serve autoinstall files
cat <<'EOF' >/etc/nginx/default.d/ks.conf                                             
location /kickstart {
root /var/lib/;

# start services
service dhcpd start
service xinetd start
service nginx start