ansible-role-debianunattended/tasks/main.yml

154 lines
5.3 KiB
YAML
Raw Normal View History

---
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
- name: install stuff
2023-07-31 22:26:26 +02:00
package:
name:
- xorriso
- unzip
2023-11-12 14:14:07 +01:00
- cdrkit
update_cache: yes
delegate_to: localhost
run_once: true
- name: create project directory
file:
2022-07-21 21:47:20 +02:00
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}"
state: directory
delegate_to: localhost
- 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"
delegate_to: localhost
run_once: true
- name: delete old stuff
file:
2022-07-21 21:47:20 +02:00
path: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/"
state: absent
delegate_to: localhost
- 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/"
args:
2022-07-21 21:47:20 +02:00
creates: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/install.amd/initrd.gz"
delegate_to: localhost
2022-07-21 21:47:20 +02:00
- name: generate /opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/preseed.cfg
template:
src: preseed.cfg.j2
2022-07-21 21:47:20 +02:00
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/preseed.cfg"
delegate_to: localhost
- 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
template:
src: md5sum.sh.j2
mode: "0755"
2022-07-21 21:47:20 +02:00
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/md5sum.sh"
delegate_to: localhost
2022-07-21 21:47:20 +02:00
- name: generate /opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/mergepreseed.sh
template:
src: mergepreseed.sh.j2
mode: "0755"
2022-07-21 21:47:20 +02:00
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/mergepreseed.sh"
delegate_to: localhost
- name: set permissions
file:
2022-07-21 21:47:20 +02:00
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/install.amd/"
mode: +w
recurse: yes
delegate_to: localhost
- 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 }}/"
delegate_to: localhost
- name: merge preseed.cfg
2022-07-21 21:47:20 +02:00
command: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/mergepreseed.sh"
delegate_to: localhost
2022-07-21 21:47:20 +02:00
- name: generate /opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/late_command.sh
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"
delegate_to: localhost
- 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"
delegate_to: localhost
- name: copy sudoers file
copy:
src: files/sudoers
2022-07-21 21:47:20 +02:00
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/sudoers"
delegate_to: localhost
- 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 }}/"
delegate_to: localhost
- name: set permissions
file:
2022-07-21 21:47:20 +02:00
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/install.amd/"
mode: -w
recurse: yes
delegate_to: localhost
- name: set permissions
file:
2022-07-21 21:47:20 +02:00
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/md5sum.txt"
mode: +w
delegate_to: localhost
- name: generate md5sums
2022-07-21 21:47:20 +02:00
command: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/md5sum.sh"
delegate_to: localhost
- name: set permissions
file:
2022-07-21 21:47:20 +02:00
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/md5sum.txt"
mode: -w
delegate_to: localhost
- name: set permissions
file:
2022-07-21 21:47:20 +02:00
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/isolinux/isolinux.bin"
mode: +w
delegate_to: localhost
- 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"
delegate_to: localhost