diff --git a/.gitignore b/.gitignore deleted file mode 100644 index b25c15b..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*~ diff --git a/defaults/main.yml b/defaults/main.yml index c965c54..ee1b6a7 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,4 +1,2 @@ installer_directory: host_files/{{ inventory_hostname }}/installer nonfree_firmware: false -img_size: 8 -memory: 512 diff --git a/meta/main.yml b/meta/main.yml deleted file mode 100644 index 307399e..0000000 --- a/meta/main.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -dependencies: - - name: static_host_vars - static_host_vars_default: - uuid: "{{ lookup('pipe','uuid') }}" - networks: "{{ { netname : { 'mac': '%02x' | format( (2**44)*5 + 2**41 + (2**32)*84 + (16777216|random) ) | hwaddr( 'linux' ) } } }}" - when: install=="vm" - - name: password - password_name: root - password_hash: sha512 - password_wordlists: ['en'] - password_space: true - password_bits: 96 - - name: password - password_name: "local-admin" - password_hash: sha512 - password_wordlists: ['en'] - password_space: true - password_bits: 96 - - name: password - password_name: grub - password_hash: md5 - password_wordlists: ['en'] - password_space: true - password_bits: 96 diff --git a/tasks/installer.yml b/tasks/installer.yml index 57af1ec..948f333 100644 --- a/tasks/installer.yml +++ b/tasks/installer.yml @@ -1,22 +1,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 + copy: + src: /usr/lib/debian-installer/images/8/amd64/text/debian-installer/amd64/linux + dest: {{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 + shell: gunzip -c + /usr/lib/debian-installer/images/8/amd64/text/debian-installer/amd64/initrd.gz + > {{installer_directory}}/initrd - name: insert files into initrd shell: echo {{item}} | cpio --create --format=newc --append --file=initrd args: - chdir: "{{installer_directory}}/" + chdir: "{{installer_directory}}" with_items: - - preseed.cfg - - run.sh + - preseed.cfg + - run.sh - name: compress custom initrd command: gzip -f {{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 + shell: cat + /usr/lib/debian-installer/images/8/amd64/text/debian-installer/firmware.cpio.gz + >> {{installer_directory}}/initrd.gz when: nonfree_firmware diff --git a/tasks/main.yml b/tasks/main.yml index e3efa0f..3d784fd 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,19 +1,17 @@ --- -#- include: tools.yml +- import_tasks: setup.yml - name: host install directory - file: state=directory path={{installer_directory}} + file: + state: directory + path: "{{installer_directory}}" -- include: preseed.yml +- import_tasks: preseed.yml +- import_tasks: installer.yml -- include: installer.yml +- include: method/kexec.yml + when: debian_installer_method == "kexec" -- include: kexec.yml - when: install == "kexec" - -- include: iso.yml - when: (install == "iso") or (install == "vm") - -- include: vm.yml - when: install == "vm" +- include: method/iso.yml + when: debian_installer_method == "iso" diff --git a/tasks/iso.yml b/tasks/method/iso.yml similarity index 99% rename from tasks/iso.yml rename to tasks/method/iso.yml index 1c52c1c..a24cb8b 100644 --- a/tasks/iso.yml +++ b/tasks/method/iso.yml @@ -11,4 +11,3 @@ - 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}}/ - diff --git a/tasks/kexec.yml b/tasks/method/kexec.yml similarity index 100% rename from tasks/kexec.yml rename to tasks/method/kexec.yml diff --git a/tasks/preseed.yml b/tasks/preseed.yml index 11f669c..caaad97 100644 --- a/tasks/preseed.yml +++ b/tasks/preseed.yml @@ -1,12 +1,16 @@ --- -- name: template run.sh - template: src=run.sh.j2 dest={{installer_directory}}/run.sh +- name: run.sh + template: + src: run.sh.j2 + dest: "{{installer_directory}}/run.sh" - name: stat run.sh - stat: path={{installer_directory}}/run.sh + stat: + path: "{{installer_directory}}/run.sh" register: run_sh - -- name: template preseed.cfg - template: src=preseed.cfg.j2 dest={{installer_directory}}/preseed.cfg +- name: preseed.cfg + template: + src: preseed.cfg.j2 + dest: "{{installer_directory}}/preseed.cfg" diff --git a/tasks/setup.yml b/tasks/setup.yml new file mode 100644 index 0000000..6195147 --- /dev/null +++ b/tasks/setup.yml @@ -0,0 +1,17 @@ +--- + +- name: install required software + apt: + name: "{{item}}" + with_items: + - cpio + - debian-installer-9-netboot-amd64 + - genisoimage + - syslinux + - isolinux + - pxelinux + +- name: download unofficial firmware for debian-installer + 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 diff --git a/tasks/tools.yml b/tasks/tools.yml deleted file mode 100644 index cc48dac..0000000 --- a/tasks/tools.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- - -- name: install required software - apt: name={{item}} state=present - with_items: - - cpio - - debian-installer-8-netboot-amd64 - - genisoimage - - syslinux - - isolinux - - pxelinux - -- name: download d-i non-free firmware - get_url: url=http://cdimage.debian.org/cdimage/unofficial/non-free/firmware/stable/current/firmware.cpio.gz dest=/usr/lib/debian-installer/images/8/amd64/text/debian-installer/firmware.cpio.gz diff --git a/tasks/vm.yml b/tasks/vm.yml deleted file mode 100644 index d786537..0000000 --- a/tasks/vm.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- name: install vm - command: virt-install -n {{ inventory_hostname }} --memory {{memory}} --vcpus {{vcpus|default(1)}} --disk size={{img_size}} --network network={{netname}},mac={{networks[netname].mac}},model=e1000 --cdrom {{installer_directory}}/installer.iso --os-variant=debianwheezy diff --git a/templates/preseed.cfg.j2 b/templates/preseed.cfg.j2 index abb44ed..8d0dc2e 100644 --- a/templates/preseed.cfg.j2 +++ b/templates/preseed.cfg.j2 @@ -9,6 +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") }} @@ -22,6 +23,7 @@ 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 %} @@ -50,7 +52,7 @@ 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/username string local-admin d-i passwd/user-password-crypted password {{ passwords_hashed["local-admin"] }} d-i passwd/user-uid string 999 diff --git a/templates/run.sh.j2 b/templates/run.sh.j2 index d8e0845..4f332ee 100644 --- a/templates/run.sh.j2 +++ b/templates/run.sh.j2 @@ -1,7 +1,9 @@ #!/bin/sh +{% if root_ssh_authorized_keys is defined %} mkdir -p /.ssh - cat > /.ssh/authorized_keys << EOF -{{ lookup('file', 'ssh_authorized_keys') }} +{% for key in root_ssh_authorized_keys %} +{{key}} +{% endfor %} EOF