Changeset - cc12c282bb3d
[Not reviewed]
0 1 2
Branko Majic (branko) - 10 years ago 2014-11-08 22:21:43
branko@majic.rs
MAR-2: Added a role for generating the preseed files.
3 files changed with 245 insertions and 0 deletions:
0 comments (0 inline, 0 general)
docs/rolereference.rst
Show inline comments
 
Role Reference
 
==============
 

	
 

	
 
Preseed
 
-------
 

	
 
This role can be used for generating simple preseed files for Debian Wheezy
 
installations.
 

	
 
The generated preseed files allow simplified installation, with a single root
 
partition. A number of common parameters can be provided.
 

	
 

	
 
Parameters
 
~~~~~~~~~~
 

	
 
**preseed_directory** (mandatory)
 
    Destination directory where the preseed files should be stored.
 

	
 
**preseed_servers** (mandatory)
 
  List of servers for which a preseed file should be created. Each item in
 
  this list defines options for a single server. The options are as follows:
 

	
 
  **name** (string, mandatory)
 
    Name associated with the server. This name is used in the preseed
 
    configuration filename.
 

	
 
  **language** (string, mandatory)
 
    Language.
 

	
 
  **country** (string, mandatory)
 
    Country.
 

	
 
  **locale** (string, mandatory)
 
    Locale.
 

	
 
  **keymap** (string, mandatory)
 
    Keymap.
 

	
 
  **network_interface** (string, mandatory)
 
    Name of network interface (for example *eth0*) that should be
 
    configured.
 

	
 
  **network_auto** (boolean, mandatory)
 
    Specifies whether the network configuration should be automatic (using
 
    DHCP) or manual. If manual configuration is selected a number of
 
    additional options needs to be specified.
 

	
 
  **network_ip** (string, mandatory if **network_auto** if *False*)
 
    IP address for the server network interface.
 

	
 
  **network_netmask** (string, mandatory if **network_auto** if *False*)
 
    Netmask for the server network interface.
 

	
 
  **network_gateway** (string, mandatory if **network_auto** if *False*)
 
    Default gateway for the server.
 

	
 
  **network_dns** (string, mandatory if **network_auto** if *False*)
 
    Comma-separated list of DNS servers.
 

	
 
  **network_hostname** (string, mandatory if **network_auto** if *False*)
 
    Server hostname.
 

	
 
  **network_domain** (string, mandatory if **network_auto** if *False*)
 
    Server domain.
 

	
 
  **mirror_hostname** (string, mandatory)
 
    Resolvable hostname of FQDN where the Debian apt repositories can be
 
    found. Only HTTP mirrors are supported.
 

	
 
  **mirror_directory** (string, mandatory)
 
    Directory under which the Debian apt repositories can be found on the
 
    specified mirror.
 

	
 
  **mirror_proxy** (string, optional, default is *None*)
 
    An HTTP proxy that should be used for accessing the Debian apt
 
    repositories.
 

	
 
  **root_password** (string, mandatory)
 
    Initial password that should be set for the server during the
 
    installation.
 

	
 
  **timezone** (string, mandatory)
 
    Timezone that should be used when calculating server time. It is assumed
 
    that the local hardware clock is set to UTC.
 

	
 

	
 
Examples
 
~~~~~~~~
 

	
 
Here is an example configuration for a preseed file for two servers, one with
 
automatic and one with manual network configuration:
 

	
 
.. code-block:: yaml
 

	
 
  ---
 

	
 
  preseed_directory: /var/www/preseed/
 

	
 
  preseed_servers:
 
    - name: test1.example.com
 
      language: en
 
      country: SE
 
      locale: en_US.UTF-8
 
      keymap: us
 
      network_interface: eth0
 
      network_auto: yes
 
      mirror_hostname: ftp.se.debian.org
 
      mirror_directory: /debian
 
      mirror_proxy: http://proxy.example.com/
 
      root_password: testserver
 
      timezone: Europe/Stockholm
 
    - name: test2.example.com
 
      language: en
 
      country: SE
 
      locale: en_US.UTF-8
 
      keymap: us
 
      network_interface: eth0
 
      network_auto: no
 
      network_ip: 10.0.0.10
 
      network_netmask: 255.255.255.0
 
      network_gateway: 10.0.0.1
 
      network_dns: 10.0.0.2,10.0.0.3
 
      network_hostname: test1
 
      network_domain: example.com
 
      mirror_hostname: ftp.se.debian.org
 
      mirror_proxy: http://proxy.example.com/
 
      mirror_directory: /debian
 
      root_password: testserver
 
      timezone: Europe/Stockholm
roles/preseed/tasks/main.yml
Show inline comments
 
new file 100644
 
---
 

	
 
- name: Create directory for storing preseed configurations
 
  file: path="{{ preseed_directory }}" mode=750 state=directory
 

	
 
- name: Create preseed configuration file
 
  template: src="preseed-wheezy.cfg.j2" dest="{{ preseed_directory }}/{{ item.name }}.cfg"
 
            mode=640
 
  with_items: preseed_servers
 
\ No newline at end of file
roles/preseed/templates/preseed-wheezy.cfg.j2
Show inline comments
 
new file 100644
 
#
 
# Pressed configuration file for Debian Wheezy installation for server {{ item.name }}.
 
#
 

	
 

	
 
### Localization configuration
 

	
 
# Language.
 
d-i debian-installer/language string {{ item.language }}
 

	
 
# Country.
 
d-i debian-installer/country string {{ item.country }}
 

	
 
# Locale.
 
d-i debian-installer/locale string {{ item.locale }}
 

	
 
# Keyboard layout.
 
d-i keymap select {{ item.keymap }}
 
d-i keyboard-configuration/xkb-keymap select {{ item.keymap }}
 

	
 

	
 
### Network configuration
 

	
 
# Network interface to configure.
 
d-i netcfg/choose_interface select {{ item.network_interface }}
 

	
 
{% if item.network_auto -%}
 
# DHCP network configuration.
 
d-i netcfg/disable_autoconfig boolean false
 
d-i netcfg/get_hostname string ignored-value
 
d-i netcfg/get_domain string ignored-value
 
{% else -%}
 
# Manual network configuration.
 
d-i netcfg/disable_autoconfig boolean true
 
d-i netcfg/get_ipaddress string {{ item.network_ip }}
 
d-i netcfg/get_netmask string {{ item.network_netmask }}
 
d-i netcfg/get_gateway string {{ item.network_gateway }}
 
d-i netcfg/get_nameservers string {{ item.network_dns }}
 
d-i netcfg/confirm_static boolean true
 

	
 
# Hostname and domain configuration.
 
d-i netcfg/get_hostname string {{ item.network_hostname }}
 
d-i netcfg/get_domain string {{ item.network_domain }}
 
{% endif -%}
 

	
 
# Disable that annoying WEP key dialog.
 
d-i netcfg/wireless_wep string
 

	
 

	
 
### Mirror settings
 
d-i mirror/protocol string http
 
d-i mirror/country string manual
 
d-i mirror/http/hostname string {{ item.mirror_hostname }}
 
d-i mirror/http/directory string {{ item.mirror_directory }}
 
d-i mirror/http/proxy string {{ item.mirror_proxy | default("") }}
 

	
 

	
 
### Account setup
 
# Skip creation of regular user account.
 
d-i passwd/make-user boolean false
 

	
 
# Set root password.
 
d-i passwd/root-password password {{ item.root_password }}
 
d-i passwd/root-password-again password {{ item.root_password }}
 

	
 

	
 
### Clock and time zone setup
 

	
 
# Hardware clock is UTC.
 
d-i clock-setup/utc boolean true
 

	
 
# Timezone.
 
d-i time/zone string {{ item.timezone }}
 

	
 
# Use NTP to set the time during installation.
 
d-i clock-setup/ntp boolean true
 

	
 

	
 
### Partitioning
 

	
 
# Use regular partitioning schema.
 
d-i partman-auto/method string regular
 

	
 
# All files in one partition.
 
d-i partman-auto/choose_recipe select atomic
 

	
 
# Wipe out all partitions.
 
d-i partman-lvm/device_remove_lvm boolean true
 
d-i partman-lvm/confirm_nooverwrite boolean true
 
d-i partman-md/device_remove_md boolean true
 

	
 
# Partition the disk without confirmation.
 
d-i partman-partitioning/confirm_write_new_label boolean true
 
d-i partman/choose_partition select finish
 
d-i partman/confirm boolean true
 
d-i partman/confirm_nooverwrite boolean true
 

	
 

	
 
### Package selection
 

	
 
# Install standard packages and SSH server.
 
tasksel tasksel/first multiselect standard,ssh-server
 

	
 
### Finishing up the installation
 

	
 
# Avoid that last message about the install being complete.
 
d-i finish-install/reboot_in_progress note
0 comments (0 inline, 0 general)