Selaa lähdekoodia

working debian-installter configuration

master
vanhempi
commit
1559ad68ea
10 muutettua tiedostoa jossa 56 lisäystä ja 109 poistoa
  1. +3
    -2
      defaults/main.yml
  2. +10
    -9
      tasks/installer.yml
  3. +3
    -3
      tasks/main.yml
  4. +19
    -4
      tasks/method/iso.yml
  5. +1
    -1
      tasks/method/kexec.yml
  6. +4
    -3
      tasks/preseed.yml
  7. +1
    -0
      tasks/setup.yml
  8. +2
    -2
      templates/isolinux.cfg.j2
  9. +11
    -84
      templates/preseed.cfg.j2
  10. +2
    -1
      templates/run.sh.j2

+ 3
- 2
defaults/main.yml Näytä tiedosto

@@ -1,2 +1,3 @@
installer_directory: host_files/{{ inventory_hostname }}/installer
nonfree_firmware: false
debian_installer_directory: host_files/{{ inventory_hostname }}/installer
debian_installer_nonfree_firmware: false
debian_installer_method: null

+ 10
- 9
tasks/installer.yml Näytä tiedosto

@@ -2,27 +2,28 @@

- name: copy linux kernel
copy:
src: /usr/lib/debian-installer/images/8/amd64/text/debian-installer/amd64/linux
dest: {{installer_directory}}/linux remote_src=true
src: /usr/lib/debian-installer/images/9/amd64/text/debian-installer/amd64/linux
dest: "{{debian_installer_directory}}/linux"
remote_src: true

- name: copy initrd for customization
shell: gunzip -c
/usr/lib/debian-installer/images/8/amd64/text/debian-installer/amd64/initrd.gz
> {{installer_directory}}/initrd
/usr/lib/debian-installer/images/9/amd64/text/debian-installer/amd64/initrd.gz
> {{debian_installer_directory}}/initrd

- name: insert files into initrd
shell: echo {{item}} | cpio --create --format=newc --append --file=initrd
args:
chdir: "{{installer_directory}}"
chdir: "{{debian_installer_directory}}"
with_items:
- preseed.cfg
- run.sh

- name: compress custom initrd
command: gzip -f {{installer_directory}}/initrd
command: gzip -f {{debian_installer_directory}}/initrd

- name: merge initrd.gz and firmware.cpio.gz
shell: cat
/usr/lib/debian-installer/images/8/amd64/text/debian-installer/firmware.cpio.gz
>> {{installer_directory}}/initrd.gz
when: nonfree_firmware
/opt/debian-installer-unofficial-firmware.cpio.gz
>> {{debian_installer_directory}}/initrd.gz
when: debian_installer_nonfree_firmware

+ 3
- 3
tasks/main.yml Näytä tiedosto

@@ -1,11 +1,11 @@
---

- import_tasks: setup.yml
# - import_tasks: setup.yml

- name: host install directory
- name: directory
file:
state: directory
path: "{{installer_directory}}"
path: "{{debian_installer_directory}}"

- import_tasks: preseed.yml
- import_tasks: installer.yml


+ 19
- 4
tasks/method/iso.yml Näytä tiedosto

@@ -1,13 +1,28 @@
---

- name: isolinux.bin
copy: src=/usr/lib/ISOLINUX/isolinux.bin dest={{installer_directory}}/isolinux.bin
copy:
src: /usr/lib/ISOLINUX/isolinux.bin
remote_src: yes
dest: "{{debian_installer_directory}}/isolinux.bin"

- name: ldlinux.c32
copy: src=/usr/lib/syslinux/modules/bios/ldlinux.c32 dest={{installer_directory}}/ldlinux.c32
copy:
src: /usr/lib/syslinux/modules/bios/ldlinux.c32
remote_src: yes
dest: "{{debian_installer_directory}}/ldlinux.c32"

- name: isolinux.cfg
template: src=isolinux.cfg.j2 dest={{installer_directory}}/isolinux.cfg
template:
src: isolinux.cfg.j2
dest: "{{debian_installer_directory}}/isolinux.cfg"

- name: generate iso image
command: genisoimage -o {{installer_directory}}/installer.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table {{installer_directory}}/
command: genisoimage
-o {{debian_installer_directory}}/installer.iso
-b isolinux.bin
-c boot.cat
-no-emul-boot
-boot-load-size 4
-boot-info-table
{{debian_installer_directory}}

+ 1
- 1
tasks/method/kexec.yml Näytä tiedosto

@@ -1,7 +1,7 @@
---

- name: create kexec-script to start debian-installer
copy: content="kexec --command-line=\'auto=true priority=critical --- console=ttyS0\' --initrd=initrd.gz linux" dest={{installer_directory}}/kexec.sh
copy: content="kexec --command-line=\'auto=true priority=critical --- console=ttyS0\' --initrd=initrd.gz linux" dest={{debian_installer_directory}}/kexec.sh

- name: install kexec-tools
apt: pkg=kexec-tools state=present

+ 4
- 3
tasks/preseed.yml Näytä tiedosto

@@ -3,14 +3,15 @@
- name: run.sh
template:
src: run.sh.j2
dest: "{{installer_directory}}/run.sh"
dest: "{{debian_installer_directory}}/run.sh"

- name: stat run.sh
stat:
path: "{{installer_directory}}/run.sh"
path: "{{debian_installer_directory}}/run.sh"
checksum_algorithm: md5
register: run_sh

- name: preseed.cfg
template:
src: preseed.cfg.j2
dest: "{{installer_directory}}/preseed.cfg"
dest: "{{debian_installer_directory}}/preseed.cfg"

+ 1
- 0
tasks/setup.yml Näytä tiedosto

@@ -15,3 +15,4 @@
get_url:
url: http://cdimage.debian.org/cdimage/unofficial/non-free/firmware/stable/current/firmware.cpio.gz
dest: /opt/debian-installer-unofficial-firmware.cpio.gz
when: debian_installer_nonfree_firmware

+ 2
- 2
templates/isolinux.cfg.j2 Näytä tiedosto

@@ -1,5 +1,5 @@
serial 0 115200
{#serial 0 115200#}
default installer
label installer
kernel /linux
append initrd=/initrd.gz auto=true priority=critical --- console=ttyS0
append initrd=/initrd.gz auto=true priority=critical ---{# console=ttyS0 #}

+ 11
- 84
templates/preseed.cfg.j2 Näytä tiedosto

@@ -9,21 +9,7 @@ d-i debian-installer/locale string de_DE.UTF-8
d-i keyboard-configuration/xkb-keymap select de
d-i keyboard-configuration/toggle select No toggling

{#
### Network configuration
{% if (networks is defined) and (netname is defined) and (networks[netname] is defined) %}
d-i netcfg/choose_interface select {{ networks[netname].mac | default("auto") }}

{% if (networks[netname].type is defined) and (networks[netname].type == 'static') %}
d-i netcfg/disable_autoconfig boolean true
d-i netcfg/get_ipaddress string {{ networks[netname].ip | ipaddr('address') }}
d-i netcfg/get_netmask string {{ networks[netname].ip | ipaddr('netmask') }}
d-i netcfg/get_gateway string {{ networks[netname].gateway }}
d-i netcfg/get_nameservers string {{ networks[netname].nameservers | join(" ") }}
d-i netcfg/confirm_static boolean true
{% endif %}
{% endif %}
#}

### Network console
{% if network_console is defined %}
@@ -36,7 +22,7 @@ d-i netcfg/hostname string {{inventory_hostname}}

### Mirror settings
d-i mirror/country string manual
d-i mirror/http/hostname string debian.thengo.net
d-i mirror/http/hostname string deb.debian.org
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string

@@ -45,35 +31,20 @@ d-i mirror/http/proxy string
# use sudo).
d-i passwd/root-login boolean true
# Alternatively, to skip creation of a normal user account.
d-i passwd/make-user boolean true
d-i passwd/make-user boolean false

# Root password
d-i passwd/root-password-crypted password {{ passwords_hashed["root"] }}

# local-admin
d-i passwd/user-fullname string Administrator
d-i passwd/username string local-admin
d-i passwd/user-password-crypted password {{ passwords_hashed["local-admin"] }}
d-i passwd/user-uid string 999
{% if root_password is defined %}
d-i passwd/root-password-crypted password {{ root_password }}
{% endif %}

### Clock and time zone setup
d-i clock-setup/utc boolean true
d-i time/zone string Etc/UTC
d-i time/zone string Europe/Berlin
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server string ntp1.thengo.net ntp2.thengo.net ntp3.thengo.net
d-i clock-setup/ntp-server string 0.de.pool.ntp.org 1.de.pool.ntp.org 2.de.pool.ntp.org 3.de.pool.ntp.org

### Partitioning
{% if partitioning is defined %}
## Partitioning example
# If the system has free space you can choose to only partition that space.
# This is only honoured if partman-auto/method (below) is not set.
#d-i partman-auto/init_automatically_partition select biggest_free

# You can choose one of the three predefined partitioning recipes:
# - atomic: all files in one partition
# - home: separate /home partition
# - multi: separate /home, /var, and /tmp partitions
d-i partman-auto/choose_recipe select atomic

## Controlling how partitions are mounted
# The default is to mount by UUID, but you can also choose "traditional" to
@@ -83,48 +54,10 @@ d-i partman/mount_style select uuid

d-i partman/default_filesystem string btrfs

#d-i partman-auto/disk string /dev/sda

d-i partman-auto/method string regular

# partitioning
d-i partman-basicfilesystems/choose_label string gpt
d-i partman-basicfilesystems/default_label string gpt
d-i partman-partitioning/choose_label string gpt
d-i partman-partitioning/default_label string gpt
d-i partman/choose_label string gpt
d-i partman/default_label string gpt
d-i partman-partitioning/choose_label select gpt

partman-base partman/default_filesystem string btrfs

d-i partman-auto/choose_recipe atomic

# This makes partman automatically partition without confirmation.
d-i partman-md/confirm boolean true
d-i partman-md/confirm_nooverwrite boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true

# If one of the disks that are going to be automatically partitioned
# contains an old LVM configuration, the user will normally receive a
# warning. This can be preseeded away...
d-i partman-lvm/device_remove_lvm boolean true
# The same applies to pre-existing software RAID array:
d-i partman-md/device_remove_md boolean true
# And the same goes for the confirmation to write the lvm partitions.
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true

# do not complain about missing swap partition
#d-i partman-basicfilesystems/no_swap boolean false
{% endif %}

### Apt setup
# You can choose to install non-free and contrib software.
d-i apt-setup/non-free boolean {{ nonfree_firmware }}
d-i apt-setup/contrib boolean {{ nonfree_firmware }}
d-i apt-setup/non-free boolean {{ debian_installer_nonfree_firmware }}
d-i apt-setup/contrib boolean {{ debian_installer_nonfree_firmware }}
d-i apt-setup/services-select multiselect security,updates
d-i apt-setup/security_host string security.debian.org

@@ -145,7 +78,6 @@ d-i pkgsel/upgrade select full-upgrade
popularity-contest popularity-contest/participate boolean false

### Boot loader installation
{% if bootloader is defined %}
# This is fairly safe to set, it makes grub install automatically to the MBR
# if no other operating system is detected on the machine.
d-i grub-installer/only_debian boolean true
@@ -154,17 +86,12 @@ d-i grub-installer/only_debian boolean true
# OS, which is less safe as it might not be able to boot that other OS.
d-i grub-installer/with_other_os boolean true

d-i grub-installer/bootdev string {{ bootdev | default("default") }}

d-i grub-installer/password-crypted password {{ passwords_hashed["grub"] }}
{% endif %}

### Finishing up the installation
# Avoid that last message about the install being complete.
d-i finish-install/reboot_in_progress note

### Running custom commands during the installation
d-i preseed/run string run.sh
d-i preseed/run/checksum string {{ run_sh.stat.md5 }}
d-i preseed/run/checksum string {{ run_sh.stat.checksum }}

d-i preseed/late_command string mkdir -p /target/root/.ssh; cp /.ssh/authorized_keys /target/root/.ssh/authorized_keys; mkdir -p /target/home/local-admin/.ssh; cp /.ssh/authorized_keys /target/home/local-admin/.ssh/authorized_keys;
d-i preseed/late_command string mkdir -p /target/root/.ssh; cp /.ssh/authorized_keys /target/root/.ssh/authorized_keys;

+ 2
- 1
templates/run.sh.j2 Näytä tiedosto

@@ -1,9 +1,10 @@
#!/bin/sh

{% if root_ssh_authorized_keys is defined %}
mkdir -p /.ssh
cat > /.ssh/authorized_keys << EOF
{% if root_ssh_authorized_keys is defined %}
{% for key in root_ssh_authorized_keys %}
{{key}}
{% endfor %}
{% endif %}
EOF

Loading…
Peruuta
Tallenna