2021-06-08 00:40:54 +02:00
|
|
|
---
|
2022-07-21 21:47:20 +02:00
|
|
|
- name: check if iso exists
|
|
|
|
stat:
|
2023-11-12 14:14:07 +01:00
|
|
|
path: "{{ playbook_dir }}/debian-{{ debianunattended_debian_version }}-amd64-netinst-unattended-{{ inventory_hostname }}.iso"
|
2022-07-21 21:47:20 +02:00
|
|
|
delegate_to: localhost
|
|
|
|
register: iso_exists
|
|
|
|
|
|
|
|
- name: stop when facts not set to download Packages
|
|
|
|
meta: end_play
|
|
|
|
when: iso_exists.stat.exists
|
|
|
|
|
2021-06-08 00:40:54 +02:00
|
|
|
- name: install stuff
|
2023-07-31 22:26:26 +02:00
|
|
|
package:
|
2021-06-08 00:40:54 +02:00
|
|
|
name:
|
|
|
|
- xorriso
|
|
|
|
- unzip
|
2023-11-12 14:14:07 +01:00
|
|
|
- cdrkit
|
2021-06-08 00:40:54 +02:00
|
|
|
update_cache: yes
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|
2024-02-07 22:08:56 +01:00
|
|
|
run_once: true
|
2021-06-08 00:40:54 +02:00
|
|
|
|
|
|
|
- name: create project directory
|
|
|
|
file:
|
2022-07-21 21:47:20 +02:00
|
|
|
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}"
|
2021-06-08 00:40:54 +02:00
|
|
|
state: directory
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|
2021-06-08 00:40:54 +02:00
|
|
|
|
|
|
|
- name: Download ISO Image
|
|
|
|
get_url:
|
2023-11-12 14:14:07 +01:00
|
|
|
url: "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-{{ debianunattended_debian_version }}-amd64-netinst.iso"
|
|
|
|
dest: "/opt/ansiblepackages/debianunattended/debian-{{ debianunattended_debian_version }}-amd64-netinst.iso"
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|
2024-02-07 22:08:56 +01:00
|
|
|
run_once: true
|
2021-06-08 00:40:54 +02:00
|
|
|
|
|
|
|
- name: delete old stuff
|
|
|
|
file:
|
2022-07-21 21:47:20 +02:00
|
|
|
path: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/"
|
2021-06-08 00:40:54 +02:00
|
|
|
state: absent
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|
2021-06-08 00:40:54 +02:00
|
|
|
|
|
|
|
- name: extract ISO Image
|
2023-11-12 14:14:07 +01:00
|
|
|
command: "xorriso -osirrox on -indev /opt/ansiblepackages/debianunattended/debian-{{ debianunattended_debian_version }}-amd64-netinst.iso -extract / /opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/"
|
2021-06-08 00:40:54 +02:00
|
|
|
args:
|
2022-07-21 21:47:20 +02:00
|
|
|
creates: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/install.amd/initrd.gz"
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|
2021-06-08 00:40:54 +02:00
|
|
|
|
2022-07-21 21:47:20 +02:00
|
|
|
- name: generate /opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/preseed.cfg
|
2021-06-08 00:40:54 +02:00
|
|
|
template:
|
|
|
|
src: preseed.cfg.j2
|
2022-07-21 21:47:20 +02:00
|
|
|
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/preseed.cfg"
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|
2021-06-08 00:40:54 +02:00
|
|
|
|
2022-07-21 22:36:24 +02:00
|
|
|
- name: generate /opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/boot/grub/grub.cfg
|
|
|
|
template:
|
|
|
|
src: grub.cfg.j2
|
|
|
|
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/boot/grub/grub.cfg"
|
|
|
|
delegate_to: localhost
|
|
|
|
|
|
|
|
- name: edit /opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/isolinux/isolinux.cfg
|
|
|
|
ansible.builtin.lineinfile:
|
|
|
|
path: /opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/isolinux/isolinux.cfg
|
|
|
|
state: absent
|
|
|
|
line: 'default vesamenu.c32'
|
|
|
|
delegate_to: localhost
|
|
|
|
|
2022-07-21 21:47:20 +02:00
|
|
|
- name: generate /opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/md5sum.sh
|
2021-06-08 00:40:54 +02:00
|
|
|
template:
|
|
|
|
src: md5sum.sh.j2
|
|
|
|
mode: "0755"
|
2022-07-21 21:47:20 +02:00
|
|
|
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/md5sum.sh"
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|
2021-06-08 00:40:54 +02:00
|
|
|
|
2022-07-21 21:47:20 +02:00
|
|
|
- name: generate /opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/mergepreseed.sh
|
2021-06-08 00:40:54 +02:00
|
|
|
template:
|
|
|
|
src: mergepreseed.sh.j2
|
|
|
|
mode: "0755"
|
2022-07-21 21:47:20 +02:00
|
|
|
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/mergepreseed.sh"
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|
2021-06-08 00:40:54 +02:00
|
|
|
|
|
|
|
- name: set permissions
|
|
|
|
file:
|
2022-07-21 21:47:20 +02:00
|
|
|
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/install.amd/"
|
2021-06-08 00:40:54 +02:00
|
|
|
mode: +w
|
|
|
|
recurse: yes
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|
2021-06-08 00:40:54 +02:00
|
|
|
|
|
|
|
- name: Extract isofiles/install.amd/initrd.gz
|
|
|
|
command: gunzip isofiles/install.amd/initrd.gz
|
|
|
|
args:
|
2022-07-21 21:47:20 +02:00
|
|
|
chdir: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/"
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|
2021-06-08 00:40:54 +02:00
|
|
|
|
|
|
|
- name: merge preseed.cfg
|
2022-07-21 21:47:20 +02:00
|
|
|
command: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/mergepreseed.sh"
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|
2021-06-08 00:40:54 +02:00
|
|
|
|
2022-07-21 21:47:20 +02:00
|
|
|
- name: generate /opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/late_command.sh
|
2021-06-12 00:27:47 +02:00
|
|
|
template:
|
|
|
|
src: late_command.sh.j2
|
|
|
|
mode: "0755"
|
2022-07-21 21:47:20 +02:00
|
|
|
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/late_command.sh"
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|
2021-06-12 00:27:47 +02:00
|
|
|
|
|
|
|
- name: copy authorized_keys file
|
|
|
|
copy:
|
2023-11-12 14:14:07 +01:00
|
|
|
src: files/ssh-keys.pub
|
2022-07-21 21:47:20 +02:00
|
|
|
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/authorized_keys"
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|
2021-06-12 00:27:47 +02:00
|
|
|
|
2021-10-08 17:09:50 +02:00
|
|
|
- name: copy sudoers file
|
|
|
|
copy:
|
|
|
|
src: files/sudoers
|
2022-07-21 21:47:20 +02:00
|
|
|
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/sudoers"
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|
2021-10-08 17:09:50 +02:00
|
|
|
|
2021-06-08 00:40:54 +02:00
|
|
|
- name: compress isofiles/install.amd/initrd
|
|
|
|
command: gzip isofiles/install.amd/initrd
|
|
|
|
args:
|
2022-07-21 21:47:20 +02:00
|
|
|
chdir: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/"
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|
2021-06-08 00:40:54 +02:00
|
|
|
|
|
|
|
- name: set permissions
|
|
|
|
file:
|
2022-07-21 21:47:20 +02:00
|
|
|
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/install.amd/"
|
2021-06-08 00:40:54 +02:00
|
|
|
mode: -w
|
|
|
|
recurse: yes
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|
2021-06-08 00:40:54 +02:00
|
|
|
|
|
|
|
- name: set permissions
|
|
|
|
file:
|
2022-07-21 21:47:20 +02:00
|
|
|
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/md5sum.txt"
|
2021-06-08 00:40:54 +02:00
|
|
|
mode: +w
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|
2021-06-08 00:40:54 +02:00
|
|
|
|
|
|
|
- name: generate md5sums
|
2022-07-21 21:47:20 +02:00
|
|
|
command: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/md5sum.sh"
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|
2021-06-08 00:40:54 +02:00
|
|
|
|
|
|
|
- name: set permissions
|
|
|
|
file:
|
2022-07-21 21:47:20 +02:00
|
|
|
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/md5sum.txt"
|
2021-06-08 00:40:54 +02:00
|
|
|
mode: -w
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|
2021-06-08 00:40:54 +02:00
|
|
|
|
|
|
|
- name: set permissions
|
|
|
|
file:
|
2022-07-21 21:47:20 +02:00
|
|
|
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/isolinux/isolinux.bin"
|
2021-06-08 00:40:54 +02:00
|
|
|
mode: +w
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|
2021-06-08 00:40:54 +02:00
|
|
|
|
|
|
|
- name: genisoimage
|
2023-11-12 14:14:07 +01:00
|
|
|
command: "genisoimage -r -J -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o {{ playbook_dir }}/debian-{{ debianunattended_debian_version }}-amd64-netinst-unattended-{{ inventory_hostname }}.iso /opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles"
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|