2021-06-08 00:40:54 +02:00
|
|
|
---
|
2022-07-21 21:47:20 +02:00
|
|
|
- name: check if iso exists
|
|
|
|
stat:
|
2023-03-18 18:05:35 +01:00
|
|
|
path: "{{ playbook_dir }}/debian-11.6.0-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
|
|
|
|
apt:
|
|
|
|
name:
|
|
|
|
- xorriso
|
|
|
|
- unzip
|
|
|
|
- genisoimage
|
|
|
|
update_cache: yes
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|
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-03-18 18:05:35 +01:00
|
|
|
url: "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.6.0-amd64-netinst.iso"
|
|
|
|
dest: "/opt/ansiblepackages/debianunattended/debian-11.6.0-amd64-netinst.iso"
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|
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-03-18 18:05:35 +01:00
|
|
|
command: "xorriso -osirrox on -indev /opt/ansiblepackages/debianunattended/debian-11.6.0-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:
|
|
|
|
src: files/authorized_keys
|
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-03-18 18:05:35 +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-11.6.0-amd64-netinst-unattended-{{ inventory_hostname }}.iso /opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles"
|
2022-01-21 23:25:22 +01:00
|
|
|
delegate_to: localhost
|