Git Product home page Git Product logo

ansible-os-autoinstall's Introduction

Ansible for OS autoinstall

Overview

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 http://mirror.yandex.ru 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.

Features

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.

Caveats

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:

Requirements

Ansible version >= 2.2.1.0

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

Description

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.

Usage

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 http://mirror.yandex.ru/epel/7/x86_64/e/epel-release-7-10.noarch.rpm

# 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 https://mirror.yandex.ru/centos/7/os/x86_64/EFI/BOOT/grubx64.efi > /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 10.0.0.0 netmask 255.255.255.0 {
  range 10.0.0.128 10.0.0.254;
  option broadcast-address 10.0.0.255;
  option domain-name-servers 10.0.0.1;
  option domain-name localdomain;
  default-lease-time 1800;
  max-lease-time 7200;
  option netbios-name-servers 10.0.0.1;
  option routers 10.0.0.1;
  next-server 10.0.0.1;
  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";
    }
  }
}
EOF

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

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

ansible-os-autoinstall's People

Contributors

newsgate avatar sergevs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-os-autoinstall's Issues

No hosts matched

Hi, I'm trying to use this project to automate the installation of redhat workstation 7.4. I have configured the pxe boot infrastructure (tftp, http, dhcp), and made a kickstart file for redhat workstation 7.4 which I have tested it separately and it works. Now when I try to run site.yml file it gives me an error "no host matched". I'm a bit confused about your hosts file configuration because what I know is that the inventory file should contain the IP or the hostname of the targeted machine, but I don't get the way your file is configured, I appreciate a little explanation about it. Thanx!

Creation of unattended install media

I am looking for a way to create unattended installation media.
Is it supported with this framework to only create the autoyast, kickstart, seed files and perform boot iso creation in another step where the boot media contain these files?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.