From 95dff0ef713cd361fe4aa3afcd0adc67bc6c90ff Mon Sep 17 00:00:00 2001 From: Markus Brechtel Date: Thu, 27 Sep 2018 15:48:43 +0200 Subject: [PATCH] live build with installer --- defaults/main.yml | 3 +- tasks/main.yml | 53 +++++----------- templates/desktop.list.chroot.j2 | 3 + templates/isolinux.cfg.j2 | 5 -- templates/lb-config-args.j2 | 18 ++++-- templates/preseed.cfg.j2 | 100 +++++++++++++++++++++++++++++++ vars/main.yml | 5 ++ 7 files changed, 138 insertions(+), 49 deletions(-) create mode 100644 templates/desktop.list.chroot.j2 delete mode 100644 templates/isolinux.cfg.j2 create mode 100644 templates/preseed.cfg.j2 diff --git a/defaults/main.yml b/defaults/main.yml index 0e3416e..55390b5 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,7 +1,8 @@ debian_mirror: http://deb.debian.org/debian +debian_security_mirror: http://security.debian.org/debian-security live_build_serial_console: false -live_build_bootappend_live: boot=live components quiet {{ live_build_serial_console | ternary('console=ttyS0','') }} hostname={{ live_build_hostname }} +live_build_bootappend_live: boot=live components quiet {{ live_build_serial_console | ternary('console=ttyS0','') }} hostname={{ live_build_hostname }} locales=de_DE.UTF-8 timezone=Europe/Berlin keyboard-layouts=de live_build_hostname: "{{ inventory_hostname }}" live_build_distribution: stretch diff --git a/tasks/main.yml b/tasks/main.yml index 7194267..4fd7992 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -36,35 +36,20 @@ chdir: "{{ live_build_directory }}" - name: root user - include_role: + import_role: name: root_user vars: root_target_directory: "{{ live_build_directory }}/config/includes.chroot/" -- name: keyboard configuration - include_role: - name: keyboard_configuration - vars: - root_target_directory: "{{ live_build_directory }}/config/includes.chroot/" - when: live_build_serial_console == false - - name: include common packages template: src: common.list.chroot.j2 dest: "{{ live_build_directory }}/config/package-lists/common.list.chroot" -- name: include console-setup package - copy: - content: console-setup - dest: "{{ live_build_directory }}/config/package-lists/console-setup.list.chroot" - when: live_build_serial_console == false - -- name: resolvconf symlink - file: - src: /etc/resolvconf/run/resolv.conf - dest: "{{ live_build_directory }}/config/includes.chroot/etc/resolv.conf" - force: yes - state: link +- name: include desktop packages + template: + src: desktop.list.chroot.j2 + dest: "{{ live_build_directory }}/config/package-lists/desktop.list.chroot" - name: include custom packages template: @@ -72,54 +57,48 @@ dest: "{{ live_build_directory }}/config/package-lists/custom.list.chroot" when: live_build_custom_packages is defined -- name: isolinx directory +- name: debian-installer installer includes directory file: - path: "{{ live_build_directory }}/config/includes.binary/isolinux" + path: "{{ live_build_directory }}/config/includes.installer" state: directory -- name: isolinux.cfg +- name: debian-installer preseed template: - src: isolinux.cfg.j2 - dest: "{{ live_build_directory }}/config/includes.binary/isolinux/isolinux.cfg" + src: preseed.cfg.j2 + dest: "{{ live_build_directory }}/config/includes.installer/preseed.cfg" - name: lb bootstrap (first build stage) - command: - lb bootstrap + command: lb bootstrap args: chdir: "{{ live_build_directory }}" register: _lb_bootstrap - name: lb chroot (second build stage) - command: - lb chroot + command: lb chroot args: chdir: "{{ live_build_directory }}" register: _lb_chroot - name: lb installer (third build stage) - command: - lb installer + command: lb installer args: chdir: "{{ live_build_directory }}" register: _lb_installer - name: lb binary (fourth build stage) - command: - lb binary + command: lb binary args: chdir: "{{ live_build_directory }}" register: _lb_binary #- name: lb source (fifth build stage) -# command: -# lb source +# command: lb source # args: # chdir: "{{ live_source_directory }}" # register: _lb_source #- name: lb build -# command: -# lb build +# command: lb build # args: # chdir: "{{ live_build_directory }}" # register: _lb_build diff --git a/templates/desktop.list.chroot.j2 b/templates/desktop.list.chroot.j2 new file mode 100644 index 0000000..3ffd921 --- /dev/null +++ b/templates/desktop.list.chroot.j2 @@ -0,0 +1,3 @@ +{% for package in live_build_desktop_packages %} +{{ package }} +{% endfor %} diff --git a/templates/isolinux.cfg.j2 b/templates/isolinux.cfg.j2 deleted file mode 100644 index 02adfad..0000000 --- a/templates/isolinux.cfg.j2 +++ /dev/null @@ -1,5 +0,0 @@ -include live.cfg -default live-amd64 -{% if live_build_serial_console == true %} -serial 0 -{% endif %} diff --git a/templates/lb-config-args.j2 b/templates/lb-config-args.j2 index 32ea12c..e150573 100644 --- a/templates/lb-config-args.j2 +++ b/templates/lb-config-args.j2 @@ -1,17 +1,23 @@ {% if live_build_distribution is defined %} --distribution "{{ live_build_distribution }}" {% endif %} ---mirror-bootstrap {{ debian_mirror }} ---mirror-binary {{ debian_mirror }} +--mirror-bootstrap "{{ debian_mirror }}" +--mirror-chroot-security "{{ debian_security_mirror }}" +--mirror-binary "{{ debian_mirror }}" +--mirror-binary-security "{{ debian_security_mirror }}" +{% if debian_nonfree_firmware %} +--firmware-chroot true +{% endif %} {% if live_build_bootappend_live is defined %} --bootappend-live "{{ live_build_bootappend_live }}" {% endif %} -{% if debian_security_mirror is defined %} ---mirror-binary-security "{{ debian_security_mirror }}" +{% if (debian_backports is defined) and (debian_backports == true) %} +--backports true {% endif %} {% if debian_live_debian_installer is defined %} --debian-installer "{{ debian_live_debian_installer }}" +--debian-installer-gui false +{% if debian_nonfree_firmware %} +--firmware-binary true {% endif %} -{% if (debian_backports is defined) and (debian_backports == true) %} ---backports true {% endif %} diff --git a/templates/preseed.cfg.j2 b/templates/preseed.cfg.j2 new file mode 100644 index 0000000..5efc0a4 --- /dev/null +++ b/templates/preseed.cfg.j2 @@ -0,0 +1,100 @@ +#### Contents of the preconfiguration file (for jessie) +### Localization +# Locale +d-i debian-installer/language string de +d-i debian-installer/country string DE +d-i debian-installer/locale string de_DE.UTF-8 + +# Keyboard selection. +d-i keyboard-configuration/xkb-keymap select de +d-i keyboard-configuration/toggle select No toggling + +### Network configuration + +### Network console + +### Hostname +{# +d-i netcfg/hostname string {{inventory_hostname}} +#} + +### Mirror settings +d-i mirror/country string manual +d-i mirror/http/hostname string deb.debian.org +d-i mirror/http/directory string /debian +d-i mirror/http/proxy string + +### Account setup +# Skip creation of a root account (normal user account will be able to +# use sudo). +d-i passwd/root-login boolean true +# Alternatively, to skip creation of a normal user account. +d-i passwd/make-user boolean false + +# Root password +{% 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 Europe/Berlin +d-i clock-setup/ntp boolean true +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 + +## Controlling how partitions are mounted +# The default is to mount by UUID, but you can also choose "traditional" to +# use traditional device names, or "label" to try filesystem labels before +# falling back to UUIDs. +d-i partman/mount_style select uuid + +d-i partman/default_filesystem string btrfs + +### Apt setup +# You can choose to install non-free and contrib software. +d-i apt-setup/non-free boolean {{ debian_nonfree_firmware }} +d-i apt-setup/contrib boolean {{ debian_nonfree_firmware }} +d-i apt-setup/services-select multiselect security,updates +d-i apt-setup/security_host string security.debian.org + +### Package selection +tasksel tasksel/first multiselect minimal + +# Individual additional packages to install +d-i pkgsel/include string openssh-server python python-apt + +# Whether to upgrade packages after debootstrap. +# Allowed values: none, safe-upgrade, full-upgrade +d-i pkgsel/upgrade select full-upgrade + +# Some versions of the installer can report back on what software you have +# installed, and what software you use. The default is not to report back, +# but sending reports helps the project determine what software is most +# popular and include it on CDs. +popularity-contest popularity-contest/participate boolean false + +### Boot loader installation +# 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 + +# This one makes grub-installer install to the MBR if it also finds some other +# 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 + +### 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/late_command string DIR=/target/root/.ssh; \ +mkdir -p $DIR; \ +chmod 700 $DIR; \ +{% if root_ssh_authorized_keys is defined %} +{% for key in root_ssh_authorized_keys %} +echo '{{key}}' >> $DIR/authorized_keys; \ +{% endfor %} +{% endif %} +echo ssh authorized keys configured diff --git a/vars/main.yml b/vars/main.yml index b8a51d7..799551c 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -55,3 +55,8 @@ live_build_common_packages: - tcpdump - dnsutils - resolvconf + +live_build_desktop_packages: + - xfce4 + - i3 + - firefox-esr